@@ -1327,6 +1327,66 @@ describe("dispatchTelegramMessage draft streaming", () => {
|
1327 | 1327 | expect(draftStream.update).toHaveBeenCalledWith("HelloWorld"); |
1328 | 1328 | }); |
1329 | 1329 | |
| 1330 | +it("sizes block-mode preview chunks from streaming.preview.chunk", async () => { |
| 1331 | +const draftStream = createDraftStream(); |
| 1332 | +createTelegramDraftStream.mockReturnValue(draftStream); |
| 1333 | +dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => { |
| 1334 | +await replyOptions?.onPartialReply?.({ text: "Hello" }); |
| 1335 | +return { queuedFinal: false }; |
| 1336 | +}); |
| 1337 | + |
| 1338 | +await dispatchWithContext({ |
| 1339 | +context: createContext(), |
| 1340 | +streamMode: "block", |
| 1341 | +cfg: { |
| 1342 | +channels: { |
| 1343 | +telegram: { streaming: { preview: { chunk: { minChars: 100, maxChars: 600 } } } }, |
| 1344 | +}, |
| 1345 | +}, |
| 1346 | +telegramCfg: { streaming: { mode: "block" } }, |
| 1347 | +}); |
| 1348 | + |
| 1349 | +expectDraftStreamParams({ maxChars: 600 }); |
| 1350 | +}); |
| 1351 | + |
| 1352 | +it("uses the shared block chunk default when block mode has no chunk config", async () => { |
| 1353 | +const draftStream = createDraftStream(); |
| 1354 | +createTelegramDraftStream.mockReturnValue(draftStream); |
| 1355 | +dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => { |
| 1356 | +await replyOptions?.onPartialReply?.({ text: "Hello" }); |
| 1357 | +return { queuedFinal: false }; |
| 1358 | +}); |
| 1359 | + |
| 1360 | +await dispatchWithContext({ |
| 1361 | +context: createContext(), |
| 1362 | +streamMode: "block", |
| 1363 | +telegramCfg: { streaming: { mode: "block" } }, |
| 1364 | +}); |
| 1365 | + |
| 1366 | +expectDraftStreamParams({ maxChars: 800 }); |
| 1367 | +}); |
| 1368 | + |
| 1369 | +it("keeps the Telegram edit cap for non-block previews regardless of chunk config", async () => { |
| 1370 | +const draftStream = createDraftStream(); |
| 1371 | +createTelegramDraftStream.mockReturnValue(draftStream); |
| 1372 | +dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => { |
| 1373 | +await replyOptions?.onPartialReply?.({ text: "Hello" }); |
| 1374 | +return { queuedFinal: false }; |
| 1375 | +}); |
| 1376 | + |
| 1377 | +await dispatchWithContext({ |
| 1378 | +context: createContext(), |
| 1379 | +cfg: { |
| 1380 | +channels: { |
| 1381 | +telegram: { streaming: { preview: { chunk: { maxChars: 600 } } } }, |
| 1382 | +}, |
| 1383 | +}, |
| 1384 | +telegramCfg: { streaming: { mode: "partial" } }, |
| 1385 | +}); |
| 1386 | + |
| 1387 | +expectDraftStreamParams({ maxChars: 4096 }); |
| 1388 | +}); |
| 1389 | + |
1330 | 1390 | it("streams text-only finals into the answer message", async () => { |
1331 | 1391 | const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 }); |
1332 | 1392 | dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ dispatcherOptions }) => { |
|