Repository navigation
fix(web): every right-panel file reopens where the reader stopped - #220
Merged
Merged
Conversation
Most of these cases fail on main because only code, rendered Markdown and PDF.js remember where the reader stopped: - CSV tables, large text, Word pages, notebooks, Mermaid diagrams and attachments, the first sheet of Excel and ODS files, audio, video, Markdown attachments and HTML pages save no place, so they reopen at the top. - A large-text citation is never recorded as shown, so it jumps back on every visit. - Desktop Chrome and Edge open a PDF in the browser's own viewer, which page script cannot read, so its place and its sideways pan are lost. - The store has no attachment key, no offset or media views, no PDF width, no held samples that reads can see before they are written, and no order for this page's own samples. - A PDF page removed by an edit restores to the top of the last page instead of the document's end. - No module decides when an HTML frame restores a page and when it saves, and no viewer container looks for a scroller to restore. The cases also cover input while a large file is still indexing, a citation the reader leaves before indexing ends, a log that changes while it is open, a file opened again while it shows, sheets other than a workbook's first visible one, a workbook whose first stored sheet is hidden, a cell link into a workbook's first sheet, the table and raw views of a large CSV attachment, a page that grows after load without scrolling, a revision that restores while the reader scrolls the page on screen, a revision that loads before the reader first scrolls, playback that moves on before a tab switch or stays paused while another browser tab saves a newer time, a first press on a player before its source loads, a press on an untouched video after its first-frame seek, a media file that changes while open and a press on it while the new source loads, a press on reopened paused playback whose time then reads a few milliseconds off, a table that the viewer mounts again inside itself long after any click, a table the reader scrolls while a cited line waits for the raw view, a CSV attachment table scrolled past its saved row, a Markdown attachment named like a PDF, an Excel first sheet that shows again after no press, and a revision restored twice that keeps one retry chain. Three cases check that the container watches a viewer only while a place or a citation waits, stops at a workspace file's code view, which keeps its own place, looks again only briefly after a press on a control, and never searches PDF.js. Two cases pass on main and guard rules the change keeps: a page without the scroll script stalls the swap once, and a PDF without a reading key keeps the browser's own viewer on its first URL until the file changes. The panel cases share fileReadingTestKit.tsx and the module stand-ins in fileReadingTestMocks.tsx, whose asset URL refresh keeps one function per resource object, as the real hook does. The HTML frame and PDF reading view cases, and the container's look, have their own files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code, Markdown and PDF.js kept the reader's place, but large text, CSV/TSV, HTML, Word, PowerPoint, spreadsheets, notebooks, Mermaid, media and the browser's own PDF viewer opened at the top after a right-panel tab switch or a page close. - The reading store keys attachments as well as paths, keeps the newest sample, orders this page's own samples by capture even when the clock steps back, and lets a mount read a sample that is not yet flushed. - fileReadingPlace.ts saves and restores the viewer container's scrollers: office pages, notebook cells, rendered Markdown, Mermaid, attachment source views, and video and audio time, which it samples again when the reader leaves while it plays, and returns to when a changed file reloads in the same element. A press on a player counts even before its source loads, but a source still loading saves nothing. The time after the restore and the player's own first-frame seek is the baseline, so leaving playback within 10 ms of it saves nothing. It watches the viewer for a scroller only while a saved place or a citation waits for one, for up to 30 s, or for 2 s after a press on a button, which may switch a sheet or a mode, and stops once it places one or meets a workspace file's code view, which keeps its own place. HTML pages and PDF.js keep their own place, so it leaves them alone. Only a workbook's first visible sheet keeps a place, by the sheet position the viewers now mark. An Excel grid that a cell link opens shows the linked cell, not the saved place, and the reader's later scrolls on it still save. A file opened again while it shows, such as from a chat link, keeps the same visit, so its sheet, its playback and its rows stay as they are. An attachment's place follows the viewer its content type picks, as the panel does, not its name. - Large text, CSV/TSV and ODS rows restore through the viewer's own reveal line, which the panel reads as a store; an attachment picks the table or the raw line by the mode it shows. Scrolling the mounted rows cancels it. Each rows viewer that mounts, such as a log that changed, an ODS sheet or an attachment's raw view, and each Excel grid, asks for its place itself, so a sheet that shows late still restores. A large-text citation stays until the raw rows show it, then becomes the file's saved line and counts as shown. - Right-panel PDFs open in PDF.js, a place saved at another width lands on the same spot, and only the restore's own scroll event goes unsaved, so a sideways pan is kept. - fileReadingFrame.ts decides, for each document in an HTML file's frame, when to restore and when to save. A report short of the restore never becomes the place, a page that grows after load is asked again for a second by one retry chain per document, one page's saving never covers the next, a page without the scroll script stalls the swap once, a page the frame navigates to saves and changes nothing, and a revision gets the live place before it is shown when the reader moved while it restored or first scrolled after it loaded. BrowserDocumentFrame posts, saves and reveals what it returns. - A chat attachment builds its asset resource from its own fields, so a panel re-render, such as the one a scroll of its table causes, keeps its signed URL and loaded text, and its viewer stays mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR changes the test suite by +34 test cases (browser +27, unit +7, 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. |
Thread transfer impact
This comment will update automatically after the next completed run. |
This was referenced Nov 19, 2026
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.
Every file the right panel shows now reopens where the reader stopped, after a right-panel tab switch or a page close, also after the file changed.
改了什么行为
Behaviour change: yes, a reader of any file in the right panel (workspace files and chat attachments, web and desktop) comes back to the place they left after a tab switch or a page close, and right-panel PDFs open in T3 Code's PDF viewer instead of the browser's own.
Why
PR #163 kept the place only for code, rendered Markdown and PDF.js. Every other viewer started at the top, and the browser's own PDF viewer, the default on desktop Chrome and Edge, reloads at page 1 and cannot tell the page where the reader is.
How to undo
Revert the two commits. Saved places stay in the browser and expire after 30 days.
Design and checks
fileReading*files:fileReadingPlace.tsfinds and tracks each viewer's scroller, andfileReadingFrame.tsdecides the HTML frame's restore and save. Upstream files get small hooks: a reveal line and a mount event for large text, tables and the first sheet, a width and a page cap for PDF.js, and the frame's message wiring.vp run check:changedpasses. A real browser with its own PDF viewer on showed each covered type, attachments included, back at its place after a tab switch and after a page close.