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

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
小众软件
小众软件
美团技术团队
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
D
Docker
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
B
Blog
雷峰网
雷峰网
The Cloudflare 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
test(telegram): cover long streamed final replay · opencl...
obviyus · 2026-05-28 · via Recent Commits to openclaw:main

@@ -663,6 +663,137 @@ describe("createLaneTextDeliverer", () => {

663663

expect(harness.sendPayload).toHaveBeenNthCalledWith(2, { text: " again" });

664664

});

665665666+

it("does not resend a long final when streaming already delivered it", async () => {

667+

const fullAnswer = "Hello world again";

668+

const answer = createTestDraftStream({ messageId: 999 });

669+

answer.lastDeliveredText.mockReturnValue(fullAnswer);

670+

const harness = createHarness({

671+

answerStream: answer,

672+

draftMaxChars: 5,

673+

splitFinalTextForStream: () => ["Hello", " world", " again"],

674+

});

675+

harness.lanes.answer.hasStreamedMessage = true;

676+677+

const result = await deliverFinalAnswer(harness, fullAnswer);

678+679+

const delivery = expectPreviewFinalized(result);

680+

expect(delivery.content).toBe(fullAnswer);

681+

expect(delivery.promptContextContent).toBe(fullAnswer);

682+

expect(delivery.messageId).toBe(999);

683+

expect(answer.update).not.toHaveBeenCalled();

684+

expect(harness.stopDraftLane).toHaveBeenCalledTimes(1);

685+

expect(harness.clearDraftLane).not.toHaveBeenCalled();

686+

expect(harness.sendPayload).not.toHaveBeenCalled();

687+

expect(harness.markDelivered).toHaveBeenCalledTimes(1);

688+

});

689+690+

it("sends only the missing suffix when a long final extends the streamed prefix", async () => {

691+

const answer = createTestDraftStream({ messageId: 999 });

692+

answer.lastDeliveredText.mockReturnValue("Hello world");

693+

const harness = createHarness({

694+

answerStream: answer,

695+

draftMaxChars: 5,

696+

splitFinalTextForStream: (text) =>

697+

text === " again" ? [" again"] : ["Hello", " world", " again"],

698+

});

699+

harness.lanes.answer.hasStreamedMessage = true;

700+701+

const result = await deliverFinalAnswer(harness, "Hello world again");

702+703+

const delivery = expectPreviewFinalized(result);

704+

expect(delivery.content).toBe("Hello world again");

705+

expect(delivery.promptContextContent).toBe("Hello world");

706+

expect(answer.update).not.toHaveBeenCalled();

707+

expect(harness.clearDraftLane).not.toHaveBeenCalled();

708+

expect(harness.sendPayload).toHaveBeenCalledTimes(1);

709+

expect(harness.sendPayload).toHaveBeenCalledWith({ text: " again" });

710+

expect(harness.markDelivered).toHaveBeenCalledTimes(1);

711+

});

712+713+

it("does not send a suffix already flushed while stopping a long streamed final", async () => {

714+

let deliveredText = "Hello world";

715+

const answer = createTestDraftStream({

716+

messageId: 999,

717+

onStop: () => {

718+

deliveredText = "Hello world again";

719+

},

720+

});

721+

answer.lastDeliveredText.mockImplementation(() => deliveredText);

722+

const harness = createHarness({

723+

answerStream: answer,

724+

draftMaxChars: 5,

725+

splitFinalTextForStream: (text) =>

726+

text === " again" ? [" again"] : ["Hello", " world", " again"],

727+

});

728+

harness.lanes.answer.hasStreamedMessage = true;

729+730+

const result = await deliverFinalAnswer(harness, "Hello world again");

731+732+

const delivery = expectPreviewFinalized(result);

733+

expect(delivery.promptContextContent).toBe("Hello world again");

734+

expect(answer.update).not.toHaveBeenCalled();

735+

expect(harness.sendPayload).not.toHaveBeenCalled();

736+

expect(harness.markDelivered).toHaveBeenCalledTimes(1);

737+

});

738+739+

it("keeps a long final when stop advances the stream past the first chunk", async () => {

740+

let deliveredText = "Hello";

741+

const answer = createTestDraftStream({

742+

messageId: 999,

743+

onStop: () => {

744+

deliveredText = "Hello world again";

745+

},

746+

});

747+

answer.lastDeliveredText.mockImplementation(() => deliveredText);

748+

const harness = createHarness({

749+

answerStream: answer,

750+

draftMaxChars: 5,

751+

splitFinalTextForStream: (text) =>

752+

text === "Hello world again" ? ["Hello", " world", " again"] : ["Hello"],

753+

});

754+

harness.lanes.answer.hasStreamedMessage = true;

755+756+

const result = await deliverFinalAnswer(harness, "Hello world again");

757+758+

const delivery = expectPreviewFinalized(result);

759+

expect(delivery.promptContextContent).toBe("Hello world again");

760+

expect(answer.update).toHaveBeenCalledWith("Hello");

761+

expect(harness.clearDraftLane).not.toHaveBeenCalled();

762+

expect(harness.sendPayload).not.toHaveBeenCalled();

763+

expect(harness.markDelivered).toHaveBeenCalledTimes(1);

764+

});

765+766+

it("keeps inline buttons on the current chunk of an already-streamed long final", async () => {

767+

const buttons = [[{ text: "OK", callback_data: "ok" }]];

768+

const fullAnswer = "Hello world again";

769+

const answer = createTestDraftStream({ messageId: 999 });

770+

answer.lastDeliveredText.mockReturnValue(fullAnswer);

771+

const harness = createHarness({

772+

answerStream: answer,

773+

draftMaxChars: 6,

774+

splitFinalTextForStream: () => ["Hello", " world", " again"],

775+

});

776+

harness.lanes.answer.hasStreamedMessage = true;

777+778+

const result = await harness.deliverLaneText({

779+

laneName: "answer",

780+

text: fullAnswer,

781+

payload: { text: fullAnswer, channelData: { telegram: { buttons } } },

782+

infoKind: "final",

783+

buttons,

784+

});

785+786+

const delivery = expectPreviewFinalized(result);

787+

expect(delivery.buttonsAttached).toBe(true);

788+

expect(harness.editStreamMessage).toHaveBeenCalledWith({

789+

laneName: "answer",

790+

messageId: 999,

791+

text: " again",

792+

buttons,

793+

});

794+

expect(harness.sendPayload).not.toHaveBeenCalled();

795+

});

796+666797

it("retains the streamed message when stop may have landed without a message id", async () => {

667798

const answer = createTestDraftStream();

668799

answer.sendMayHaveLanded.mockReturnValue(true);