Skip to content

fix #12: fix terminal viewport jump during streaming#96

Open
blueberrycongee wants to merge 1 commit intomainfrom
fix/issue-12-scroll-jump-to-top
Open

fix #12: fix terminal viewport jump during streaming#96
blueberrycongee wants to merge 1 commit intomainfrom
fix/issue-12-scroll-jump-to-top

Conversation

@blueberrycongee
Copy link
Owner

Summary

  • Fix intermittent viewport jump to top when scrolling up during active Claude CLI output
  • Root cause: BufferService.scroll() decrements buffer.ydisp by 1 for each trimmed line during buffer trimming while isUserScrolling is true, causing the viewport to drift toward ydisp=0 (stuck at top)
  • Approach: Monkey-patch BufferService.scroll() to freeze buffer.ydisp via a temporary property descriptor during buffer trimming when isUserScrolling is true. The freeze blocks the trim decrement while letting onScroll events fire with the stable ydisp value, so the Viewport stays at the user's scroll position
  • scrollLines() (user-initiated scrolling) is unaffected — it's a separate code path
  • Prior attempts history: see docs/bugs/scroll-pinning-evolution.md

Test plan

  • During Claude streaming, scroll up — viewport stays at user's position
  • When not scrolling, new output auto-scrolls to bottom as normal
  • No viewport lock-to-bottom side effect
  • Scrolling back to bottom during streaming resumes auto-follow
  • No scroll jank or flickering during rapid output

Monkey-patch BufferService.scroll() to freeze buffer.ydisp during
buffer trimming when isUserScrolling is true. This prevents the
viewport from drifting toward ydisp=0 as xterm decrements ydisp
on each trimmed line. The freeze uses a temporary property descriptor
so the onScroll event fires with the stable ydisp value, keeping the
Viewport in sync.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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