Repository navigation
fix(history): closing a file or a diff after a reload under a phone sheet goes back to the pane - #3115
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
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. |
…e entry under it may be another pane's by now
|
Review round (omo CLEAR at 6d73cab; Codex gpt-6.1-terra xhigh, two MEDIUMs from code tracing):
After the fix: |
|
Targeted Codex check of 581c019 (fix round), two P2s, both left as on main:
Neither is introduced by this PR relative to origin/main, so neither gets a follow-up issue (LOW, not reproduced in a browser). |
|
Local merge gate (owner-approved): |
Fixes #3101
What
On a phone, a sheet (the command palette, the ⋯ menu) is a history entry that copies the entry it opened over. On reload
lib/sheetHistory.tsturned that entry into an ordinary one by dropping only the sheet's own mark. Over a plain file, the copy keptovis:file-preview, so it read as a second entry of the file above the real one: closing the file (X) went back one entry, landed on the real file entry, and the viewer came back. A repository diff had the same problem.#3095 already counts such a copy for the web panel: a copy of a page's entry is one more of the page's (
ovis:web-panel-below), and Close page goes back past it. This PR applies the same rule to a file's and a diff's own entry:overCopiedWebPanelbecomesoverCopiedEntry(lib/historyKeys.ts). A copy of an entry that holdsovis:file-previeworovis:repo-diffnow also gets the count, so the copy holds one more entry under it. A file's or a diff's copy counts only where the entry under it is still the one it copied: a reload, and an address an item changed on the sheet's entry. Forward onto a retired sheet entry keeps main's rule, which counts only the web panel's copies. After Back, another pane may have taken over the entry under it (review round).closeFilealready goes back1 + below.closeDiffnow does the same throughbackUnderCurrentEntry, in place of a singlehistory.back(). If the browser refuses the traversal, the closing latch is released, ascloseFilealready does.ovis:file-previewandovis:repo-diffnow live inhistoryKeys.tswith the other shared history keys, sosheetHistorycan recognise them without importing the viewers.Back still steps through the entries one at a time, as before (#3095).
Pushes already drop the count where needed:
openFilepushes throughwithoutWebPanel,openDiffdrops it, and a web page pushed from the palette sets it to 0. So a fresh entry pushed over a copy never inherits the count. A file or diff that replaces the copy's entry keeps the count, so it still closes past both entries.Design
This follows the rule #3058/#3095 set, which a browser tab also follows: closing drops everything the overlay holds, while Back walks through it. Nothing changes on screen, and there is no new setting.
Validation
scripts/files-documents-demo-regression.ts, phone branch, new step (Documents → a file as the popup viewer, palette over it, reload, Close file):closing the file after a reload under the palette goes back to the pane's entry (0), not 1. It passes with the fix at 390 light and dark, and the 1280 steps pass too.src/lib/sheetHistory.test.ts, new test: a sheet's copy of a plain file's or a diff's entry that is kept over it counts one more under it, and a copy that Forward lands on after Back does not. Reverting either side of the change turns it red.src/lib/useFilePanels.hook.test.ts, new test: a diff over a copy of its entry closes back to the pane. Without the change it traverses onto the diff's own entry. It passes with the change.sheetHistory,useFilePanels*,repoDiff,useFileViewer,webPanelandsettingsHistorytests pass (54 + 38). RunningsettingsHistory.test.tsin the same process assheetHistory.test.tsfails 6 settings tests on origin/main as well, because the files interfere with each other. Each file passes on its own.bun run typecheck: pass.herdr-ci-runner:local, uid 1001): files-documents, files-panel, palette-local-page, web-panel-mobile, file-viewer-mobile, diff-find and diff-line-notes regressions pass, and so doesrepo-diff-browser-qa.ts(Back/Close/focus of the diff).phone-worktree-sheet-regression.tstimes out waiting for a response on origin/main in the image too, because it needs an owned herdr pane. It is not affected by this change.bun run check fast: pass (12585 unit tests, 0 fail; typecheck, build, generated files).bun run check fastpasses again, and so do the files-documents and palette-local-page regressions.bun run check full(CI runs the integration and browser lanes).