

























@@ -3213,6 +3213,44 @@ describe("dispatchTelegramMessage draft streaming", () => {
32133213expect(draftStream.clear).not.toHaveBeenCalled();
32143214});
321532153216+// #76529: when a visible non-final message is delivered after the answer
3217+// preview is already on screen, finalizing the preview by edit puts the
3218+// final answer above the intermediate output. Force a fresh send instead.
3219+it("sends a fresh final after a visible block bubble pushes the preview up (#76529)", async () => {
3220+// Preview was already on screen before the block bubble was sent.
3221+const draftStream = createTestDraftStream({
3222+messageId: 999,
3223+visibleSinceMs: Date.now() - 1_000,
3224+});
3225+createTelegramDraftStream.mockReturnValue(draftStream);
3226+editMessageTelegram.mockResolvedValue({ ok: true });
3227+dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
3228+async ({ dispatcherOptions, replyOptions }) => {
3229+await replyOptions?.onPartialReply?.({ text: "Checked maxDBdays..." });
3230+await dispatcherOptions.deliver(
3231+{ text: "Changed maxDBdays from 91 → 14" },
3232+{ kind: "block" },
3233+);
3234+await dispatcherOptions.deliver({ text: "Done" }, { kind: "final" });
3235+return { queuedFinal: true };
3236+},
3237+);
3238+deliverReplies.mockResolvedValue({ delivered: true });
3239+3240+await dispatchWithContext({ context: createContext() });
3241+3242+// Block + fresh final both went through deliverReplies; preview was not
3243+// edited in place and the stale preview was cleared.
3244+expect(deliverReplies).toHaveBeenCalledTimes(2);
3245+expect(editMessageTelegram).not.toHaveBeenCalled();
3246+expect(deliverReplies).toHaveBeenLastCalledWith(
3247+expect.objectContaining({
3248+replies: [expect.objectContaining({ text: "Done" })],
3249+}),
3250+);
3251+expect(draftStream.clear).toHaveBeenCalled();
3252+});
3253+32163254it("cleans up preview even when fallback delivery throws (double failure)", async () => {
32173255const draftStream = createDraftStream();
32183256createTelegramDraftStream.mockReturnValue(draftStream);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。