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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - Franky
IT之家
IT之家
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
腾讯CDC
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
博客园_首页
G
Google Developers Blog

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
fix(discord): recover truncated progress finals · opencla...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

@@ -166,12 +166,31 @@ const recordInboundSession = vi.hoisted(() =>

166166

vi.fn<(params?: unknown) => Promise<void>>(async () => {}),

167167

);

168168

const configSessionsMocks = vi.hoisted(() => ({

169+

loadSessionStore: vi.fn<(storePath: string, opts?: unknown) => Record<string, unknown>>(

170+

() => ({}),

171+

),

169172

readSessionUpdatedAt: vi.fn<(params?: unknown) => number | undefined>(() => undefined),

173+

readLatestAssistantTextFromSessionTranscript: vi.fn<

174+

(sessionFile: string) => Promise<{ text: string; timestamp?: number } | undefined>

175+

>(async () => undefined),

176+

resolveAndPersistSessionFile: vi.fn<(params?: unknown) => Promise<{ sessionFile: string }>>(

177+

async () => ({ sessionFile: "/tmp/openclaw-discord-process-test-session.jsonl" }),

178+

),

179+

resolveSessionStoreEntry: vi.fn<

180+

(params: { store: Record<string, unknown>; sessionKey?: string }) => { existing?: unknown }

181+

>((params) => ({

182+

existing: params.sessionKey ? params.store[params.sessionKey] : undefined,

183+

})),

170184

resolveStorePath: vi.fn<(path?: unknown, opts?: unknown) => string>(

171185

() => "/tmp/openclaw-discord-process-test-sessions.json",

172186

),

173187

}));

188+

const loadSessionStore = configSessionsMocks.loadSessionStore;

174189

const readSessionUpdatedAt = configSessionsMocks.readSessionUpdatedAt;

190+

const readLatestAssistantTextFromSessionTranscript =

191+

configSessionsMocks.readLatestAssistantTextFromSessionTranscript;

192+

const resolveAndPersistSessionFile = configSessionsMocks.resolveAndPersistSessionFile;

193+

const resolveSessionStoreEntry = configSessionsMocks.resolveSessionStoreEntry;

175194

const resolveStorePath = configSessionsMocks.resolveStorePath;

176195

const createDiscordRestClientSpy = vi.hoisted(() =>

177196

vi.fn<

@@ -266,8 +285,17 @@ vi.mock("openclaw/plugin-sdk/conversation-runtime", () => ({

266285

}));

267286268287

vi.mock("openclaw/plugin-sdk/session-store-runtime", () => ({

269-

readSessionUpdatedAt: (...args: unknown[]) => configSessionsMocks.readSessionUpdatedAt(...args),

270-

resolveStorePath: (...args: unknown[]) => configSessionsMocks.resolveStorePath(...args),

288+

loadSessionStore: (storePath: string, opts?: unknown) =>

289+

configSessionsMocks.loadSessionStore(storePath, opts),

290+

readSessionUpdatedAt: (params?: unknown) => configSessionsMocks.readSessionUpdatedAt(params),

291+

readLatestAssistantTextFromSessionTranscript: (sessionFile: string) =>

292+

configSessionsMocks.readLatestAssistantTextFromSessionTranscript(sessionFile),

293+

resolveAndPersistSessionFile: (params?: unknown) =>

294+

configSessionsMocks.resolveAndPersistSessionFile(params),

295+

resolveSessionStoreEntry: (params: { store: Record<string, unknown>; sessionKey?: string }) =>

296+

configSessionsMocks.resolveSessionStoreEntry(params),

297+

resolveStorePath: (path?: unknown, opts?: unknown) =>

298+

configSessionsMocks.resolveStorePath(path, opts),

271299

}));

272300273301

vi.mock("../client.js", () => ({

@@ -358,12 +386,24 @@ beforeEach(() => {

358386

createDiscordDraftStream.mockClear();

359387

dispatchInboundMessage.mockClear();

360388

recordInboundSession.mockClear();

389+

loadSessionStore.mockClear();

361390

readSessionUpdatedAt.mockClear();

391+

readLatestAssistantTextFromSessionTranscript.mockClear();

392+

resolveAndPersistSessionFile.mockClear();

393+

resolveSessionStoreEntry.mockClear();

362394

resolveStorePath.mockClear();

363395

createDiscordRestClientSpy.mockClear();

364396

dispatchInboundMessage.mockResolvedValue(createNoQueuedDispatchResult());

365397

recordInboundSession.mockResolvedValue(undefined);

398+

loadSessionStore.mockReturnValue({});

366399

readSessionUpdatedAt.mockReturnValue(undefined);

400+

readLatestAssistantTextFromSessionTranscript.mockResolvedValue(undefined);

401+

resolveAndPersistSessionFile.mockResolvedValue({

402+

sessionFile: "/tmp/openclaw-discord-process-test-session.jsonl",

403+

});

404+

resolveSessionStoreEntry.mockImplementation((params) => ({

405+

existing: params.sessionKey ? params.store[params.sessionKey] : undefined,

406+

}));

367407

resolveStorePath.mockReturnValue("/tmp/openclaw-discord-process-test-sessions.json");

368408

threadBindingTesting.resetThreadBindingsForTests();

369409

});

@@ -1739,6 +1779,47 @@ describe("processDiscordMessage draft streaming", () => {

17391779

expect(deliverDiscordReply).toHaveBeenCalledTimes(1);

17401780

});

174117811782+

it("uses transcript-backed final text when progress final text is truncated", async () => {

1783+

const draftStream = createMockDraftStreamForTest();

1784+

const prefix =

1785+

"Here is the complete Discord answer with enough stable prefix text before truncation";

1786+

const truncatedFinal = `${prefix}...`;

1787+

const fullAnswer = `${prefix} ${Array.from(

1788+

{ length: 260 },

1789+

(_value, index) => `continuation${index}`,

1790+

).join(" ")}`;

1791+1792+

loadSessionStore.mockReturnValue({

1793+

"agent:main:discord:channel:c1": { sessionId: "session-1" },

1794+

});

1795+

readLatestAssistantTextFromSessionTranscript.mockResolvedValue({

1796+

text: fullAnswer,

1797+

timestamp: Date.now() + 60_000,

1798+

});

1799+

dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {

1800+

await params?.replyOptions?.onToolStart?.({ name: "exec", phase: "start" });

1801+

await params?.replyOptions?.onItemEvent?.({ progressText: "exec done" });

1802+

await params?.dispatcher.sendFinalReply({ text: truncatedFinal });

1803+

return { queuedFinal: true, counts: { final: 1, tool: 0, block: 0 } };

1804+

});

1805+1806+

const ctx = await createAutomaticSourceDeliveryContext({

1807+

baseSessionKey: BASE_CHANNEL_ROUTE.sessionKey,

1808+

discordConfig: { maxLinesPerMessage: 120 },

1809+

route: BASE_CHANNEL_ROUTE,

1810+

});

1811+1812+

await runProcessDiscordMessage(ctx);

1813+1814+

expect(draftStream.update).toHaveBeenCalledTimes(1);

1815+

expect(editMessageDiscord).not.toHaveBeenCalled();

1816+

expect(deliverDiscordReply).toHaveBeenCalledTimes(1);

1817+

const params = firstMockArg(deliverDiscordReply, "deliverDiscordReply");

1818+

const replies = requireRecord(params, "deliverDiscordReply params").replies;

1819+

expect(Array.isArray(replies)).toBe(true);

1820+

expect((replies as Array<{ text?: string }>)[0]?.text).toBe(fullAnswer);

1821+

});

1822+17421823

it("clears partial drafts when fallback final delivery fails before completion", async () => {

17431824

const draftStream = createMockDraftStreamForTest();

17441825

deliverDiscordReply.mockRejectedValueOnce(new Error("send failed"));