Repository navigation
Conversation
The timeline cache only preserved row measurements across unmounts, so remounting a session (e.g. switching tabs) re-anchored the viewport to the bottom. Capture the first-visible-row anchor plus pixel offset on unmount, keyed per session, and re-apply it on remount until measurements settle. Bottom-follow is detached through the normal scroll handler since programmatic restores are not gestures, and all anchor-bottom paths are suppressed while the restore is in flight. Sessions that were following the bottom keep following it. Repro of the fixed case: scroll up in a long session while it streams, switch to another tab, let the stream finish, then switch back - the viewport now returns to the exact reading position instead of the bottom.
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found a related PR that addresses a similar scroll position restoration issue: Related PR:
The current PR #48125 is specifically fixing the tab-switch scenario, which is a distinct case from the parent/child navigation in #42809, so these are complementary fixes rather than duplicates. |
|
Note on the related PR flagged above: #42809 covers scroll restoration when navigating between parent and child sessions, while this one covers switching between session tabs (the scenario from #45212). The two are complementary - this PR anchors restoration on the per-session timeline cache used when a session's timeline unmounts and remounts on tab switches. |
|
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 #45212
Type of change
What does this PR do?
Switching away from a session tab and back loses the reading position and lands at the bottom of the timeline.
Root cause: the per-session timeline cache only preserves row measurements across unmounts. On remount the viewport re-anchors to the bottom (initial offset plus anchor-bottom effects), and if the session was mid-stream the position is gone entirely - repro of the worst case: scroll up in a long session while it streams, switch to another tab, let the stream finish, switch back. The viewport lands at the bottom instead of the reading position.
Fix: on unmount, capture the first-visible-row anchor plus its pixel offset into the existing per-session timeline cache. On remount, use the saved offset as the virtualizer's initial offset and re-apply the anchor until measurements settle (same convergence pattern as the existing prepend-anchor logic). While the restore is in flight, all anchor-bottom paths (mount scrollToEnd, maybeAnchorBottom, resize-triggered anchor) are suppressed. Because programmatic scrolls don't count as gestures, the restore also routes through the normal scroll handler once, so bottom-follow detaches when landing away from the bottom and re-engages when the restored position is at the bottom. Sessions that were following the bottom keep following it (no restore is attempted), and hash/message navigation still takes precedence.
How did you verify your code works?
Verified interactively in Chromium against
bun dev+ a local server, using wheel gestures over long sessions (~100k px timelines):devit lands at the bottom.dev.Screenshots / recordings
Happy to attach a recording on request; verification steps above are reproducible with any long session.
Checklist