Skip to content

feat(scrollbox): preserve scroll position across resize#835

Open
benkoppe wants to merge 1 commit intoanomalyco:mainfrom
benkoppe:scrollbox-resize
Open

feat(scrollbox): preserve scroll position across resize#835
benkoppe wants to merge 1 commit intoanomalyco:mainfrom
benkoppe:scrollbox-resize

Conversation

@benkoppe
Copy link
Copy Markdown

@benkoppe benkoppe commented Mar 19, 2026

Hi! Thanks for your work with this repo. I use opencode in a workflow that causes it to get resized relatively often, and currently that causes large and unpredictable jumps in the scroll box, which can be jarring and very annoying.

This PR addresses the issue by snapshotting pre-resize state and restoring. The first visible child is used as an anchor, and distanceFromBottom is used as a fallback when anchor IDs aren't available. Here's the behavior before and after:

Before

Screen.Recording.2026-03-19.at.1.12.38.PM.mov

After

Screen.Recording.2026-03-19.at.1.15.57.PM.mov

Regression tests are also included in a new file, scrollbox-resize-preserve.test.ts, which defines a ScrollBoxResizeScenario class ease test creation.

Copy link
Copy Markdown

@Arsh-S Arsh-S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

2 participants