Repository navigation
Conversation
|
This PR changes the test suite by +8 test cases (browser +3, unit +5, server 0). New browser test files: Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing. |
The saved scroll position was a pixel offset. The old viewer measured the rows it drew; a new one estimates the rows above the offset, and a wrapped line or a review card is taller than its estimate. The same offset then lands further down: on a real 32-file pull request at normal panel width, line 147 came back as line 224. The restore now saves the first line under the sticky header and aims at that line, which the viewer keeps in place while it measures. It falls back to the offset when the file or line is gone.
jbearak
force-pushed
the
fix/code-view-restore-by-line
branch
from
November 25, 2026 17:07
37808a9 to
1285016
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on pingdotgg#38761 in pingdotgg/t3code (
fix/pr-code-tab-keeps-view). This PR lives in the fork so it shows only its own diff. Once pingdotgg#38761 merges it can be opened against upstreammain.Problem
I scrolled a long way into a pull request's Code tab, switched to another right-panel tab, and came back. The diff was open at a different line. On pingdotgg#42582 (32 files) in a 533px panel with wrapping on, line 147 of
PullRequestDetailCrumbs.tsxcame back as line 224.useCodeViewScrollRestoresaved a pixel offset. The viewer measures each row it draws, so while I scrolled down, that offset counted real heights. After a remount the viewer is new. It has drawn nothing above the offset, so it estimates those rows, and a wrapped line or a review card is taller than its estimate. The same offset then lands further down the file. The thread Diff tab uses the same hook and had the same problem.Change
The hook now saves the first line under the sticky file header along with the offset, and the restore aims at that line. Pierre keeps a line target in place while it measures, so the line comes back where it was.
:pending.The pixel path is unchanged. Its unit expectations are the same as before.
Verification
Running app, perf(web): thread switches paint the timeline in their first frame pingdotgg/t3code#42582, 533px panel, wrapping on. I scrolled a viewport at a time, switched to another right-panel tab and back.
PullRequestDetailCrumbs.tsxline 147PullRequestDetailCrumbs.tsxline 110, 7px under the headerPullRequestDetailPanel.tsxline 1838, 11pxusePullRequestDetail.tsline 66, 12pxSwitching between All commits and one commit also brought each back to its own line.
useCodeViewScrollRestore.browser.test.tsis new. It drives Pierre's realCodeViewthrough its scroll subscription andonPostRender, the way the tabs wire it. Four 300-line files with every sixth line wrapping, in a 640px viewer:value198instead ofvalue73) and passes here.useCodeViewScrollRestore.test.tsadds cases for the line target, a jump, a file shown before its patch loads, a missing line or file, and the next file's header.vp run check:changed upstream/mainpasses. So doDiffPanel.browser.test.tsxandPullRequestCodeTab.browser.test.tsx.Cost of saving: asking the viewer for the line took 0.003 to 0.013 ms per call in the browser test fixture.
No screenshots. The change is where the diff sits after a tab switch, and the table above is the evidence.
Limits
Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved
Created with Claude Fable 5.2 in Claude Code, running in T3 Code.