Skip to content

feat(web): restore scroll position when browsing files#1261

Merged
brendan-kellam merged 1 commit into
v5from
brendan/browse-scroll-restoration-SOU-1260
Jun 2, 2026
Merged

feat(web): restore scroll position when browsing files#1261
brendan-kellam merged 1 commit into
v5from
brendan/browse-scroll-restoration-SOU-1260

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

Fixes SOU-1260

Summary

Adds scroll position restoration to the code browser's file preview panel (pureCodePreviewPanel.tsx). Previously, scrolling down a file, navigating away, and returning would reset you to the top.

How it works

  • The editor grows to its content height, so the actual scroll container is the ScrollArea viewport ([data-radix-scroll-area-viewport]), not CodeMirror's internal scroller. The scroll position is captured from there.
  • Position is persisted per file to sessionStorage under a browse-scroll-pos:{repoName}@{revisionName}:{path} key, throttled to one write per animation frame.
  • On mount (once the editor view is ready), the saved position is restored via viewport.scrollTo(...) on the next frame so layout has settled.
  • Restoration is skipped when a highlight_range query param is present, so the existing highlight scroll-into-view behavior takes precedence.
  • A ref guards against re-restoring after the user has scrolled, while still re-running when the file/revision changes.

Notes

  • Uses sessionStorage, so positions persist across in-session back/forward and re-navigation but reset when the tab closes.

🤖 Generated with Claude Code

The code preview panel now persists the scroll position per
file/revision to sessionStorage and restores it on mount. Restoration
is skipped when a highlight_range query param is present so the existing
highlight scroll-into-view takes precedence.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a4152a8-dda2-43d0-a4f7-a58063cc7d73

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/browse-scroll-restoration-SOU-1260

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam merged commit aaa8cfe into v5 Jun 2, 2026
3 checks passed
@brendan-kellam brendan-kellam deleted the brendan/browse-scroll-restoration-SOU-1260 branch June 2, 2026 00:31
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