Repository navigation
fix(tui): render delta-only assistant streams - #83000
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step Review history (8 earlier review cycles)
|
0429b7c to
c6a83a0
Compare
💡 Codex Reviewhttps://github.com/openclaw/openclaw/blob/c6a83a04f6c674f169992d8ff4c1a411f9b4b1c0/src/gateway/live-chat-projector.ts#L29-L31 When an assistant runtime emits only ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ad94fc7 to
fd5934e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd5934e34e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { | ||
| text: typeof record.text === "string" ? record.text : "", | ||
| delta: typeof record.delta === "string" ? record.delta : "", |
There was a problem hiding this comment.
Sanitize delta-only chunks after merging
For delta-only streams, this returns each fragment with text: "", and both new callers run normalizeLiveAssistantEventText on that single fragment before appending it to the live buffer. When the model emits an inline directive or runtime-context delimiter split across deltas (for example [[reply_to_ then current]] hello, or split <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> blocks), the stripping regexes never see the complete marker, so the TUI can render those raw control tokens during live streaming (and embedded local mode can keep them through final projection). Please preserve/merge the raw delta-only buffer first, then apply the existing display sanitizer to the merged text.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f61fd39b8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -43,6 +43,7 @@ Docs: https://docs.openclaw.ai | |||
| - **Control UI terminal tabs:** vertically center the new-session button in the terminal tab strip. | |||
| - **Control UI composer scrollbar:** show the message-field scrollbar only when the draft actually overflows its autosized height. | |||
| - **Control UI terminal cursor:** hide the browser-native contenteditable caret so the integrated terminal shows only its canvas-rendered cursor. | |||
| - **TUI streaming:** render delta-only assistant events in live Gateway and embedded TUI sessions instead of waiting for the final response. Thanks @flashosophy. | |||
There was a problem hiding this comment.
Remove the manual changelog entry
This fix is not release-generation work, but the root AGENTS.md says CHANGELOG.md is release-only and must not be edited for normal PRs or direct fixes; release generation derives entries from merged PRs and direct commits. Leaving this hand-written entry can duplicate or conflict with the generated release notes, so move the release-note context to the PR/squash/direct-commit text and leave the changelog unchanged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31aa4e25b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const mergedRawText = resolveMergedAssistantText({ | ||
| previousText: previousRawText, | ||
| nextText: cleaned.text, | ||
| nextDelta: cleaned.delta, | ||
| nextText: text, | ||
| nextDelta: typeof delta === "string" ? delta : "", | ||
| }); |
There was a problem hiding this comment.
Preserve protected block openers before capping deltas
When a delta-only assistant stream opens an internal runtime-context block and that block grows past MAX_LIVE_CHAT_BUFFER_CHARS before the closing delimiter arrives, this now feeds the unsanitized raw delta into the capped merge buffer. resolveMergedAssistantText keeps only the tail, so the opening delimiter can be discarded before normalizeLiveAssistantBufferedText runs; after that the stripper no longer recognizes the protected block and can broadcast the private tail as chat text. This affects live Gateway streaming here and the same raw-buffer pattern in embedded TUI; keep unmatched protected blocks/cap after sanitizing visible text so large private blocks cannot leak mid-stream.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8161186730
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const normalizedText = normalizeLiveAssistantBufferedText(mergedRawText); | ||
| const projected = projectLiveAssistantBufferedText(normalizedText); |
There was a problem hiding this comment.
Hold incomplete control markers before broadcasting
In a delta-only stream where a frame ends with an unfinished control marker such as [[reply_to_ or the first half of <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>, this normalizes the incomplete buffer to the same text and the later delta path broadcasts it before the sanitizer can ever see the completed tag. The next frame may eventually replace the text, but live Gateway clients can still see raw directive/runtime-context marker fragments; this is fresh evidence after the merge-buffer change because the first unmatched fragment is sent before merge completion. Please keep unmatched directive/runtime-context prefixes pending until they either complete or are known to be normal text.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69f985a06e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| run.buffer = resolveMergedAssistantText({ | ||
| previousText: run.buffer, | ||
| nextText: cleaned.text, | ||
| nextDelta: cleaned.delta, | ||
| nextText: assistantLiveChatInput.text, | ||
| nextDelta: assistantLiveChatInput.delta, | ||
| }); |
There was a problem hiding this comment.
Preserve final payload when raw deltas sanitize away
When local mode receives a delta-only assistant event that is entirely stripped from display (for example a runtime-context block or directive tag) and the command later resolves with the actual answer only in result.payloads, this assignment makes run.buffer truthy even though its normalized visible text is empty. The completion path only copies payloadText(result?.payloads) when !run.buffer, so emitChatFinal() normalizes the raw control-only buffer to empty and emits a final without the answer; before accepting delta-only events, that fallback still displayed the non-streamed final payload. Track visible text separately or fall back when the normalized buffer is empty.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
Closes #82988
What Problem This Solves
Fixes an issue where Gateway-backed and embedded TUI sessions could drop live assistant output when a runtime emitted incremental
deltaframes without also repeating the cumulativetextsnapshot. Users saw no progress until the final response, despite the runtime streaming correctly.Why This Change Was Made
A shared live-chat input normalizer now accepts snapshot-only, delta-only, and combined assistant events before both TUI backends enter the existing sanitization, merge, suppression, and projection pipeline. The branch was rebased and rewritten on current
main; unrelated dependency override and lockfile changes were removed.User Impact
Streaming text appears incrementally in both normal Gateway TUI sessions and
tui --local, including runtimes that emit canonical delta-only events. Commentary suppression, abort handling, buffer caps, and final-message behavior are unchanged.Evidence
node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/server-chat.agent-events.test.ts src/gateway/server-chat.stream-text-merge.test.ts— 109 tests passed.node scripts/run-vitest.mjs run --config test/vitest/vitest.tui.config.ts src/tui/embedded-backend.test.ts— 43 tests passed.tbx_01kwrjhsjn8geh91q5w6rnh5j3: real Gateway + real tmux TUI showed the firstDELTA_frame before the second frame arrived, then renderedDELTA_ONLY_VISIBLEwhile still streaming.tbx_01kwrjhsjn8geh91q5w6rnh5j3:pnpm check:changedpassed, including typechecks, lint, guards, and import-cycle checks..agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output— clean, no accepted/actionable findings.