Repository navigation
fix(relay): keep a PC details closed when Add a PC opens and closes before a sheet Back lands - #4243
Conversation
… before a sheet's Back lands (#4221) Race 1 of #4221, reproduced in a real browser (Chrome 156, 390 px, CPU 6x, 9 of 20 runs): close a sheet opened from a PC's details, open Add a PC and close it, then close the details, all before the first sheet's Back lands. The dashboard held the list's #pcs and settled the hold on the first popstate, taking the landing for the sheet's when the current entry was the one under the entry that was current when the hold began. Add a PC's entry had moved that, so the sheet's own landing looked like the user's traversal, the held #pcs was dropped and the details opened again. sheetHistory now says which traversal is its own. As it asks for a step (history.back()), and where the browser tells its entries (the Navigation API), it records the key of the entry under the one being left: the entry that step lands on, as Chromium names it when asked. sheetBackOnto() returns that key while the step is on its way, and sheetBackLanded(event) says whether a popstate is that landing. A sheet that opened over the entry the step leaves and closed before it landed takes no second step there, because the one step leaves its entry too and a second would land under the named entry. RelayDashboard's held queue holds only while sheetBackOnto() names an entry, and settles on sheetBackLanded(event) instead of its own reading of the entries. Browsers without the Navigation API keep the previous behaviour: nothing is held, and every sheet takes its own step. The browser regression scripts/sheet-history-late-step-regression.ts gains the race-1 walk (Add a PC opened and closed between the two Escapes) at 390 and 1440. It fails on main at 390 and passes with this change.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
Merged through Reviews of record (lane relay-followups): omo (dori review) CLEAR and Codex gpt-6.2-sol-fast xhigh via team proxy CLEAR, both at 4295a18. Race 1 of #4221 reproduced in real Chromium (CI image 5/24, local 9/20 at 390 CPU 6x), 0/40 after; new regression walk fails on main and passes in the image; file-viewer, inbox-mode-demo, mobile-tabs regressions pass in the image. No new text or screen. Follow-ups, unreproduced: (1) Codex MEDIUM: a Back that only undoes a fragment navigation inside an HTML preview's iframe never lands in the parent, so stepping stays set and a later sheet opened and closed meanwhile skips its own Back (main took it); a landing timeout on the recorded key would bound it. (2) Codex MEDIUM, same on main (#4220): a held dashboard write flushed while Add a PC stays open replaces Add a PC's entry. (3) omo LOW: WebKit not run (Playwright WebKit cannot launch on this host); the change relies on back() landing relative to the entry current when it was asked, which the HTML traversal queue orders before a later pushState. |
Fixes #4221 (race 1, which reproduces in a real browser; races 2 and 3 did not reproduce, and the evidence is on the issue).
What was wrong
In the hosted app's dashboard on a phone, the details of a PC could open again by themselves. The steps:
history.back()lands, open Add a PC and close it.#4220 holds the dashboard's address writes while a closed sheet's Back is on its way, and settles them at the first popstate. It decided whether that popstate was the sheet's own landing by reading the browser's entries when the hold began. Add a PC's own entry had moved those entries, so the sheet's landing looked like the user's own traversal. The held
#pcswas dropped, and the details opened again.It reproduced in Chromium 153 in the CI runner image at 390 px with CPU 6x in 5 of 24 runs, and in local Chrome 156 in 9 of 20. It never reproduced at 1440 px, where no sheet makes a history entry.
What changed
src/lib/sheetHistory.ts:history.back()the sheets take goes through one function. Where the browser exposes its entries (the Navigation API), that function records the key of the entry the step will land on.sheetBackOnto()returns that key while the step is on its way, andsheetBackLanded(event)says whether a popstate is that landing.src/components/RelayDashboard.tsx: the held queue holds only whilesheetBackOnto()names an entry, and settles onsheetBackLanded(event)instead of its own reading of the entries.No new text and no new screen.
Validation
scripts/sheet-history-late-step-regression.tsgains the race-1 walk (Add a PC opened and closed between the two Escapes) at 390 and 1440. In the CI runner image,late-step-add-pc-390-cpu6xfails on main's sources (the address never returns to#pcs) and the walk passes here 4/4.Race-1 driver (local Chrome 156):
Browser regressions that use sheets, in the CI runner image:
file-viewer-regressionPASS,inbox-mode-demo-regressionPASS,mobile-tabs-regressionPASS.Unit tests:
sheetHistory.test.ts,sheetHistory.skips.test.ts,RelayDashboard.test.tsxandAgentSidebar.test.tsx, 124 pass. The newsheetHistorytest fails if either the landing check or the second-step skip is removed.bun run check faston old-desktop: exit 0.Not run: WebKit and Firefox, and the full browser lane (CI runs it).