GeezerVison is showing github.com — fix(files): keep the reader's place in read-only code views by orbitingflea · Pull Request #326 · orbitingflea/t3code
Conversation
Behaviour change
Behaviour change: yes, readers of read-only files in the file preview: a read-only file reopens on the line where the reader stopped after a tab switch, a panel remount or Reopen Closed View, and a cited line that landed becomes the file's saved place.
Why
Restore CodeView place memory and keep upstream pingdotgg#43235 after upstream pingdotgg#42442.
What changed
fileReadingPosition.ts adds CodeView geometry, centered citations, reader scrolls, re-placing as downloaded text grows, and unmount or page-hide settle() keeping active restores.
fileReadingPlace.ts adds settle(). fileReadingStore.ts adds optional centered.
FilePreviewPanel.tsx drops useFileLineReveal branches, 64 to 57 fork lines.
fileReadingPosition.browser.test.tsx tests all cases.
Scope
Read-only and full-text previews. No new files, suppressions, or upstream test edits.
Tradeoffs
- Reads private
virtualizer via instanceof CodeView to skip two upstream edits. A rename disables memory and fails tests.
- A prior-release citation in a shorter panel opens once below view until scrolled because it lacks
centered.
Blast Radius
CodeView memory. Editor keeps its own, caps offset, shares useFileLineReveal, saves ignored centered.
Verification
- Fork tests pass, each red on the base branch or an earlier build.
- All 22 file preview browser test files pass, 331 of 331.
- Web typecheck, 1596 React Compiler and store unit tests, lint, and format pass.
- CI checks pass on the final commit.
Geometry, citations, tradeoffs, and tests
- Why and geometry. CodeView mounts only a row window, so line 150 came back at line 72. Stage 1 detached it for upstream fix(web): file links with a line number open read-only files at that line pingdotgg/t3code#43235, losing place on remount, re-jumping on Reopen Closed View, and letting older Markdown or CSV views win.
fileReadingPosition.ts reads viewport top from Pierre's getLinePosition model across drawn and undrawn lines. It restores in the hold loop each frame for a second and on resizes so measured rows and scroll anchoring cannot shift the reader (CodeView's own scroll settled on estimates in wrapped files). CodeView and the editor cap a saved offset to the line's height until measured, then place the rest. Editor places return as before. Drawn-row top padding is added. Chat attachments keep pixel place; Pierre patch is unchanged.
- Citations, settles, and hooks. A settled
scrollToLine marks the citation shown and saves centered in fileReadingStore.ts. Old places still read. The editor saves and ignores it. CodeView centers them per frame at measured height on tab switches, remounts, reloads, rebuilds, and wrapped lines. The next scroll saves a plain place over it, even from another tab. A shown citation with no saved place opens centered unless the panel read or saved its path, with per-path pixel fallback if dropped. Plain places return as saved. Scrolling during or before a citation scroll marks it shown and keeps it. Reopen Closed View restores the reader's place. A new citation jumps. Download growth re-places saved or cited lines unless scrolled. Pointer holds wait for release. A cut-short citation saves its line centered only while text is below file size. It lands after tab switch, Reopen Closed View, theme change, remount, reload, or mid-scroll end. Landing clears prior scroll. Past a whole file's end or a download ending short, it saves the last line like the editor. settle() in fileReadingPlace.ts saves pending scrolls on unmount and page hide for code views only, keeping restores for back-forward cache returns. FilePreviewPanel.tsx passes one hook argument at the three upstream sites. It passes a truncated file's byte size to the reading-position hook. Cancel clears only its request. The guard drops a cut-short reveal once more arrives.
- Tradeoffs and edges. For 30 days, a prior-release citation keeps its mark. Its offset matches an editor upward scroll. Untested: paging past 550k lines in Chromium or 185k in Firefox. As in the editor, shortening a wrapped line can land later, and a 1 px scroll returns 1 px off. An editor place in a very tall wrapped line can land above that line in the base editor and a read-only view.
- Tests. Fork tests cover every case above, each red on base or an earlier build and green here, plus two editor guards. They cover editor typing at the next line after a mid-line read-only place, also in a full-view wrapped line, and piece-by-piece download tests using a fetch stand-in. Upstream's reveal test passes unchanged in 22 preview files, 331 of 331.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR changes the test suite by +45 test cases (browser +45, unit 0, server 0).
Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
⚠️ The latest CI run did not produce a thread transfer result for b6e09f4.
This comment will update automatically after the next completed run.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Read-only files show in Pierre's CodeView, whose file element holds only
the mounted rows. The fork's source tracker measured lines from that
element, so a read-only place came back on the wrong line, and the
2026-11-27 catch-up took the tracker off CodeView.
The tracker now runs on CodeView with a geometry in CodeView's own
coordinates. Capture finds the line at the viewport top in Pierre's line
model (getLinePosition, every line, mounted or not), so a window CodeView
has yet to move does not matter; restore places that line through the
tracker's hold loop, as in the editor, so rows CodeView measures on the
way and its scroll anchoring do not move the reader off it. Both add the
drawn rows' top padding, which the line model leaves out, so a place is
where the reader saw the rows. A place deeper into a line than the view
has measured it, in CodeView or the editor, stops inside the line until
the view measures it. A code view's scroll whose capture frame has not run is read and written when
the view unmounts or the page hides, without stopping a restore in
progress.
A landed citation saves its place marked centered, so it comes back
centered at the line's measured height in a view of any height, also
after a reload, until the reader's own scroll replaces it. A read-only
citation shown by an earlier release shows centered on its line when it
saved no place in a panel that has not placed that tab. Every other
saved place, the editor's included, comes back as saved. A reader who
scrolls before or while a citation scrolls in keeps the place they scrolled to, Reopen Closed View restores the
reader's place, and upstream's centered reveal and rebuild redo stay.
The editor keeps its own caret line and behaviour; after a read-only
place that starts inside its line, an unset caret goes to the next line,
the one the editor itself saves as its place.
A large file's full text arrives in swaps after the first second of a
restore. Each time the code view's text grows, a place the reader has
not scrolled away from is placed again, so a saved line or a citation
past the text shown so far lands once it arrives. A citation that the
reveal stopped at the last line downloaded saves the cited line while
the shown text is less than the file's size (the panel passes it), so it
lands once the text holds it, also after a tab switch, a remount or a
reload, and at once when the download ends during the reveal's scroll.
A citation past the end of a whole file saves the last line, as the
editor does, also once a download ends short of the cited line.
A landed citation clears an earlier reader scroll, so it is not left
short. The editor saves the line it revealed, as before. A piece that
arrives while the reader holds the pointer down, as in a text selection
or a scrollbar drag, leaves the view to the reader until the release,
which places it unless the reader scrolled. Upstream's reveal
guard lets go of a line it stopped at short of the cited line once more
of the file arrives, so on slow frames it does not pull the view back.
useFileLineReveal takes the fork hooks as one argument and no longer
branches per viewer; a cancelled scrollToLine clears only its own
handled request; its guard lets go of a reveal cut short at the end of
a file still downloading once the file grows past the text it clamped
against.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 28, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|