perf(cli): coalesce wheel scrolls and throttle stream flushes - #7745
Open
innocarpe wants to merge 1 commit into
Open
perf(cli): coalesce wheel scrolls and throttle stream flushes#7745innocarpe wants to merge 1 commit into
innocarpe wants to merge 1 commit into
Conversation
This was referenced Aug 6, 2026
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.
Summary
Fix TUI scroll jank in long sessions (user-reported: scrolling stutters badly as transcripts grow; other terminal tools don't). An audit of
internal/cli/chat_tui.gopinned two dominant bottlenecks; both are fixed behavior-preservingly:B1 — wheel events caused a full-screen ClearScreen + full repaint per notch, uncoalesced (fast wheels/trackpad inertia = 30-120+ events/sec → dozens of full repaints/sec, defeating bubbletea's line-diff optimization):
wheelAccum) and are applied once per 16ms tick (wheelScrollTick), oneScrollUp/Downofaccum × 3rows — same scroll semantics, ~10-50× fewer scroll commands/repaintstea.ClearScreenpath are untouchedB2 — every stream flush re-rendered the ENTIRE accumulated answer with goldmark (up to several full re-renders per 512-event drain → O(answer²)):
streamFlushDue+streamFlushTick); the deferred flush is guaranteed by the tick, so final output is byte-identicalcommitPending(message end) unchangedBoth fixes are unit-tested with injected times / synthetic tick messages (no sleeps, no flakiness):
TestApplyWheelDelta,TestWheelScrollCoalescesBurstIntoSingleTick,TestStreamFlushDueThrottlesWithinWindow,TestStreamAnswerThrottlesDeferredFlushes+ 12 existing wheel tests updated to feed the synthetic tick.Issues
None — user-reported performance issue (matches closed tracking issue #1829's transcript-growth slowdown class; the block-cache rewrite covered other paths but these two remained).
Verification
go test ./internal/cli/— full suite passgo vet ./internal/cli/— cleangofmt -l internal/cli/— cleango build ./cmd/reasonix— OKDocumentation impact
Documentation-impact: none - internal rendering performance; no behavior or docs change.
Cache impact
Cache-impact: none - TUI rendering only; no prompt/tool surface or serialization touched.
Cache-guard: N/A
System-prompt-review: N/A