惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
Microsoft Azure Blog
Microsoft Azure Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Y
Y Combinator Blog
博客园_首页
有赞技术团队
有赞技术团队
博客园 - Franky
腾讯CDC
G
Google Developers Blog
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
D
Docker
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
U
Unit 42
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(telegram): prove mixed cache recovery · openclaw/ope...
obviyus · 2026-05-11 · via Recent Commits to openclaw:main

@@ -1,4 +1,4 @@

1-

import { readFile, rm } from "node:fs/promises";

1+

import { readFile, rm, writeFile } from "node:fs/promises";

22

import type { Message } from "@grammyjs/types";

33

import { describe, expect, it, vi } from "vitest";

44

import {

@@ -8,6 +8,28 @@ import {

88

resolveTelegramMessageCachePath,

99

} from "./message-cache.js";

101011+

type PersistedCacheEntry = {

12+

key: string;

13+

node: {

14+

sourceMessage: Message;

15+

};

16+

};

17+18+

function persistedCacheEntry(messageId: number, text: string): PersistedCacheEntry {

19+

return {

20+

key: `default:7:${messageId}`,

21+

node: {

22+

sourceMessage: {

23+

chat: { id: 7, type: "group", title: "Ops" },

24+

message_id: messageId,

25+

date: 1736380000 + messageId,

26+

text,

27+

from: { id: messageId, is_bot: false, first_name: `User ${messageId}` },

28+

} as Message,

29+

},

30+

};

31+

}

32+1133

describe("telegram message cache", () => {

1234

it("hydrates reply chains from persisted cached messages", async () => {

1335

const storePath = `/tmp/openclaw-telegram-message-cache-${process.pid}-${Date.now()}.json`;

@@ -253,6 +275,54 @@ describe("telegram message cache", () => {

253275

}

254276

});

255277278+

it("loads mixed legacy array caches and rewrites them as line-delimited entries", async () => {

279+

const storePath = `/tmp/openclaw-telegram-message-cache-legacy-${process.pid}-${Date.now()}.json`;

280+

const persistedPath = resolveTelegramMessageCachePath(storePath);

281+

await rm(persistedPath, { force: true });

282+

try {

283+

const legacyEntries = [

284+

persistedCacheEntry(35033, "ocdbg-5818 one"),

285+

persistedCacheEntry(35034, "ocdbg-5818 two"),

286+

persistedCacheEntry(35035, "ocdbg-5818 three"),

287+

];

288+

const appendedEntries = [

289+

persistedCacheEntry(35036, "ocdbg-5818 four"),

290+

persistedCacheEntry(35037, "ocdbg-5818 five"),

291+

];

292+

await writeFile(

293+

persistedPath,

294+

`${JSON.stringify(legacyEntries)}${appendedEntries.map((entry) => JSON.stringify(entry)).join("\n")}\n`,

295+

);

296+297+

const cache = createTelegramMessageCache({ persistedPath });

298+299+

expect(

300+

cache

301+

.around({

302+

accountId: "default",

303+

chatId: 7,

304+

messageId: "35035",

305+

before: 2,

306+

after: 2,

307+

})

308+

.map((entry) => entry.messageId),

309+

).toEqual(["35033", "35034", "35035", "35036", "35037"]);

310+311+

const canonical = await readFile(persistedPath, "utf-8");

312+

expect(canonical.startsWith("[")).toBe(false);

313+

const lines = canonical.trim().split("\n");

314+

expect(lines).toHaveLength(5);

315+

expect(

316+

lines.map((line) => {

317+

const entry = JSON.parse(line) as PersistedCacheEntry;

318+

return entry.node.sourceMessage.message_id;

319+

}),

320+

).toEqual([35033, 35034, 35035, 35036, 35037]);

321+

} finally {

322+

await rm(persistedPath, { force: true });

323+

}

324+

});

325+256326

it("returns recent chat messages before the current message", () => {

257327

const cache = createTelegramMessageCache();

258328

for (const id of [41, 42, 43, 44]) {