@@ -2689,6 +2689,34 @@ describe("dispatchTelegramMessage draft streaming", () => {
|
2689 | 2689 | ); |
2690 | 2690 | }); |
2691 | 2691 | |
| 2692 | +it("clears progress drafts before visible tool artifacts", async () => { |
| 2693 | +const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 }); |
| 2694 | +dispatchReplyWithBufferedBlockDispatcher.mockImplementation( |
| 2695 | +async ({ dispatcherOptions, replyOptions }) => { |
| 2696 | +await replyOptions?.onToolStart?.({ name: "exec", phase: "start" }); |
| 2697 | +await dispatcherOptions.deliver( |
| 2698 | +{ mediaUrl: "https://example.com/validation.txt" }, |
| 2699 | +{ kind: "tool" }, |
| 2700 | +); |
| 2701 | +await dispatcherOptions.deliver({ text: "Final answer" }, { kind: "final" }); |
| 2702 | +return { queuedFinal: true }; |
| 2703 | +}, |
| 2704 | +); |
| 2705 | + |
| 2706 | +await dispatchWithContext({ |
| 2707 | +context: createContext(), |
| 2708 | +streamMode: "progress", |
| 2709 | +telegramCfg: { streaming: { mode: "progress", progress: { label: "Shelling" } } }, |
| 2710 | +}); |
| 2711 | + |
| 2712 | +expect(answerDraftStream.update).toHaveBeenCalledWith("Shelling\n\n`🛠️ Exec`"); |
| 2713 | +expectDeliveredReply(0, { mediaUrl: "https://example.com/validation.txt" }); |
| 2714 | +expectDeliveredReply(0, { text: "Final answer" }, 1); |
| 2715 | +expect(answerDraftStream.clear.mock.invocationCallOrder[0]).toBeLessThan( |
| 2716 | +deliverReplies.mock.invocationCallOrder[0], |
| 2717 | +); |
| 2718 | +}); |
| 2719 | + |
2692 | 2720 | it("does not stream text-only tool results into progress drafts", async () => { |
2693 | 2721 | const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 }); |
2694 | 2722 | dispatchReplyWithBufferedBlockDispatcher.mockImplementation( |
|