mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:47:41 +00:00
fix (tui): preserve streamed text across tool boundary deltas
This commit is contained in:
@@ -93,7 +93,12 @@ export class TuiStreamAssembler {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateRunState(state: RunStreamState, message: unknown, showThinking: boolean) {
|
private updateRunState(
|
||||||
|
state: RunStreamState,
|
||||||
|
message: unknown,
|
||||||
|
showThinking: boolean,
|
||||||
|
opts?: { protectBoundaryDrops?: boolean },
|
||||||
|
) {
|
||||||
const thinkingText = extractThinkingFromMessage(message);
|
const thinkingText = extractThinkingFromMessage(message);
|
||||||
const contentText = extractContentFromMessage(message);
|
const contentText = extractContentFromMessage(message);
|
||||||
const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
|
const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
|
||||||
@@ -102,8 +107,19 @@ export class TuiStreamAssembler {
|
|||||||
state.thinkingText = thinkingText;
|
state.thinkingText = thinkingText;
|
||||||
}
|
}
|
||||||
if (contentText) {
|
if (contentText) {
|
||||||
state.contentText = contentText;
|
const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
|
||||||
state.contentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
|
const shouldPreserveBoundaryDroppedText =
|
||||||
|
opts?.protectBoundaryDrops === true &&
|
||||||
|
(state.sawNonTextContentBlocks || sawNonTextContentBlocks) &&
|
||||||
|
isDroppedBoundaryTextBlockSubset({
|
||||||
|
streamedTextBlocks: state.contentBlocks,
|
||||||
|
finalTextBlocks: nextContentBlocks,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!shouldPreserveBoundaryDroppedText) {
|
||||||
|
state.contentText = contentText;
|
||||||
|
state.contentBlocks = nextContentBlocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sawNonTextContentBlocks) {
|
if (sawNonTextContentBlocks) {
|
||||||
state.sawNonTextContentBlocks = true;
|
state.sawNonTextContentBlocks = true;
|
||||||
@@ -121,7 +137,7 @@ export class TuiStreamAssembler {
|
|||||||
ingestDelta(runId: string, message: unknown, showThinking: boolean): string | null {
|
ingestDelta(runId: string, message: unknown, showThinking: boolean): string | null {
|
||||||
const state = this.getOrCreateRun(runId);
|
const state = this.getOrCreateRun(runId);
|
||||||
const previousDisplayText = state.displayText;
|
const previousDisplayText = state.displayText;
|
||||||
this.updateRunState(state, message, showThinking);
|
this.updateRunState(state, message, showThinking, { protectBoundaryDrops: true });
|
||||||
|
|
||||||
if (!state.displayText || state.displayText === previousDisplayText) {
|
if (!state.displayText || state.displayText === previousDisplayText) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user