Skip to content

fix: preserve scroll position when new output arrives#150

Open
sauyon wants to merge 1 commit intocoder:mainfrom
sauyon:sauyon/preserve-scroll-position
Open

fix: preserve scroll position when new output arrives#150
sauyon wants to merge 1 commit intocoder:mainfrom
sauyon:sauyon/preserve-scroll-position

Conversation

@sauyon
Copy link
Copy Markdown

@sauyon sauyon commented Apr 5, 2026

Adjust viewportY by the scrollback delta so the viewport stays locked on the same content while output streams below. Clamp to the current scrollback length in case old lines are dropped by the buffer limit.

When the user has scrolled up to review earlier output, keep the
viewport locked on the same content as new lines arrive instead of
snapping back to the bottom.

Save the scrollback length before each write and adjust `viewportY`
by the delta afterward.  Clamp to the current scrollback length in
case old lines are dropped by the buffer limit.

When the user is already at the bottom (`viewportY === 0`), the
adjustment is skipped and the viewport naturally follows new output.

Co-Authored-By: Claude Opus 4.6 (1M context) <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