



























@@ -747,31 +747,6 @@ describe("dispatchTelegramMessage draft streaming", () => {
747747);
748748});
749749750-it("does not materialize native draft tool progress before final-only text", async () => {
751-const draftStream = createTestDraftStream({ previewMode: "draft" });
752-draftStream.materialize.mockResolvedValue(321);
753-createTelegramDraftStream.mockReturnValue(draftStream);
754-dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
755-async ({ dispatcherOptions, replyOptions }) => {
756-await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
757-await dispatcherOptions.deliver({ text: "Done" }, { kind: "final" });
758-return { queuedFinal: true };
759-},
760-);
761-762-await dispatchWithContext({ context: createContext(), streamMode: "partial" });
763-764-expect(draftStream.update).toHaveBeenCalledWith("Working…\n• `tool: exec`");
765-expect(draftStream.update).not.toHaveBeenCalledWith("Done");
766-expect(draftStream.materialize).not.toHaveBeenCalled();
767-expect(deliverReplies).toHaveBeenCalledWith(
768-expect.objectContaining({
769-replies: [expect.objectContaining({ text: "Done" })],
770-}),
771-);
772-expect(draftStream.clear).toHaveBeenCalledTimes(1);
773-});
774-775750it("suppresses Telegram tool progress when explicitly disabled", async () => {
776751const draftStream = createDraftStream();
777752createTelegramDraftStream.mockReturnValue(draftStream);
@@ -2463,13 +2438,11 @@ describe("dispatchTelegramMessage draft streaming", () => {
24632438expect(createTelegramDraftStream.mock.calls[0]?.[0]).toEqual(
24642439expect.objectContaining({
24652440thread: { id: 777, scope: "dm" },
2466-previewTransport: "message",
24672441}),
24682442);
24692443expect(createTelegramDraftStream.mock.calls[1]?.[0]).toEqual(
24702444expect.objectContaining({
24712445thread: { id: 777, scope: "dm" },
2472-previewTransport: "message",
24732446}),
24742447);
24752448});
@@ -2494,7 +2467,6 @@ describe("dispatchTelegramMessage draft streaming", () => {
24942467expect(createTelegramDraftStream.mock.calls[0]?.[0]).toEqual(
24952468expect.objectContaining({
24962469thread: { id: 777, scope: "dm" },
2497-previewTransport: "message",
24982470}),
24992471);
25002472expect(answerDraftStream.materialize).not.toHaveBeenCalled();
@@ -2638,14 +2610,13 @@ describe("dispatchTelegramMessage draft streaming", () => {
26382610);
26392611});
264026122641-it("keeps DM draft reasoning block updates in preview flow without sending duplicates", async () => {
2613+it("keeps DM reasoning block updates in preview flow without sending duplicates", async () => {
26422614const answerDraftStream = createDraftStream(999);
26432615let previewRevision = 0;
26442616const reasoningDraftStream = {
26452617update: vi.fn(),
26462618flush: vi.fn().mockResolvedValue(true),
2647-messageId: vi.fn().mockReturnValue(undefined),
2648-previewMode: vi.fn().mockReturnValue("draft"),
2619+messageId: vi.fn().mockReturnValue(111),
26492620previewRevision: vi.fn().mockImplementation(() => previewRevision),
26502621clear: vi.fn().mockResolvedValue(undefined),
26512622stop: vi.fn().mockResolvedValue(undefined),
@@ -2680,25 +2651,30 @@ describe("dispatchTelegramMessage draft streaming", () => {
26802651await dispatchWithContext({ context: createReasoningStreamContext(), streamMode: "partial" });
2681265226822653expect(editMessageTelegram).toHaveBeenCalledWith(123, 999, "3", expect.any(Object));
2683-expect(reasoningDraftStream.update).toHaveBeenCalledWith(
2654+expect(editMessageTelegram).toHaveBeenCalledWith(
2655+123,
2656+111,
26842657"Reasoning:\nI am counting letters. The total is 3.",
2658+expect.any(Object),
2659+);
2660+expect(reasoningDraftStream.update).toHaveBeenCalledWith(
2661+"Reasoning:\nI am counting letters...",
26852662);
2686-expect(reasoningDraftStream.flush).toHaveBeenCalled();
2663+expect(reasoningDraftStream.flush).not.toHaveBeenCalled();
26872664expect(deliverReplies).not.toHaveBeenCalledWith(
26882665expect.objectContaining({
26892666replies: [expect.objectContaining({ text: expect.stringContaining("Reasoning:\nI am") })],
26902667}),
26912668);
26922669});
269326702694-it("falls back to normal send when DM draft reasoning flush emits no preview update", async () => {
2671+it("falls back to normal send when DM reasoning preview has no message id", async () => {
26952672const answerDraftStream = createDraftStream(999);
26962673const previewRevision = 0;
26972674const reasoningDraftStream = {
26982675update: vi.fn(),
26992676flush: vi.fn().mockResolvedValue(false),
27002677messageId: vi.fn().mockReturnValue(undefined),
2701-previewMode: vi.fn().mockReturnValue("draft"),
27022678previewRevision: vi.fn().mockReturnValue(previewRevision),
27032679clear: vi.fn().mockResolvedValue(undefined),
27042680stop: vi.fn().mockResolvedValue(undefined),
@@ -2722,7 +2698,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
2722269827232699await dispatchWithContext({ context: createReasoningStreamContext(), streamMode: "partial" });
272427002725-expect(reasoningDraftStream.flush).toHaveBeenCalled();
2701+expect(reasoningDraftStream.flush).not.toHaveBeenCalled();
27262702expect(deliverReplies).toHaveBeenCalledWith(
27272703expect.objectContaining({
27282704replies: [expect.objectContaining({ text: "Reasoning:\n_step one expanded_" })],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。