fix(telegram): split preview per assistant block

This commit is contained in:
Ayaan Zaidi
2026-02-21 17:07:47 +05:30
parent 36a0df423d
commit 7e632b9674
2 changed files with 7 additions and 4 deletions

View File

@@ -445,7 +445,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
);
});
it("does not force new message for legacy block stream mode", async () => {
it("forces new message for next assistant block in legacy block stream mode", async () => {
const draftStream = createDraftStream(999);
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
@@ -464,10 +464,10 @@ describe("dispatchTelegramMessage draft streaming", () => {
await dispatchWithContext({ context: createContext(), streamMode: "block" });
expect(draftStream.forceNewMessage).not.toHaveBeenCalled();
expect(draftStream.forceNewMessage).toHaveBeenCalledTimes(1);
});
it("does not force new message in partial mode when assistant message restarts", async () => {
it("forces new message in partial mode when assistant message restarts", async () => {
const draftStream = createDraftStream(999);
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
@@ -483,7 +483,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
await dispatchWithContext({ context: createContext(), streamMode: "partial" });
expect(draftStream.forceNewMessage).not.toHaveBeenCalled();
expect(draftStream.forceNewMessage).toHaveBeenCalledTimes(1);
});
it("does not force new message on first assistant message start", async () => {

View File

@@ -630,6 +630,9 @@ export const dispatchTelegramMessage = async ({
onAssistantMessageStart: answerLane.stream
? () => {
reasoningStepState.resetForNextStep();
if (answerLane.hasStreamedMessage) {
answerLane.stream?.forceNewMessage();
}
resetDraftLaneState(answerLane);
}
: undefined,