Skip to content

Commit ea471ba

Browse files
committed
Show Telegram progress placeholder for suppressed drafts
1 parent ccc1415 commit ea471ba

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

extensions/telegram/src/bot-message-dispatch.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,30 @@ describe("dispatchTelegramMessage draft streaming", () => {
26002600
expect(editMessageTelegram).not.toHaveBeenCalled();
26012601
});
26022602

2603+
it("shows a progress placeholder when progress mode suppresses answer partial text", async () => {
2604+
const draftStream = createSequencedDraftStream(2001);
2605+
createTelegramDraftStream.mockReturnValue(draftStream);
2606+
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {
2607+
await replyOptions?.onPartialReply?.({ text: "Short draft" });
2608+
return { queuedFinal: false };
2609+
});
2610+
2611+
await dispatchWithContext({
2612+
context: createContext(),
2613+
streamMode: "progress",
2614+
telegramCfg: {
2615+
streaming: {
2616+
mode: "progress",
2617+
progress: { label: "Working", toolProgress: false },
2618+
},
2619+
},
2620+
});
2621+
2622+
expect(draftStream.updatePreview).toHaveBeenCalledWith(telegramHtmlPreview("<b>Working</b>"));
2623+
expect(draftStream.update).not.toHaveBeenCalledWith("Short draft");
2624+
expect(draftStream.flush).toHaveBeenCalled();
2625+
});
2626+
26032627
it("replaces Telegram command progress items with matching command output", async () => {
26042628
const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
26052629
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {

extensions/telegram/src/bot-message-dispatch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ export const dispatchTelegramMessage = async ({
13641364
recomputeQueuedAnswerBlockRotations();
13651365
}
13661366
};
1367-
const updateDraftFromPartial = (lane: DraftLaneState, update: DraftPartialTextUpdate) => {
1367+
const updateDraftFromPartial = async (lane: DraftLaneState, update: DraftPartialTextUpdate) => {
13681368
const laneStream = lane.stream;
13691369
if (!laneStream || !update.text) {
13701370
return;
@@ -1376,6 +1376,7 @@ export const dispatchTelegramMessage = async ({
13761376
}
13771377
if (lane === answerLane) {
13781378
if (streamMode === "progress") {
1379+
await progressDraft.start();
13791380
return;
13801381
}
13811382
resetAnswerToolProgressDraft();
@@ -1402,7 +1403,7 @@ export const dispatchTelegramMessage = async ({
14021403
reasoningStepState.noteReasoningHint();
14031404
reasoningStepState.noteReasoningDelivered();
14041405
}
1405-
updateDraftFromPartial(lanes[segment.lane], segment.update);
1406+
await updateDraftFromPartial(lanes[segment.lane], segment.update);
14061407
}
14071408
};
14081409
const flushDraftLane = async (lane: DraftLaneState) => {

0 commit comments

Comments
 (0)