Repository navigation
Conversation
Review of the scroll-position restoration fix:
|
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #42806
Type of change
What does this PR do?
The web app lost scroll position when navigating between parent and child sessions. Two primary paths were affected:
Both called
navigate(parentHref), which mounted the parent session fresh, andautoScroll.resume()scrolled straight to the bottom. No scroll position was ever saved.How it works:
The
timelineCache(a per-session-key cache that already cached virtualizer measurements and tool open/close state) now also savesscrollOffseton cleanup vialistRoot()?.scrollTop. When the same session is remounted, three guards prevent the scroll-to-bottom:timelineCachein the virtualizer —initialOffsetuses the cached offset instead ofMAX_SAFE_INTEGER.onMountandmaybeAnchorBottomskip theirscrollToEnd()calls when restoring.session.tsxsession-switch effect —on(() => params.id)skipsautoScroll.resume()when the target session has a cached offset.session.tsxscroll-ref callback —setScrollRefcallsautoScroll.pause()when restoring from cache, preventing the auto-scroll resize observer from overriding the restored position. The user can re-engage auto-scroll by manually scrolling to the bottom.useSessionHashScroll.forceScrollToBottom— returns early when the cache has an offset, soapplyHashwith no hash does not force-scroll away from the restored position.How did you verify your code works?
bun typecheckfrompackages/app— passesbun run testfrompackages/app— 721 pass, 1 fail (pre-existingdesktop-native.test.tsUnicode locale test, unchanged)bun typecheckfrompackages/session-ui— passesbun typecheckfrompackages/tui— passesbun typecheckfrompackages/opencode— passesbun turbo typecheck— 30/30 successfulScreenshots / recordings
No screenshot; this is a navigation scroll behavior fix.
Checklist