forked from EduCraft/curriculum-project-hub
fix: repair streaming output broken by markdown rendering changes
Two bugs were introduced when sendTextMessage was changed to auto-detect message format (text/post/interactive): 1. Message type mismatch: sendTextMessage could create a text or post message, but patchTextMessage only works on interactive cards. Fix: add sendInteractiveCardMessage for streaming create (always interactive, always patchable). 2. flushTextToSink state corruption: the text management after flush had a flawed appendedDuringFlush heuristic that could lose text or duplicate it. Fix: properly track sent vs unsent text by removing the sent prefix length, keeping only the last chunk for future patches. Also fix finish() to flush pending text regardless of currentMessageId.
This commit is contained in:
@@ -14,6 +14,7 @@ import type { FastifyBaseLogger } from "fastify";
|
||||
import {
|
||||
sendText,
|
||||
sendTextMessage,
|
||||
sendInteractiveCardMessage,
|
||||
patchTextMessage,
|
||||
reactToMessage,
|
||||
addReaction,
|
||||
@@ -264,7 +265,7 @@ export function makeTriggerHandler(deps: TriggerDeps): TriggerHandler {
|
||||
// Stream agent response as text-as-card messages. Lazy-init: don't send
|
||||
// anything until the first text-delta arrives (avoids empty placeholder).
|
||||
const textStream = new PatchableTextStream({
|
||||
create: (text) => sendTextMessage(rt, chatId, text),
|
||||
create: (text) => sendInteractiveCardMessage(rt, chatId, text),
|
||||
patch: (messageId, text) => patchTextMessage(rt, messageId, text),
|
||||
});
|
||||
const deliveredFiles: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user