Skip to content

Fix input lag on long-running sessions: bound live emulator scrollback - #923

Merged
drn merged 2 commits into
masterfrom
argus/noticing-lag-inputting-text
Aug 4, 2026
Merged

Fix input lag on long-running sessions: bound live emulator scrollback#923
drn merged 2 commits into
masterfrom
argus/noticing-lag-inputting-text

Conversation

@drn

@drn drn commented Aug 4, 2026

Copy link
Copy Markdown
Owner

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

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>
drn and others added 2 commits August 4, 2026 15:33
…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
drn force-pushed the argus/noticing-lag-inputting-text branch from 41bcad1 to db6b9d5 Compare August 4, 2026 22:33
@drn
drn merged commit fce1a63 into master Aug 4, 2026
1 check passed
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/drn/argus/internal/tui/terminal 96.00% (+0.00%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/drn/argus/internal/tui/terminal/terminalpane.go 96.18% (+0.00%) 812 (+1) 781 (+1) 31 👍

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

  • github.com/drn/argus/internal/tui/terminal/terminalpane_test.go

@drn
drn deleted the argus/noticing-lag-inputting-text branch August 5, 2026 00:19
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.

1 participant