Skip to content

fix(relay): keep a PC details closed when Add a PC opens and closes before a sheet Back lands - #4243

Merged
devswha merged 1 commit into
mainfrom
fix/sheet-history-own-step
Nov 19, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/sheet-history-own-step

Conversation

@devswha

@devswha devswha commented Nov 19, 2026

Copy link
Copy Markdown
Owner

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:

  1. Close a sheet opened from a PC's details.
  2. Before that sheet's history.back() lands, open Add a PC and close it.
  3. Close the details.

#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 #pcs was 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:
    • Every 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, and sheetBackLanded(event) says whether a popstate is that landing.
    • A sheet that opened over the entry the step leaves, and closed before the step landed, takes no second step there. The one step leaves its entry too, and a second step would land one entry too far.
  • src/components/RelayDashboard.tsx: the 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 main's behaviour: nothing is held, and every sheet takes its own step.

No new text and no new screen.

Validation

  • 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. In the CI runner image, late-step-add-pc-390-cpu6x fails on main's sources (the address never returns to #pcs) and the walk passes here 4/4.

  • Race-1 driver (local Chrome 156):

    Width Before After
    390 px, CPU 6x 9/20 0/40 (12 runs still had the Back pending at the last Escape)
    1440 0/20 0/20
  • Browser regressions that use sheets, in the CI runner image: file-viewer-regression PASS, inbox-mode-demo-regression PASS, mobile-tabs-regression PASS.

  • Unit tests: sheetHistory.test.ts, sheetHistory.skips.test.ts, RelayDashboard.test.tsx and AgentSidebar.test.tsx, 124 pass. The new sheetHistory test fails if either the landing check or the second-step skip is removed.

  • bun run check fast on old-desktop: exit 0.

  • Not run: WebKit and Firefox, and the full browser lane (CI runs it).

… 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.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue on phones where hosted-app PC details could reopen after closing the details sheet and opening and dismissing Add a PC. Pressing Back now restores the details as expected, and closing the details returns to the PC list without reopening them.

The change adds tracking for the entry targeted by a pending sheet Back. RelayDashboard uses the landing signal to settle held address hashes. Tests and regression scenarios cover phone and desktop flows, including opening and dismissing Add a PC.

Changes: Sheet Back address handling

Layer / File(s) Summary
Track pending sheet Back landings
src/lib/sheetHistory.ts, src/lib/sheetHistory.test.ts
sheetHistory records the expected entry for a step Back and identifies the popstate that reaches it. Tests model keyed history entries and held traversals.
Settle held dashboard hashes
src/components/RelayDashboard.tsx, src/components/RelayDashboard.test.tsx
RelayDashboard holds hashes while a sheet Back is pending. It pushes them in order when sheetBackLanded identifies the landing; other traversals discard them.
Exercise nested Add a PC scenarios
scripts/sheet-history-late-step-regression.ts, changelog.d/relay-details-late-sheet-back-add-pc.md
The regression script runs phone and desktop scenarios with and without opening and dismissing Add a PC. The changelog describes the phone scenario.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#4220: Introduced the held-address behavior that this change updates.
  • devswha/ovis#4194: Exposed pending sheet Back state for address-write handling in another surface.

Suggested labels: bug

Merge Risk: Minimal · up to 4295a

This change prevents PC details from reopening on phones after a sheet is closed and Add a PC is opened and dismissed before the sheet's Back lands. No actionable merge-blocking risk was identified in the reviewed changes.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Linked issue #4221 is the only direct target. Its concrete case is race 1: close a sheet, open and close Add a PC, then close the details before the sheet's Back lands. The PR summary describes a mech… Confirm with the issue owner whether #4221 requires races 2 and 3 in this PR or accepts them as follow-up work. Make the changed blobs for src/lib/sheetHistory.ts, src/lib/sheetHistory.test.ts, and src/components/RelayDashboard.tsx av…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: keeping a PC details sheet closed when Add a PC opens and closes before a sheet Back lands. This matches the changeset, which adds sheetBackOnto/sheetBackLanded and ch…
Description check Passed The description follows the template. The Change section describes the problem (race 1 in #4221), the steps to reproduce, the root cause, and the resulting behavior. The Validation section lists the c…
Out of Scope Changes check Passed The summary lists these changes. changelog.d/relay-details-late-sheet-back-add-pc.md adds a changelog entry. scripts/sheet-history-late-step-regression.ts adds the race-1 walk and nested Add a PC …
Full details: Title check

Explanation

The title names the main change: keeping a PC details sheet closed when Add a PC opens and closes before a sheet Back lands. This matches the changeset, which adds sheetBackOnto/sheetBackLanded and changes how held address writes settle. The title is specific and uses a conventional fix(scope) prefix.

Full details: Description check

Explanation

The description follows the template. The Change section describes the problem (race 1 in #4221), the steps to reproduce, the root cause, and the resulting behavior. The Validation section lists the commands and browser checks run, plus those not run (WebKit, Firefox, full browser lane). The template's HTTP/WS contract-test note is not addressed, but the change does not appear to touch HTTP/WS, so this is a minor gap. The changelog reference from the template's header is covered by the changelog.d entry in the raw summary. The description is complete enough to pass.

Full details: Out of Scope Changes check

Explanation

The summary lists these changes. changelog.d/relay-details-late-sheet-back-add-pc.md adds a changelog entry. scripts/sheet-history-late-step-regression.ts adds the race-1 walk and nested Add a PC scenarios. src/components/RelayDashboard.test.tsx and src/lib/sheetHistory.test.ts update and add tests for the new functions. src/lib/sheetHistory.ts adds sheetBackOnto(), sheetBackLanded(event), and stepBack. src/components/RelayDashboard.tsx changes the held-queue logic to use them. Each change supports the race-1 fix or its validation. The summary reports no new text or screen. The changes are tied to the sheet-history mechanism described in #4221. Line-level code review was not possible, so this verdict relies on the summary.

Full details: Linked Issues check

Explanation

Linked issue #4221 is the only direct target. Its concrete case is race 1: close a sheet, open and close Add a PC, then close the details before the sheet's Back lands. The PR summary describes a mechanism for race 1. sheetBackOnto() records the expected landing entry key. sheetBackLanded(event) identifies the landing. RelayDashboard.tsx settles held navigation on that landing. A sheet that closes before its step lands skips a second step. The regression walk, the race-1 driver, and the unit tests support this mechanism. The PR does not address races 2 and 3, and the PR objectives say so. Issue #4221 says a fix covering all three is 'worth doing if any of the three is seen in the field.' Race 1 was seen in the field, so that condition is met. It is unclear whether the issue requires races 2 and 3 in this PR. Code-level verification was not possible: the diffs for src/lib/sheetHistory.ts and src/components/RelayDashboard.tsx could not be read because their blobs are missing from the checkout. The race-1 conclusion relies on the supplied summary and PR description.

Resolution

Confirm with the issue owner whether #4221 requires races 2 and 3 in this PR or accepts them as follow-up work. Make the changed blobs for src/lib/sheetHistory.ts, src/lib/sheetHistory.test.ts, and src/components/RelayDashboard.tsx available for review. Then confirm that the hold settles on the identified landing and that the second-step skip is present.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6721ca5 and 4295a18.

Files selected for processing: 6

  • changelog.d/relay-details-late-sheet-back-add-pc.md
  • scripts/sheet-history-late-step-regression.ts
  • src/components/RelayDashboard.test.tsx
  • src/components/RelayDashboard.tsx
  • src/lib/sheetHistory.test.ts
  • src/lib/sheetHistory.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@devswha
devswha merged commit aa7a2d6 into main Nov 19, 2026
15 checks passed
@devswha

devswha commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 4295a18dd. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

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.

@devswha
devswha deleted the fix/sheet-history-own-step branch November 19, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sheet history: three simulated races the dashboard's held address does not cover

1 participant