






















@@ -1250,7 +1250,12 @@ describe("dispatchTelegramMessage draft streaming", () => {
12501250await dispatchWithContext({
12511251context: createContext(),
12521252streamMode: "partial",
1253-telegramCfg: { streaming: { mode: "partial" } },
1253+telegramCfg: {
1254+streaming: {
1255+mode: "partial",
1256+preview: { nativeToolProgress: true, nativeToolProgressAllowFrom: ["123"] },
1257+},
1258+},
12541259});
1255126012561261expect(createNativeTelegramToolProgressDraft).toHaveBeenCalledWith(
@@ -1267,6 +1272,62 @@ describe("dispatchTelegramMessage draft streaming", () => {
12671272expect(nativeDraft.stop).toHaveBeenCalled();
12681273});
126912741275+it("keeps native DM drafts off by default", async () => {
1276+const nativeDraft = createNativeToolProgressDraft();
1277+createNativeTelegramToolProgressDraft.mockReturnValue(nativeDraft);
1278+const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
1279+dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
1280+async ({ dispatcherOptions, replyOptions }) => {
1281+await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
1282+await dispatcherOptions.deliver({ text: "Done answer." }, { kind: "final" });
1283+return { queuedFinal: true };
1284+},
1285+);
1286+1287+await dispatchWithContext({
1288+context: createContext(),
1289+streamMode: "partial",
1290+telegramCfg: { streaming: { mode: "partial" } },
1291+});
1292+1293+expect(createNativeTelegramToolProgressDraft).not.toHaveBeenCalled();
1294+expect(nativeDraft.update).not.toHaveBeenCalled();
1295+expect(answerDraftStream.update).toHaveBeenNthCalledWith(1, expect.stringContaining("Exec"));
1296+expect(answerDraftStream.update).toHaveBeenLastCalledWith("Done answer.");
1297+});
1298+1299+it("honors the native DM draft allowlist", async () => {
1300+const nativeDraft = createNativeToolProgressDraft();
1301+createNativeTelegramToolProgressDraft.mockReturnValue(nativeDraft);
1302+const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
1303+dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
1304+async ({ dispatcherOptions, replyOptions }) => {
1305+await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
1306+await dispatcherOptions.deliver({ text: "Done answer." }, { kind: "final" });
1307+return { queuedFinal: true };
1308+},
1309+);
1310+1311+await dispatchWithContext({
1312+context: createContext(),
1313+streamMode: "partial",
1314+telegramCfg: {
1315+streaming: {
1316+mode: "partial",
1317+preview: {
1318+nativeToolProgress: true,
1319+nativeToolProgressAllowFrom: ["999"],
1320+},
1321+},
1322+},
1323+});
1324+1325+expect(createNativeTelegramToolProgressDraft).not.toHaveBeenCalled();
1326+expect(nativeDraft.update).not.toHaveBeenCalled();
1327+expect(answerDraftStream.update).toHaveBeenNthCalledWith(1, expect.stringContaining("Exec"));
1328+expect(answerDraftStream.update).toHaveBeenLastCalledWith("Done answer.");
1329+});
1330+12701331it("falls back to edited preview tool progress when native DM draft update fails", async () => {
12711332const nativeDraft = createNativeToolProgressDraft(false);
12721333createNativeTelegramToolProgressDraft.mockReturnValue(nativeDraft);
@@ -1282,7 +1343,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
12821343await dispatchWithContext({
12831344context: createContext(),
12841345streamMode: "partial",
1285-telegramCfg: { streaming: { mode: "partial" } },
1346+telegramCfg: {
1347+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1348+},
12861349});
1287135012881351expect(nativeDraft.update).toHaveBeenCalledWith(expect.stringContaining("Exec"));
@@ -1305,7 +1368,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
13051368await dispatchWithContext({
13061369context: createContext(),
13071370streamMode: "partial",
1308-telegramCfg: { streaming: { mode: "partial" } },
1371+telegramCfg: {
1372+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1373+},
13091374});
1310137513111376expect(nativeDraft.update).not.toHaveBeenCalled();
@@ -1324,7 +1389,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
13241389await dispatchWithContext({
13251390context: createContext(),
13261391streamMode: "partial",
1327-telegramCfg: { streaming: { mode: "partial" } },
1392+telegramCfg: {
1393+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1394+},
13281395});
1329139613301397expect(nativeDraft.update).not.toHaveBeenCalled();
@@ -1350,7 +1417,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
13501417await dispatchWithContext({
13511418context: createContext(),
13521419streamMode: "partial",
1353-telegramCfg: { streaming: { mode: "partial" } },
1420+telegramCfg: {
1421+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1422+},
13541423});
1355142413561425expect(nativeDraft.update).not.toHaveBeenCalled();
@@ -1382,7 +1451,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
13821451threadSpec: { id: undefined, scope: "none" },
13831452}),
13841453streamMode: "partial",
1385-telegramCfg: { streaming: { mode: "partial" } },
1454+telegramCfg: {
1455+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1456+},
13861457});
1387145813881459expect(createNativeTelegramToolProgressDraft).not.toHaveBeenCalled();
@@ -1403,7 +1474,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
14031474await dispatchWithContext({
14041475context: createContext(),
14051476streamMode: "partial",
1406-telegramCfg: { streaming: { mode: "partial" } },
1477+telegramCfg: {
1478+streaming: { mode: "partial", preview: { nativeToolProgress: true } },
1479+},
14071480});
1408148114091482expect(nativeDraft.update).not.toHaveBeenCalledWith(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。