Fix input lag on long-running sessions: bound live emulator scrollback - #923
Merged
Conversation
drn
added a commit
that referenced
this pull request
Aug 4, 2026
…measured data Two warnings from /review on the live-scrollback-cap fix (#923): - Missing a gotchas/pty-terminal.md entry per this repo's own documentation rule for non-obvious invariants/fixes. Added, including the residual-cost caveat (this mitigates rather than eliminates the O(n) eviction) and the known resize-taller backfill trade-off the reviewer identified. - The 1,000-line cap wasn't grounded in measured data the way the sibling replayScrollbackSize constant is. Benchmarked a synthetic 500-line burst feed at the old 10K cap vs the new 1K cap (~7.9ms vs ~5.0ms on an Apple M5 Max) and folded the real numbers into the code comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…g sessions x/vt's Scrollback.Push evicts the oldest line via slices.Delete(s.lines, 0, 1) once at capacity — an O(cap) shift of the whole backing slice, paid on every line that scrolls off the top of the screen. The live agent-view emulator never overrode x/vt's 10K-line default, so any long-running, high-output session pays that shift on every subsequent scrolled line, synchronously on the tview main goroutine inside SafeEmuWrite — the same goroutine that processes keyboard input. Confirmed against a real 18+ hour, 2MB+ log task. Cap the live emulator's scrollback 10x smaller (1K lines), mirroring the existing pattern for the replay emulator's cap. Deep scroll-back-in-history already goes through the separate 50K-line replay emulator built for scroll mode, so this has no user-visible effect on how far back a user can scroll. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…measured data Two warnings from /review on the live-scrollback-cap fix (#923): - Missing a gotchas/pty-terminal.md entry per this repo's own documentation rule for non-obvious invariants/fixes. Added, including the residual-cost caveat (this mitigates rather than eliminates the O(n) eviction) and the known resize-taller backfill trade-off the reviewer identified. - The 1,000-line cap wasn't grounded in measured data the way the sibling replayScrollbackSize constant is. Benchmarked a synthetic 500-line burst feed at the old 10K cap vs the new 1K cap (~7.9ms vs ~5.0ms on an Apple M5 Max) and folded the real numbers into the code comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
drn
force-pushed
the
argus/noticing-lag-inputting-text
branch
from
August 4, 2026 22:33
41bcad1 to
db6b9d5
Compare
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
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.
x/vt's Scrollback.Push evicts the oldest line via slices.Delete(s.lines, 0, 1) once at capacity — an O(cap) shift of the whole backing slice, paid on every line that scrolls off the top of the screen. The live agent-view emulator never overrode x/vt's 10K-line default, so a long-running, high-output session pays that shift on every subsequent scrolled line, synchronously on the tview main goroutine — the same goroutine that processes keyboard input. Confirmed against a real 18+ hour, 2MB+ log task.
Caps the live emulator's scrollback 10x smaller (1K lines), mirroring the existing pattern for the replay emulator's cap. Deep scroll-back-in-history already goes through the separate 50K-line replay emulator built for scroll mode, so this has no material effect on how far back a user can scroll. Grounded the cap in a measured benchmark and documented the fix + its residual-cost/edge-case trade-offs in gotchas/pty-terminal.md per review feedback.
Co-Authored-By: Claude noreply@anthropic.com