@@ -1296,6 +1296,38 @@ describe("dispatchTelegramMessage draft streaming", () => {
|
1296 | 1296 | expect(editMessageTelegram).not.toHaveBeenCalled(); |
1297 | 1297 | }); |
1298 | 1298 | |
| 1299 | +it("uses the transcript final when progress-mode final text is truncated", async () => { |
| 1300 | +setupDraftStreams({ answerMessageId: 2001 }); |
| 1301 | +const fullAnswer = |
| 1302 | +"Ja. Hier nochmal sauber Schritt fuer Schritt. Einen API Key kopiert man aus der Google Cloud Console. Danach pruefst du die Projekt- und API-Einstellungen."; |
| 1303 | +const truncatedFinal = |
| 1304 | +"Ja. Hier nochmal sauber Schritt fuer Schritt. Einen API Key kopiert man..."; |
| 1305 | +const context = createContext(); |
| 1306 | +context.ctxPayload.SessionKey = "agent:default:telegram:direct:123"; |
| 1307 | +loadSessionStore.mockReturnValue({ |
| 1308 | +"agent:default:telegram:direct:123": { sessionId: "s1" }, |
| 1309 | +}); |
| 1310 | +readLatestAssistantTextFromSessionTranscript.mockResolvedValue({ |
| 1311 | +text: fullAnswer, |
| 1312 | +timestamp: Date.now() + 1_000, |
| 1313 | +}); |
| 1314 | +dispatchReplyWithBufferedBlockDispatcher.mockImplementation( |
| 1315 | +async ({ dispatcherOptions, replyOptions }) => { |
| 1316 | +await replyOptions?.onToolStart?.({ name: "exec", phase: "start" }); |
| 1317 | +await dispatcherOptions.deliver({ text: truncatedFinal }, { kind: "final" }); |
| 1318 | +return { queuedFinal: true }; |
| 1319 | +}, |
| 1320 | +); |
| 1321 | + |
| 1322 | +await dispatchWithContext({ |
| 1323 | + context, |
| 1324 | +streamMode: "progress", |
| 1325 | +telegramCfg: { streaming: { mode: "progress" } }, |
| 1326 | +}); |
| 1327 | + |
| 1328 | +expectDeliveredReply(0, { text: fullAnswer }); |
| 1329 | +}); |
| 1330 | + |
1299 | 1331 | it("streams the first long final chunk and sends follow-up chunks", async () => { |
1300 | 1332 | const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 }); |
1301 | 1333 | const longText = "one ".repeat(80); |
|