

























@@ -1500,6 +1500,68 @@ describe("processDiscordMessage draft streaming", () => {
15001500expect(draftStream.flush).toHaveBeenCalledTimes(1);
15011501});
150215021503+it("keeps Discord progress drafts instead of delivering text-only interim blocks", async () => {
1504+const draftStream = createMockDraftStreamForTest();
1505+1506+dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
1507+await params?.dispatcher.sendBlockReply({ text: "on it" });
1508+await params?.replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
1509+await params?.dispatcher.sendFinalReply({ text: "done" });
1510+return { queuedFinal: true, counts: { final: 1, tool: 0, block: 1 } };
1511+});
1512+1513+const ctx = await createAutomaticSourceDeliveryContext({
1514+discordConfig: {
1515+streaming: {
1516+mode: "progress",
1517+progress: {
1518+label: "Shelling",
1519+},
1520+},
1521+},
1522+});
1523+1524+await runProcessDiscordMessage(ctx);
1525+1526+expect(draftStream.update).toHaveBeenCalledWith("Shelling");
1527+expect(draftStream.update).toHaveBeenCalledWith("Shelling\n• tool: exec");
1528+expect(deliverDiscordReply).not.toHaveBeenCalled();
1529+expect(editMessageDiscord).toHaveBeenCalledWith(
1530+"c1",
1531+"preview-1",
1532+{ content: "done" },
1533+expect.objectContaining({ rest: expect.anything() }),
1534+);
1535+});
1536+1537+it("keeps Discord progress lines across assistant boundaries", async () => {
1538+const draftStream = createMockDraftStreamForTest();
1539+1540+dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
1541+await params?.replyOptions?.onToolStart?.({ name: "first", phase: "start" });
1542+await params?.replyOptions?.onAssistantMessageStart?.();
1543+await params?.replyOptions?.onToolStart?.({ name: "second", phase: "start" });
1544+return createNoQueuedDispatchResult();
1545+});
1546+1547+const ctx = await createAutomaticSourceDeliveryContext({
1548+discordConfig: {
1549+streaming: {
1550+mode: "progress",
1551+progress: {
1552+label: "Shelling",
1553+},
1554+},
1555+},
1556+});
1557+1558+await runProcessDiscordMessage(ctx);
1559+1560+expect(draftStream.update).toHaveBeenCalledWith("Shelling\n• tool: first");
1561+expect(draftStream.update).toHaveBeenCalledWith("Shelling\n• tool: first\n• tool: second");
1562+expect(draftStream.forceNewMessage).not.toHaveBeenCalled();
1563+});
1564+15031565it("keeps standalone Discord tool progress when partial preview lines are disabled", async () => {
15041566createMockDraftStreamForTest();
15051567此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。