fix(tui): preserve streamed text during tool call transitions

Fixes #27674

The TUI was erasing already-streamed assistant text when tool calls
were triggered. This happened because the finalize() method in
TuiStreamAssembler was not using the protectBoundaryDrops option
when updating run state.

Now finalize() applies the same boundary drop protection as
ingestDelta(), ensuring that streamed text before tool calls is
preserved when the final payload drops earlier content blocks.
This commit is contained in:
AI Assistant
2026-02-26 23:57:31 +08:00
committed by Peter Steinberger
parent 03159f3942
commit d6cbaea434

View File

@@ -151,7 +151,7 @@ export class TuiStreamAssembler {
const streamedDisplayText = state.displayText;
const streamedTextBlocks = [...state.contentBlocks];
const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
this.updateRunState(state, message, showThinking);
this.updateRunState(state, message, showThinking, { protectBoundaryDrops: true });
const finalComposed = state.displayText;
const shouldKeepStreamedText =
streamedSawNonTextContentBlocks &&