fix(tui): batch streaming part deltas to keep TUI responsive during fast streams#36045
Closed
YayoRazo wants to merge 1 commit into
Closed
fix(tui): batch streaming part deltas to keep TUI responsive during fast streams#36045YayoRazo wants to merge 1 commit into
YayoRazo wants to merge 1 commit into
Conversation
Every message.part.delta event was applied to the Solid store synchronously, so each streamed chunk triggered reactivity and a re-render of the growing text part. Models with high chunk rates saturate the render loop and queued input (scrolling) stalls for seconds. Deltas now accumulate per part field and flush together every 40ms inside a single batch. A message.part.updated snapshot drops any buffered deltas for that part before reconciling, so the final store state is identical to the unbatched behavior. Closes #36043
YayoRazo
force-pushed
the
fix-tui-delta-batching
branch
from
July 9, 2026 07:53
80b4851 to
6986c32
Compare
3 tasks
CreatorGhost
added a commit
to CreatorGhost/TheCode
that referenced
this pull request
Jul 12, 2026
…ast streams Ported from upstream anomalyco#36045.
CreatorGhost
added a commit
to CreatorGhost/TheCode
that referenced
this pull request
Jul 12, 2026
…ast streams Ported from upstream anomalyco#36045.
CreatorGhost
added a commit
to CreatorGhost/TheCode
that referenced
this pull request
Jul 12, 2026
…ast streams (#24) * fix(tui): batch streaming part deltas to keep TUI responsive during fast streams Ported from upstream anomalyco#36045. * fix(tui): don't drop buffered streaming deltas Addresses Opus review of PR #24: a full snapshot dropped this part's buffered deltas; now flush them into the store before the snapshot reconciles. Also flush on stream completion (assistant message completed / session idle) so a stream that ends on a delta isn't truncated, and clear the batching timer on manual flush. Adds regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #36043
Type of change
What does this PR do?
Every
message.part.deltaSSE event was applied to the Solid store synchronously (packages/tui/src/context/sync.tsx), so each streamed chunk triggered reactivity and a re-render of the growing text part. Models with high chunk rates (GLM in my case) saturate the render loop, and queued input — scrolling in particular — stalls for several seconds, even in a brand-new conversation.The fix accumulates deltas per part field in a small buffer and flushes them together every 40ms inside a single
batch(). Why the final state is unchanged: flushing applies the concatenated delta exactly where the per-chunk appends would have landed, and amessage.part.updatedsnapshot drops any buffered deltas for that part before reconciling (the snapshot already contains that text, so applying them afterwards would duplicate it). Removed parts/messages are skipped at flush time, same outcome as the previous per-chunk path.How did you verify your code works?
bun run typecheckpasses inpackages/tui.bun testinpackages/tui: no new failures vs a cleandevcheckout on the same machine (dev fails 5, this branch fails 3 — the remaining ones are pre-existing environment-flaky tests: SIGHUP/title handling and home-path abbreviation on Windows).Screenshots / recordings
Not a visual change — behavior fix (scroll responsiveness while streaming).
Checklist