Skip to content

fix(app): hold the address while a sheet goes back onto its own entry (phone-back flake) - #4387

Merged
devswha merged 4 commits into
mainfrom
fix/phone-back-new-workspace-flake
Nov 20, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/phone-back-new-workspace-flake

Conversation

@devswha

@devswha devswha commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

What

On a phone, the address bar now holds its write while any traversal of the sheets' own is on its way, not only a closed sheet's step off its entry. sheetBackPending() becomes sheetTraversalPending() (src/lib/sheetHistory.ts) and also counts the ways back onto an entry: returning (Back off a sheet over one that stays goes forward again onto the entry it left), climbing, and a refusing sheet's way back (stood). Its only caller is useAddressBar, which releases a held write when the next popstate lands, and now also when sheetHistory says the history is on the entry of what is shown with no landing to tell it (onSheetTraversalOver: a sheet made its entry). A way back counts only while the sheet it is for is up; one that only ended (dropped, rejected, given up, or its sheet closed) releases nothing.

Not fixed here, and present on main: after a Back across panes that a sheet refuses or returns from, a later address write can land on the other pane's entry (#4400). This PR holds those writes while the way back is pending, where main writes at once; it does not widen the case.

Why (the flake on main)

scripts/phone-back-demo-regression.ts:164 failed on main at ed69fd4 (run 44828208755): after Back closed New workspace's folder browser, the next Back left .new-session-modal up for 30 s.

The cause is in the app, not the script:

  1. Back off the agent list or the folder browser (a sheet over New workspace, sharing its entry) lands on the entry under the dialog, and sheetHistory then goes forward again onto the entry Back left (returning).
  2. New workspace reports its fields 400 ms after they change (DRAFT_MS). When that report fell between the two landings, useAddressBar saw no pending step and wrote new=workspace&cwd=... with replaceState into the address of the entry under the dialog.
  3. The test's next Back landed on that entry. The dialog closed on it, and useAddressBar's popstate read create from the address and opened New workspace again.

A history trace of the walk with the app's own traverseTo held 1.5 s shows the write landing on index 0 (replace idx=0 /?...&new=workspace&cwd=...) between the Back and the way forward, and the dialog coming back after the last Back. A user sees the same thing: Back from New workspace opens it again.

Validation

  • Forced race (a scratch copy of the walk with the app's navigation.traverseTo held 1.5 s, not committed): main failed 2 of 2; with the fix 4 of 4 passed.
  • New unit test in src/lib/sheetHistory.skips.test.ts: sheetTraversalPending() is true at the popstate onto the entry under the sheets and false once the way back lands. It fails against main's module ([["entry under it", false], ...]) and passes with the fix.
  • Dropped ways back (gate review): four more sheetHistory tests and one useAddressBar hook test, each failing against the head before it (396e9c1, 6f9b653 or 3bad30b).
  • bun test src/lib/sheetHistory src/lib/useAddressBar: 95 pass, 0 fail (3 runs in a row).
  • scripts/phone-back-demo-regression.ts 20 times in the CI runner image on hosthatch (ovis-in-image, herdr-ci-runner:fe67f3d2ccdc, 4 at a time to load it): PHONEBACK pass=20 fail=0 at 396e9c1, 6f9b653, 3bad30b and 0c04125.
  • bun run check fast (hosthatch, at 0c04125): typecheck, build, unit tests and the rest all ok.
  • Skipped: bun run check full; the other browser scripts run in this PR's CI.

Changelog: changelog.d/new-workspace-back-reopens.md.

…y is on its way

On a phone, Back off a sheet over another that stays (New workspace's agent
list or folder browser) lands on the entry under both, and the sheets then go
forward again onto the entry Back left (src/lib/sheetHistory.ts `returning`).
The address bar held its writes only while a closed sheet's step off its entry
was on its way, not while that way back was. New workspace reports its fields
400 ms after they change, so when that report fell between the two landings it
wrote `new=workspace&...` into the address of the entry under the dialog, and
the next Back, landing there, opened New workspace again. That is the CI flake
at scripts/phone-back-demo-regression.ts:164 (run 44828208755).

sheetBackPending becomes sheetTraversalPending and also counts the sheets' own
ways back onto an entry (returning, climbing, a refusing sheet's way back), so
the write is held until that popstate lands and is made on the right entry.

Reproduced by holding the app's own traverseTo for 1.5 s in a scratch copy of
the walk: 2 of 2 failed on main, 4 of 4 passed with the fix.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • On phones, pressing Back after closing the agent list or folder browser in New workspace no longer reopens New workspace.
    • Prevented New workspace fields from being written into the address of the page underneath during this Back navigation.

On phones, Back from New workspace could reopen it after closing its agent list or folder browser. The change expands the sheet traversal check and holds address-bar writes until the traversal lands.

Changes: Sheet traversal and address writes

Layer / File(s) Summary
Traversal-aware address writes
src/lib/sheetHistory.ts, src/lib/useAddressBar.ts, src/lib/sheetHistory.skips.test.ts, changelog.d/new-workspace-back-reopens.md
sheetTraversalPending() reports pending stepping, returning, climbing, or stood states. useAddressBar holds link writes while a traversal is pending. The test checks the pending state during a traversal to the entry beneath the sheet and verifies that a later Back closes the drawer. The changelog documents the New workspace Back scenario.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#4194: Also holds useAddressBar URL writes until a sheet’s pending Back traversal lands.
  • devswha/ovis#4220: Addresses a related Back-navigation and address-write timing issue at a different fix site.

Suggested labels: bug

Merge Risk: Minimal · up to 396e9

This change holds address-bar writes while sheet traversals are pending, which prevents Back from reopening New workspace on phones. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the address write is now held while a sheet traverses back onto its own entry. It matches the renamed helper and the useAddressBar hold described in the summary. It al…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has the Change section, which explains the problem, the cause, and the fix. It also has the Validation section, which lists the checks run and the c…
Full details: Title check

Explanation

The title names the main change: the address write is now held while a sheet traverses back onto its own entry. It matches the renamed helper and the useAddressBar hold described in the summary. It also states the phone-back flake it fixes. The 88-character length is long but acceptable.

Full details: Description check

Explanation

The description follows the repository template. It has the Change section, which explains the problem, the cause, and the fix. It also has the Validation section, which lists the checks run and the checks skipped. It gives a reproducible failing scenario and a linked CI run. The Change section does not link a maintainer-agreed issue. The PR is a bug fix, so that link is not strictly needed. The author cites a #4400 item as a known issue on main. The validation figures differ slightly from the objectives (95 vs 90 passing tests, and a different commit). The description is complete enough to pass.

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 5c190e7 and 396e9c1.

Files selected for processing: 4

  • changelog.d/new-workspace-back-reopens.md
  • src/lib/sheetHistory.skips.test.ts
  • src/lib/sheetHistory.ts
  • src/lib/useAddressBar.ts

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

… with no landing

Gate review of 396e9c1 (B1 HIGH, B2 MEDIUM, both reproduced with the
suite's fake browser):

- A way back the browser drops with no word (no Navigation API: a step by
  count) left `returning` set, so every later address write was held, even
  after the dialog closed and another pane was selected. The hold now applies
  only while a sheet is up; with every sheet closed nothing is held.
- A way back the browser rejects cleared `returning`, but the held write was
  released only by a popstate, and the dialog's entry made again by the next
  tap is a push. The sheets that lost their way back are now counted as
  pending until that tap makes their entry, and sheetHistory tells the address
  bar (onSheetTraversalOver) when a sheet made its entry, closed or lost its
  way back with nothing left pending; the address bar then writes what it held,
  onto the sheet's entry and not the one under it.

Tests: a dropped (rejected) way back holds until the tap makes the entry and
says so once; a silently dropped one holds nothing once the sheets close
(both fail against 396e9c1's predicate); the address bar writes the held
New workspace fields onto the remade entry once told (fails against
396e9c1's useAddressBar). The trace listener of the first test stops
listening after its assertion (review LOW).
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Gate review (omo-native-gate-reviewer, GPT-6.2 Astra) of 396e9c1: BLOCK with B1 HIGH and B2 MEDIUM. Both reproduced with the suite's fake browser and fixed in 6f9b653:

  • B1 HIGH (a silently dropped way back held every later address write): the hold now applies only while a sheet is up. Test: "holds no address once every sheet is closed, when the way back onto the entry Back left lands nowhere" (fails at 396e9c1).
  • B2 MEDIUM (a rejected way back cleared the hold but never replayed the held write, and the entry remade by a tap is a push): sheets that lost their way back count as pending until a tap makes their entry, and onSheetTraversalOver tells useAddressBar to write what it held then, onto the remade entry and not the one under it. Tests: "keeps the address off the entry under a sheet whose way back the browser dropped until a tap makes its entry, and says so then" (sheetHistory) and "writes New workspace's fields onto the dialog's entry once the sheets' way back is over, never onto the entry under it" (hook), both failing at the previous head.
  • LOW (trace listener kept appending): it stops after its assertion.

At 6f9b653: bun test src/lib/sheetHistory src/lib/useAddressBar 93/0; forced race (traverseTo held 1.5 s) 4/4; scripts/phone-back-demo-regression.ts 20/20 in the CI image on hosthatch; bun run check fast green (old-desktop). The omo review (dori review) was CLEAR at 396e9c1; both reviews rerun on this head.

… or its way back's sheet closed

Delta gate review of 6f9b653 (D1 HIGH, D2 MEDIUM, both reproduced by the
reviewer with the real modules and the suite's fake browser):

- D1: a lost way back for a sheet with no entry that refused Back (`stood`)
  told the address bar to write, while the history was still on the other
  pane's entry, which it then overwrote. A way back that only ended (dropped,
  rejected or given up) now tells nothing; the write stays held until a
  landing, as at 396e9c1.
- D2: a way back dropped with no word kept `returning` set, and a sheet opened
  afresh counted it, so its new entry got no address. A way back now counts
  only while the sheet it is for is up (`returning.owner`, `climbing.owner`,
  stranded sheets still open), which replaces the `open.size === 0` short-cut.

The address bar is told only when the history is on the entry of what is shown
with no landing to say so: a sheet made its entry (`write`), or the sheet a way
back was for closed (the history is on the entry under it, which is what is left
shown). Closed sheets no longer stay in `stranded` (review LOW).

Tests: "tells nothing when the way back for a sheet with no entry that refused
Back is dropped" and the fresh-sheet part of "holds no address once every sheet
is closed" both fail at 6f9b653.
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Delta gate review of 6f9b653: BLOCK with D1 HIGH and D2 MEDIUM, both reproduced by the reviewer with the real modules; fixed in 3bad30b:

  • D1 HIGH (a lost way back for an entryless sheet that refused Back released the held write while the history was still on another pane's entry, overwriting it): a way back that only ended (dropped, rejected, given up) now tells nothing; the write stays held until a landing, as at 396e9c1. Test: "tells nothing when the way back for a sheet with no entry that refused Back is dropped" (fails at 6f9b653).
  • D2 MEDIUM (a silently dropped way back kept returning set and a freshly opened sheet counted it): a way back counts only while the sheet it is for is up (returning.owner, climbing.owner, stranded sheets still open), replacing the open.size === 0 short-cut. The address bar is told only when a sheet made its entry or the sheet a way back was for closed. Test: the fresh-sheet part of "holds no address once every sheet is closed" (fails at 6f9b653).
  • LOW (closed ids left in stranded): only open sheets are added, and a closed one is dropped when its waiting turn comes.

At 3bad30b: bun test src/lib/sheetHistory src/lib/useAddressBar 94/0 (5 runs); forced race 4/4; scripts/phone-back-demo-regression.ts 20/20 in the CI image on hosthatch; bun run check fast green (old-desktop).

…when a way back's sheet closed

Delta gate review of 3bad30b (E1 HIGH): after Back past more than one
entry (A, B, then a drawer and a menu on B; go(-2) lands on A while the
drawer stays up on B), closing the drawer before its way back landed released
the held write onto A's entry. A sheet closing says nothing about which entry
the history is on, so leaveSheet no longer tells the address bar; only a
sheet making its entry does. The held write then waits for the next landing
or the next change that writes the address.

Test: "tells nothing when the sheet a way back past more than one entry was
for closes before it lands" (fails at 3bad30b).
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Delta gate review of 3bad30b: BLOCK with E1 HIGH and E2 HIGH.

  • E1 (after Back past more than one entry, closing the sheet a way back was for released the held write onto the other pane's entry): fixed in 0c04125. A sheet closing no longer tells the address bar; only a sheet making its entry does. Test: "tells nothing when the sheet a way back past more than one entry was for closes before it lands" (fails at 3bad30b).
  • E2 (after an entryless sheet's refused Back whose way back is dropped, the next roster snapshot writes the shown pane onto the other pane's entry): this is main's behaviour. Main never holds that write, and this PR holds it while the way back is pending. The reviewer's report says so too ("not a claim that this commit introduced the underlying ordinary-effect behavior"). The residual E1 path (a write after the hold ends with no landing) is the same class. Both are filed as Phone Back across panes that a sheet refuses or returns from can write the shown pane onto another pane's history entry #4400, with a sketch of the fix (write only onto the entry last written for the shown place). It is out of scope for this flake fix.

At 0c04125: bun test src/lib/sheetHistory src/lib/useAddressBar 95/0 (3 runs); scripts/phone-back-demo-regression.ts 20/20 in the CI image on hosthatch; bun run check fast green (hosthatch).

@devswha
devswha merged commit 28e0207 into main Nov 20, 2026
15 of 16 checks passed
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 0c0412521. 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 finished, with no review that names this head.

Reviews of record at 0c04125: dori review (omo) CLEAR; omo-native-gate-reviewer (GPT-6.2 Astra) CLEAR after three BLOCK rounds (B1/B2 at 396e9c1, D1/D2 at 6f9b653, E1/E2 at 3bad30b; all reproduced; E1 and the earlier ones fixed with failing-first tests; E2 and the residual E1 path confirmed by the reviewer to happen on main 721aa78 and not widened here, filed as #4400). CodeRabbit did not review this head (rationed); merged on these reviews per the owner's standing rule. Evidence: phone-back-demo-regression.ts 20/20 in the CI image on hosthatch at this head; check fast green.

@devswha
devswha deleted the fix/phone-back-new-workspace-flake branch November 20, 2026 23:59
@devswha devswha mentioned this pull request Nov 21, 2026
devswha added a commit that referenced this pull request Nov 21, 2026
Release 0.5.8, on the owner's word (2026-11-21: run the whole release
end to end), option A by the lead's call: ship from main without #4377,
so step 2 stays off by default on every PC (`accountOpensAll()` is on
only when `OVIS_ACCOUNT_OPENS_ALL` is exactly `1`). #4377 (default on)
moves to 0.5.9.

- `package.json` and `herdr-plugin.toml`: 0.5.7 -> 0.5.8.
- `REMOTE_BUNDLE_VERSION` 51 -> 52 (`shared/machines.ts`): `server/` and
`shared/` changed since `remote-v51`. After this merges, `remote-v52` is
tagged on the merge commit and the Remote PC bundles run publishes it
before the Release run. Until the Release run is done, nothing touching
`server/`, `shared/`, `bun.lock` or `patches/` merges.
- `CHANGELOG.md`: `bun scripts/changelog-fold.ts 0.5.8 2026-11-21`
folded the fragments under 0.5.8; fragments merged after the fold
(#4384, #4387) were moved in by hand with their PR links. No `by @login`
credits: every PR in the section is the maintainer's.
- `release-summaries.json`: 0.5.8 in en, ko, ja and zh: 3 new, 5
improved, 2 fixed. Step 2 is not announced for everyone; one line says
`OVIS_ACCOUNT_OPENS_ALL=1` on a PC opens it by signing in once (what
step 2 does, per docs/account.md). Its parts (one-press PC add, It's me,
durable Not me #4341, strict mode) are not named one by one. Left out on
purpose: the built-in browser's results panel and downloads list (render
only with P3a's setting, not on main), Android SSH (ships through the
store).
- `telemetry/deployed.json` unchanged: release guards agree.

## Validation
- `bun run check fast` on the remote heavy host (hosthatch) at the
release commit on main cfbe85c: every step ok, unit 21695 pass, 0
fail.
- `bun test scripts/changelog-fold.test.ts scripts/release-notes.test.ts
server/release-notes.test.ts scripts/release-guards.test.ts`: 60 pass, 0
fail.
- `bun scripts/release-guards.ts --base origin/main`: "Release 0.5.8:
remote bundle, telemetry Worker and release metadata are in order."
- `bun scripts/release-notes.ts 0.5.8` renders the notes.
- Not run: `check full` (the diff is versions, notes and one constant).
devswha added a commit that referenced this pull request Nov 27, 2026
…4906)

Plan step B5. Fixes #4393 and #4400 (their remaining paths), on top of
#4888 which merged meanwhile.

## Problem
On a phone, `useAddressBar` wrote the shown place with `replaceState`
onto whatever history entry the browser was on. A sheet's own traversal
(a Back it refused, a way back the browser dropped, a step that landed
unheard) can leave the history on another pane's entry with this pane
still shown, so a routine render could write pane B's address onto pane
A's entry. #4724 and #4888 guarded one case each (`refusedEntry`). Left
over:
- #4393: after a closed sheet's own Back landed with no event, the
user's next Back was taken for the sheet's step: the address moved to A
while the screen stayed on B.
- #4400 / Settings: a pane that took the place over under Settings, on
an entry a sheet had closed over, was never written to the address.

## Change
- **The address bar owns one entry, by key.** It remembers the key of
its own entry: the one it last wrote, or the one a Back/Forward the app
(or Settings) followed landed on, or the one the page just made (a
sheet's, a Settings page's, a file's). It writes only onto that entry,
or onto an entry whose address already names the pane shown; otherwise
the write is held until the next popstate or new entry. Settings is the
one exception: the entry Settings steps back onto as it closes is taken
at that moment only (and not when Settings was opened over an entry that
was not the address bar's own).
- Keys come from `sheetHistoryEntryKey()` (the Navigation API key, or
the `ovis:place` key `sheetHistory.ts` keeps where Chromium has no
Navigation API). `sheetHistory.ts` gains `onHistoryEntryMade` (with the
key of the entry it was made over), so an entry pushed by anyone (a file
opened over another pane's entry) is owned with its correct address,
also where the browser tells no key.
- A browser that tells no key at all treats every entry as one: a
sheet's own traversal drops ownership, and it comes back with a followed
Back, the app's own move, a new entry the page made, or the sheets'
"traversal over" signal.
- Removed: `refusedEntry`, `wouldOverwriteRefused`. Kept: the
`sheetTraversalPending()` hold and `onSheetTraversalOver` (a sheet's
underlying entry is also "owned", so they still keep a dialog's draft
off the entry under it, #4387), and the unread-popstate hold.
- #4393: `hear` in `sheetHistory.ts` treats a step as the sheet's own
only when it lands on the entry the step named (`stepOnto`); a landing
elsewhere is the user's Back. `stepOnto` comes from the Navigation API
or, without it in Chromium, from the `ovis:place` keys. An address write
held while such a step was on its way is made once the silent landing is
settled.
- No UI, HTTP or WS contract change.

## Tests (failing first)
New cases drive the **real** `useAddressBar` over the **real**
`sheetHistory` in the fake browser of
`src/lib/sheetHistory.skips.test.ts` (the hook's probe moved to
`src/lib/useAddressBar.fixture.ts`, shared with
`useAddressBar.hook.test.ts`):
| Case | On main before this PR | Here |
|---|---|---|
| D1, E1, E2 of the #4387 gate reviews (pane A's entry keeps A through
roster renders, owner close and rejection) | pass (since #4724); kept as
locks, each fails with the write guard turned off | pass |
| A jump from a drawer over B whose place was taken over on a dialog's
entry | pass; fails with ownership reset turned off | pass |
| Settings: the pane that took the place over under Settings is written,
also after a sheet closed over that entry | **fail** (address stays on
pane a) | pass |
| #4393: the user's Back right after a closed sheet's own Back landed
unheard | **fail** (screen stays on b) | pass |
| #4400: pane b's file on its new entry with no Navigation API |
**fail** (file entry keeps pane a) | pass |
| No key at all: the other pane's entry is kept | pass; fails with
no-key handling turned off | pass |
| #4888's two cases | pass (merged) | pass |

`settingsHistory.test.ts` now imports its own copy of the module: it
passed only when it was the first file to load it.

## Verification (head 628d026)
- `bun test src/lib/sheetHistory src/lib/useAddressBar
src/lib/settingsHistory src/lib/historyKeys`: 164 pass, 0 fail.
- `bun run check fast`: exit 0 (typecheck, build, unit 29660 pass / 0
fail).
- `scripts/phone-back-demo-regression.ts` on a demo build of this head:
**20 of 20** passed (4 at a time). `settings-pages-demo-regression.ts`
passes.
- Android emulator (Android 16 AVD, Chrome 133, the system's real Back
key and real taps over the demo): drawer; a move to another pane, a row
menu over the drawer, Back x3 back onto the first pane; a file from
Files closed by Back, then Files. After every step the address's pane
equals the pane shown; all steps passed in 2 of 2 runs (also 2 of 2 at
the first head).
- Follow-up filed for a pre-existing path found in review: #4907.
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.

1 participant