Skip to content

fix(flow-chat): stop repainting finalized streamed text - #3004

Open
xielixing wants to merge 1 commit into
GCWing:mainfrom
xielixing:codex/2778-streamed-text-repaint
Open

xielixing wants to merge 1 commit into
GCWing:mainfrom
xielixing:codex/2778-streamed-text-repaint

Conversation

@xielixing

Copy link
Copy Markdown

Problem

Fixes #2778 — in a long turn the same assistant text was painted several times even though the model emitted it once (reported on the remote-control / multi-device session path).

Root cause

completeActiveTextItems in src/web-ui/src/flow_chat/services/flow-chat-manager/TextChunkModule.ts finalizes the active text items at a model-round boundary. It cleared the item registrations but left each stream key's accumulated entries in the session content buffer. The next chunk for the same stream key then found no reusable item and opened a new text item seeded with the whole accumulated buffer, so the first segment showed up again inside the second item.

Fix

completeActiveTextItems now releases the accumulated buffer entries together with the item registrations it finalizes. The item itself stays the source of truth for its own content, so a genuine late chunk still continues the existing item through the existing reuse path.

Changed files:

  • src/web-ui/src/flow_chat/services/flow-chat-manager/TextChunkModule.ts (+14/-3)
  • src/web-ui/src/flow_chat/services/flow-chat-manager/TextChunkModule.test.ts (+56/-1)

Validation

Check Result
vitest run flow_chat/services/flow-chat-manager/TextChunkModule.test.ts flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts 2 files / 60 tests passed, exit 0
tsc --noEmit (web-ui) exit 0, no output
New regression test on the unpatched module 1 failed | 7 passed — the second text item re-contained the whole first segment
Same test with the fix passes

The regression test replays the round-boundary sequence: paint a segment, finalize active text items, then apply the next chunk of the same stream key.

Notes / residual risk

  • The reported scenario was a two-device remote-control session; that path was not exercised end to end here. What is proven is the deterministic code-level defect and that painting no longer repeats text an earlier item already shows.
  • Re-delivery of already applied chunks remains a separate concern owned by the position-admitted projection contract; this change only removes the duplicated full-segment repaint.

Finalizing active text items dropped the item registration but kept the accumulated text buffer, so the next chunk of the same stream key created a second item seeded with everything already painted (issue 2778). Release the buffer together with the registration; the item remains the source of truth for its own content, so a genuine late chunk still continues it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 流式输出的助手文本被重复渲染多次(模型实际只输出一次)

1 participant