Repository navigation
feat(mobile): hand the page's dead Back button to the shell (OTA phase C, C2.2) - #21582
Conversation
…TA phase C, C2.2)
A page served at `/` holds the one history entry its entry wrote with
`replaceState`, so `history.back()` goes nowhere and a page Back button is
dead. The only stack with somewhere to go is the native one the shell pushed
the page onto.
Adds `notify { name: 'navigate-back' }` to the closed client union, gated on
the existing `navigate` grant rather than a name of its own: an app that can
open a screen can close one, and a new grant name would leave every route
declaring it native on every shell already shipped. `MOBILE_WEB_SHELL_GRANTS`
is unchanged and `BRIDGE_PROTOCOL_VERSION` is not bumped.
`bridgeNotifyRefusal` grows a name-to-grant table, since this is the first
notify whose name is not its grant's. The shell screen pops its own stack and
answers false when there is nothing left, which the host logs as
`navigate-back-refused` — nothing crosses back to the page either way, so
silence there is indistinguishable from a Back button that worked.
Inert until a consumer exists: no page posts the name yet.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e C, C2.2)
`useRouteHandoff` wrapped `push`, `replace` and `dismissTo` and left `back`
as expo-router's own, which inside the page pops a history of one and does
nothing. It now pops locally when the document grew a stack of its own, and
otherwise posts `navigate-back` for the shell to pop the native stack.
This is what makes the Tasks header's `onPress={() => router.back()}`
(`src/tasks/mobile-tasks-screen-chrome.tsx`) work once the C2.1 consumer
routes that screen's router through this seam; the barrel still reaches
expo-router directly, so nothing calls this yet.
A shell that granted no `navigate` falls through to the local router rather
than throwing out of a tap handler. A shell that granted `navigate` but is
too old to know the verb refuses the frame as `unrecognised-message` and
logs it; neither is distinguishable from the page, and the fallback goes
nowhere in both — which is exactly where Back already went.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The header said three wrapped members driven by one answer. `back` is a fourth, and it is not driven by that answer: it carries no target, so the document's own stack decides it rather than the shell's route list. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`Probe` grew `backPops`, and two cases build the object inline rather than through `mount`. `tsc -p tsconfig.json` excludes test files, so only the tests-typecheck ratchet saw it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ase C, C2.2) `useRouteHandoff().back()` asks expo-router's `canGoBack()` whether this document can serve a back itself, and that answer is React Navigation's, so no unit test settles it. The render check now measures it in the browser it actually runs in. Read through `router.back()` on `/h/[hostId]/edit`, a real route of this tree whose chevron is expo-router's own back, because the page exposes no handle to call `canGoBack()` on and a global added for a test would ship forever. Measured: the router has nowhere to go on the document the shell opens, and a location change does not give it one either. So the handoff's `canGoBack()` gate answers false for everything the shell or the browser can do to the page, and its local branch belongs to a push the page makes through the handoff itself. The shell double now records every notify the page posts and takes the grant list as a parameter, so a control that handed something to the shell can be told from one that did nothing. The first case asserts a real tap crossing the bridge, which is what makes the two absences after it evidence. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ No critical issues — one minor consistency question inline.
Reviewed changes
Reviewed the full 20-file diff at 15187d1 against main (e49b3aa). The PR adds the navigate-back bridge notify end to end and is inert on released phones (no page-tree call site yet):
- Contract —
bridge-envelope.tsaddsBRIDGE_NAVIGATE_BACK_NOTIFYand a closed-union variant that carries no target;bridge-notify-grants.tsreplaces the name-keyed gate with a name→grant map. - Host —
bridge-host.tsacts on the notify and reportsnavigate-back-refusedwhen the pop finds nothing;MobileWebShellScreen.tsxpops its own router stack guarded byrouter.canGoBack();use-mobile-web-shell-bridge.tsthreads the callback through a ref. - Page —
bridge-client-notifications.ts/bridge-rpc-client.tsexposenotifyNavigateBack()under thenavigategrant;route-handoff.web.tsback()pops locally, otherwise hands the pop to the shell and falls through to the local router when the grant is absent. - Tests — unit coverage for host, page and hook, plus a real-browser render check that measures
canGoBack()on/h/[hostId]/editand establishes the page holds no local stack.
The back() branch order (canGoBack() || !notifyNavigateBack()), the no-target schema, and the old-shell refusal path all check out; the render check's presence precondition makes the two absence cases evidence rather than silence.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe web route handoff now supports Back navigation. It uses the page router when local history exists and otherwise sends a
Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed technical context, motivation, implementation changes, testing, and review history. However, it does not follow the required template. It omits the required ELI5, Why, Linked Issue, Visual Proof, AI Disclosure, Agent skill upstream boundary, Notes, and Checklist sections. It also does not provide the required issue link or visual proof/N/A statement. Resolution Update the description to include all required template sections. Add the linked issue after "Fixes #". Add before-and-after visual proof, or write "N/A" with a reason if there is no visual or interaction change. Add the required testing checkboxes and platform details. Complete the checklist and the remaining required sections, or explicitly mark them as not applicable.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: cb254a26-aa07-4bab-8bec-6909e0b47190
📒 Files selected for processing (20)
config/scripts/mobile-web-app-render.test.mjsmobile/src/mobile-web-shell/MobileWebShellScreen.test.tsxmobile/src/mobile-web-shell/MobileWebShellScreen.tsxmobile/src/mobile-web-shell/bridge-diagnostic-log.tsmobile/src/mobile-web-shell/bridge-host-contract.tsmobile/src/mobile-web-shell/bridge-host-notifications.test.tsmobile/src/mobile-web-shell/bridge-host-test-harness.tsmobile/src/mobile-web-shell/bridge-host.tsmobile/src/mobile-web-shell/bridge/bridge-client-notifications.test.tsmobile/src/mobile-web-shell/bridge/bridge-client-notifications.tsmobile/src/mobile-web-shell/bridge/bridge-envelope.test.tsmobile/src/mobile-web-shell/bridge/bridge-envelope.tsmobile/src/mobile-web-shell/bridge/bridge-notify-grants.test.tsmobile/src/mobile-web-shell/bridge/bridge-notify-grants.tsmobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.tsmobile/src/mobile-web-shell/bridge/bridge-rpc-client.tsmobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.tsmobile/src/mobile-web-shell/use-mobile-web-shell-bridge.tsmobile/src/navigation/route-handoff.web.test.tsxmobile/src/navigation/route-handoff.web.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| // The one member whose handoff needs no target: inside the page there is nothing behind this | ||
| // document, because the entry wrote its single history entry with `replaceState`. A stack the | ||
| // page did grow it pops itself; otherwise the stack that has somewhere to go is the native | ||
| // one the shell pushed this page onto, and a shell that cannot pop it leaves Back exactly as | ||
| // dead as it already was. | ||
| back: () => { | ||
| if (router.canGoBack() || !client.notifyNavigateBack()) { | ||
| router.back() | ||
| } | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n "protocolVersion|protocol version|capabilit|native version|app version|OTA|older shell|back.*fallback" mobile/src config docs README.md
sed -n '1,140p' mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts
sed -n '1,130p' mobile/src/mobile-web-shell/bridge/bridge-client-session.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- candidate files ---'
fd -t f . mobile/src mobile config docs README.md 2>/dev/null | rg '(^|/)(bridge|navigation|config|session|init|.*ota.*|.*version.*|.*shell.*|.*rollout.*)' | head -200
printf '%s\n' '--- targeted references ---'
rg -n --glob '*.ts' --glob '*.tsx' --glob '*.md' --glob '*.json' --glob '*.yaml' --glob '*.yml' \
'(OTA|ota|rollout|older shell|old shell|native shell|shell version|protocolVersion|protocol version|capabilit|session|init|initialize|version)' \
mobile/src mobile config docs README.md 2>/dev/null | \
rg -v 'xterm|node_modules|dist|build|vendor' | head -500
printf '%s\n' '--- bridge files ---'
fd -t f . mobile/src/mobile-web-shell | sort | head -200Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- session and bridge contract references ---'
for f in \
mobile/src/mobile-web-shell/mobile-web-shell-session.ts \
mobile/src/mobile-web-shell/mobile-web-shell-session-contract.ts \
mobile/src/mobile-web-shell/bridge-host.ts \
mobile/src/mobile-web-shell/bridge-host-init.test.ts \
mobile/src/mobile-web-shell/bridge/page-bootstrap.test.ts \
mobile/src/mobile-web-shell/bridge/bridge-envelope.ts \
mobile/src/mobile-web-shell/bridge/bridge-client-notifications.ts
do
if [ -f "$f" ]; then
echo "### $f"
rg -n -C 3 '(init|version|protocol|capabil|grant|session|generation|shell)' "$f" | head -240
fi
done
printf '%s\n' '--- focused OTA and compatibility references ---'
rg -n -C 2 --glob '*.ts' --glob '*.tsx' --glob '*.md' --glob '*.json' --glob '*.yaml' --glob '*.yml' \
'(OTA|over-the-air|over the air|runtime version|native version|app version|protocolVersion|protocol version|older shell|old shell|mixed-version|cross-version|compatib)' \
mobile .github docs 2>/dev/null | \
rg -v 'xterm|node_modules|dist|build|vendor|audits' | head -500Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -o pipefail
for f in \
mobile/src/mobile-web-shell/bridge/bridge-init-frame.ts \
mobile/src/mobile-web-shell/bridge/bridge-caps.ts \
mobile/src/mobile-web-shell/bridge/page-bootstrap.ts \
mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts \
mobile/src/navigation/route-handoff.web.ts \
mobile/src/navigation/route-handoff.web.test.tsx
do
if [ -f "$f" ]; then
echo "### $f"
wc -l "$f"
cat -n "$f" | sed -n '1,220p'
fi
doneRepository: stablyai/orca
Length of output: 46567
Gate navigate-back with its own init grant. OTA page bundles can run against older installed shells. An older shell can grant navigate but reject navigate-back without replying. The page then skips router.back(), so Back remains inert.
Add navigate-back to the new shell's init.grants.native, map the notification to that grant, and check it in notifyNavigateBack(). Older shells will omit the grant and use the existing local fallback. The existing grant metadata provides this capability signal; BRIDGE_PROTOCOL_VERSION does not need to change.
…d (OTA phase C, C2.2) `canGoBack()` and `back()` disagree about time. The first reads the committed navigation state; the second only adds `GO_BACK` to expo-router's `routingQueue`, which `useImperativeApiEmitter` drains from an effect. Two `navigate-back` frames delivered in one native batch therefore both read the stack the first pop has not left yet, both queue, and a three-deep stack unwinds past the screen the page was opened over. The host forwards every notify it is granted, so nothing upstream coalesced them. `useShellStackPop` owns the pop and latches it. The latch clears on the committed route rather than on a timer, because that commit is the first moment `canGoBack()` answers for the stack the pop actually left; a pop that takes this screen off the stack unmounts it and takes the ref with it. `onNavigateBack` now answers `popped` / `nothing-to-pop` / `pop-pending` so the `navigate-back-refused` diagnostic is true for the frame it names, and the log dedupes per reason rather than burying the second behind the first. Driven against expo-router 55.0.18's own `global-state/routing.js`, evaluated verbatim with only its externals stubbed: a mock of `canGoBack` is what hid this. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ase C, C2.2)
The table was `Record<string, string | undefined>` indexed with a plain
string, so a notify name with no row returned undefined, read as ungated,
and the host acted on a frame it had never granted. Adding a member to the
envelope's notify union raised no error anywhere — the hole was silent.
Keyed on `Extract<BridgeClientMessage, { type: 'notify' }>['name']` with
`string | null` values, an omitted row is now a TS2741 on the table itself,
and `bridgeNotifyRefusal` cannot be asked about a name the table has no row
for.
Adds the `navigate` and `storage` rows, which were missing: the host was
enforcing the navigate grant for `navigate-back` but not for `navigate`.
Both are inert while every page is offered every grant, and load-bearing the
moment a grant is per-route.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…opstate (OTA phase C, C2.2) The case that dispatches a synthetic `popstate` read its answer as "the page did not move", and a throw under the page's fault boundary leaves the page exactly there. Without the errors assertion the other two cases carry, that absence was not evidence of what it claimed. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…them The casting gate refuses the two assertions the loader used, and it is right: a stub that stopped covering an import would have left the members undefined and the test would have driven a half-evaluated module. Destructure and check instead, so that case says so. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the incremental delta since the prior pullfrog review at 15187d1 (commits d819c97faf, 9398733fe9, 2eec51ff01, ca7119bed9) against main (0817476b2c):
- Refused a second stack pop in one batch —
use-shell-stack-pop.tslatches a queued pop and clears on the committedusePathname(), socanGoBack()/back()'s time skew cannot unwind a three-deep stack past the host screen; the boolean contract becameBridgeNavigateBackOutcomeand the refusal log now namesnothing-to-popvspop-pending. - Made the notify grant table total —
BRIDGE_NOTIFY_GRANTSis nowRecord<BridgeNotifyName, string | null>over the envelope's notify union, addingnavigateandstoragerows so the host enforces those grants on their own names, not only onnavigate-back(the prior inline note). - Asserted no page errors — the render check's
popstatecase now assertsopened.errorslike its two siblings. - Read the routing module's members — the latch test destructures and checks
canGoBack/goBack/routingQueueinstead of asserting them, satisfying the casting gate.
The latch is exercised against expo-router's shipped routing.js with only its externals stubbed, and the grant table's totality is a compile-time property pinned by exact tests.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…A phase C, C2.2) The comment read as if the clear were exhaustive. It is not: a pop landing on an equal pathname does not transition `usePathname`, and a `GO_BACK` the queue discards commits no route at all — `routingQueue.run` shifts every action off the queue whether or not `ref.current` is set. Kept the pathname clear rather than moving to the navigator's `state` event. The event would cover the first stick: `@react-navigation/core` 7.17.2 emits `state` from an effect keyed on the navigator state object, and every pop replaces it. It would not cover the second, which changes no state. And the emitter is the navigator, not the routing module this hook is written and tested against, so the switch cannot be earned by a test here the way the queue behaviour was — it would rest on a mock of the signal under test. Both sticks are bounded instead, in the commit that makes the latch one per stack: the holder releases on unmount, so a stick lasts at most as long as the screen that took it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…A phase C, C2.2) `MobileWebShellScreen` mounts at both `app/h/[hostId]/index.tsx` and `app/h/[hostId]/web.tsx`, and `/h/a/web` is deep-linkable over `/h/a`, so two shells can be mounted over one native stack. A latch per screen left each of them holding its own, and two frames from two pages still unwound two screens. The latch is module-scoped and carries which screen took it, so a shell whose own route commits cannot release a pop another shell is still waiting on. The holder also releases on unmount, which is what bounds the two pops the pathname clear never hears about: a latch nobody is left to release would outlive the stack it guards and leave Back dead for the session. Both screen suites now unmount their trees between cases, because a tree that is only dropped is a screen still holding whatever pop it took. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…phase C, C2.2) `BRIDGE_GRANT_GATED_NOTIFY_NAMES` existed so a caller could ask which names ride a grant. Once the table became total over the notify union, the table itself answers that and the only readers left were the two assertions that read the list for its own sake. Deleted with them. The behaviour they stood next to is kept: the protocol's own names are still asserted ungated through `bridgeNotifyRefusal`. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… phase C, C2.2) The comment claimed the guard catches a stub that stopped covering an import. It does not: evaluating the module with every stub dropped still defines all three exports, because the module assigns them whatever its imports resolved to, and the failure surfaces later as `TypeError: Cannot read properties of undefined (reading 'navigationRef')`. What the guard does catch is an expo-router upgrade that renames or removes one of the three members this test drives. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6f71b82b-6d14-4331-99ac-b76cda39d39c
📒 Files selected for processing (5)
mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsxmobile/src/mobile-web-shell/bridge/bridge-notify-grants.test.tsmobile/src/mobile-web-shell/bridge/bridge-notify-grants.tsmobile/src/mobile-web-shell/use-shell-stack-pop.test.tsxmobile/src/mobile-web-shell/use-shell-stack-pop.ts
💤 Files with no reviewable changes (1)
- mobile/src/mobile-web-shell/bridge/bridge-notify-grants.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test-isolation suggestion inline.
Reviewed changes
Re-reviewed the incremental delta since the prior pullfrog review at ca7119b (commits 5798912487, dc6e50c08f, b34e6db89d, d078a3b391) against main (0817476b2c):
- Held one pending stack pop per stack —
use-shell-stack-pop.tsmoves the latch from a per-screenuseRef(false)to a module-scopedpendingPopsymbol that records which screen took it and is released when that screen's route commits or it unmounts, so two shells mounted over one stack (/h/aand the deep-linkable/h/a/web) cannot each queue aGO_BACK. - Named the two pops the pathname clear never hears — the hook documents the equal-pathname pop and the
GO_BACKa teardown drain discards, and why the unmount release bounds both. - Dropped the dead gated-name list —
BRIDGE_GRANT_GATED_NOTIFY_NAMEShad no production reader once the grant table became total; removed with its tests. - Corrected the routing-module guard comment — the guard catches an expo-router upgrade that renames or drops
canGoBack/goBack/routingQueue, not a stub that stops covering an import.
The module-scoped latch reads sound: it is one per stack, only its holder can release it, and the unmount cleanup bounds the two cases the pathname clear misses. I ran the focused mobile suites (use-shell-stack-pop, MobileWebShellScreen) and both pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…al (OTA phase C, C2.2) The harness swapped the tree's root element between a single shell, a fragment of two, and a single shell again. Each swap remounts everything under it, so the callbacks the cases held belonged to unmounted hooks. One of those could still take the module-scoped latch, and the instance that took it was already gone, so nothing was left to release it — the last case in the file leaked the latch into whatever ran next. The root is now one component with a slot per shell, so removing the holder leaves the second shell's instance alone, and every pop is taken through a callback re-read at call time. `afterEach` now asserts the latch is clear by mounting a screen after every other one is gone and requiring it to pop. Without it this leak was invisible: it surfaces only in a following case, and the case that caused it was last. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the incremental delta since the prior pullfrog review at d078a3b (commit bd4460ee42) against main (e49b3aa):
- Made the two-shell latch harness leak-proof —
use-shell-stack-pop.test.tsxnow renders oneShellsroot with a slot per shell, so adding or removing a shell no longer swaps the root element type and remounts the surviving instance.secondPop()re-reads whichever instance is mounted when it is called, instead of using a callback captured before the swap. - Added a latch probe to
afterEach— every case is followed by mounting a fresh screen on a two-deep stack and asserting it can pop, so any case that leaves the module-scopedpendingPopset fails on that case rather than silently on the next one.
The prior inline thread about the leaked pendingPop is addressed by bd4460ee42 and resolved. I ran the focused suite (mobile/src/mobile-web-shell/use-shell-stack-pop.test.tsx, 5 tests) and it passes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

What this is
OTA phase C, C2.2: the first shell verb of the C2 series. A page served at
/holds the one history entry its entry wrote withreplaceState, sohistory.back()goes nowhere and any Back button inside the page is dead. The only stack with somewhere to go is the native one the shell pushed the page onto. This PR lets the page hand that Back to the shell.Independent PR off main (
0817476b2c), not stacked. Inert for released phones: no consumer posts the name yet (the Tasks route is native until the C2.1 consumer PR), and the dev-flagged page never sends what it is not granted.What changed, by layer
bridge-envelope.ts,bridge-notify-grants.ts):notify { name: 'navigate-back' }joins the closed client union. It rides the existingnavigategrant rather than a name of its own: an app that can open a screen can close one, and a new grant name would leave every route declaring it native on every shell already shipped.MOBILE_WEB_SHELL_GRANTSis unchanged andBRIDGE_PROTOCOL_VERSIONis not bumped.bridgeNotifyRefusalgrows a name-to-grant table, since this is the first notify whose name is not its grant's.bridge-host.ts,bridge-host-contract.ts,MobileWebShellScreen.tsx,use-mobile-web-shell-bridge.ts): the shell screen pops the top of the native stack (which may be a native screen pushed over the page) throughuseShellStackPop, and answerspopped,nothing-to-poporpop-pending; the host logs the two refusals asnavigate-back-refusedwith the reason. Nothing crosses back to the page either way. No Swift or Kotlin: the pop is the RN router's.route-handoff.web.ts,bridge-client-notifications.ts,bridge-rpc-client.ts):useRouteHandoffnow wrapsbackalongsidepush,replaceanddismissTo. It pops locally when the document grew a stack of its own (expo-router'scanGoBack()), otherwise postsnavigate-back. A shell that granted nonavigatefalls through to the local router rather than throwing out of a tap handler.How an older shell refuses the name
The page cannot tell an old shell from a new one: both grant
navigate. An older shell that lacks the name refuses the frame asunrecognised-messageand logs it; the page sees nothing and its fallback goes nowhere, which is exactly where Back already went. The C2 ruling said "ungrantedat the call site"; that is not reachable because the grant it rides is one the old shell already gives. Stated here rather than silently corrected.What the render check measured
canGoBack()is React Navigation's answer about a mounted tree, so no unit test settles it.config/scripts/mobile-web-app-render.test.mjsnow reads it throughrouter.back()on/h/[hostId]/edit, a real route whose chevron is expo-router's own back, because the page exposes no handle and a test global would ship forever. Three cases, in order:navigatewith href/to the shell double. Without this, the two absences below would be silence.pushStatepluspopstategrowshistoryby one, the same chevron still moves nothing: a location change resets the router rather than stacking on it.So the handoff's local branch belongs only to a push the page makes through the handoff itself, and this tree makes none today. The gate stays.
Not driven from the browser:
useRouteHandoff().back()has no call site in the page tree yet (every Back control reaches expo-router directly; the seam's only consumer callsdismissTo). That aback()through the seam postsnavigate-backis proven at unit level until C2.1 routes the Tasks barrel through it.Checks
Mobile tsc, tests-typecheck ratchet, whole-tree oxlint, format, both changed-code gates against main, full mobile suite including the bridged parity gate (787 goldens, classes unchanged), root
config/scriptssuite including the render check.Review round 1 (SHIP WITH NITS, three findings folded, one declined)
Fresh reviewer at
15187d1abcconfirmed the version unbumped,MOBILE_WEB_SHELL_GRANTSunchanged, the old-shell refusal against the base parser (an unknown notify name falls tounrecognised-messageand is logged), and inertness twice over (the shell flag is false outside__DEV__;back()through the seam has no call site). Red-first: reverting the host commit fails 16 tests across 6 files, reverting the page commit fails 1. Findings:d819c97faf). The host pop guard readrouter.canGoBack(), which reads committed state, whilerouter.back()only enqueuesGO_BACKfor a later effect. Two frames in one batch both saw true and a three-deep stack unwound past the host screen (reproduced against expo-router's own routing module).useShellStackPopnow refuses a second pop while one is queued and clears on the committed route, not a timer;onNavigateBackanswerspopped,nothing-to-poporpop-pending, so the refusal log names the real reason.9398733fe9). The name-to-grant table was keyed onstring, so a new notify name with no row passed ungated. It is nowRecord<BridgeNotifyName, string | null>over the envelope's union (an omitted row is a compile error), andnavigateandstoragegained rows: the host was enforcing thenavigategrant fornavigate-backbut not fornavigateitself.2eec51ff01). Browser case 3 assertsopened.errorslike the other two.Back to hostson the host route) than the two absences (Backon the edit route). Proving that a no-move handler ran would need an instrument the shipped page carries. The handler is expo-router's ownback(), wired atedit.tsx:149.A fourth commit (
ca7119bed9) reads the routing module's members by destructuring instead of type assertions, which the casting gate refused. Reviewer nit, recorded: revertingroute-handoff.web.tsleaves 3 of the 4 new handoff tests green because the unwrappedbackisrouter.back; only "hands the pop to the shell" discriminates.Review round 2 (SHIP WITH NITS, three lows and one nit folded)
Fresh reviewer at
ca7119bed9re-ran every gate (7841 mobile tests; parity 396/341/3/6/33/8 untouched; all three browser Back cases ran) and broke the folds red-first: deleting thepop-pendingbranch unwinds the real routing module's stack to the home screen, and dropping a table row is the claimed TS2741. Findings and what landed:5798912487,dc6e50c08f). The latch cleared only on a pathname transition, so a pop landing on an equal pathname, or aGO_BACKthe routing queue discards, left it stuck for the screen's life. And the latch was per screen instance while the stack is global: the shell mounts at both the host route andweb.tsx, and/h/a/webdeep-links over/h/a, so two pages could still unwind two screens. Now one latch per stack, released when the holding screen unmounts, so a stick lasts at most as long as the screen that took it; both sticks are named in the hook comment. The pathname clear stays: the navigator'sstateevent would cover the first stick but is emitted by the navigator, not the routing module the test drives, so switching would rest on a mock of the signal under test.b34e6db89d).BRIDGE_GRANT_GATED_NOTIFY_NAMEShad no production reader after round 1; deleted with its tests.d078a3b391). The loader guard's comment named the wrong scenario; it catches a renamed or removed export on an expo-router upgrade, not a stub that stops covering an import (the module assigns its exports unconditionally at eval).Making the latch global also exposed that both shell-screen suites dropped trees without unmounting them; they now tear down between cases.
Bot threads (one fold, one decline)
Pullfrog and CodeRabbit both flagged the latch test's second-shell case: the harness swapped the tree's root element type between cases, so React remounted every shell and a callback captured earlier belonged to an unmounted hook; a pop taken through it could set the module latch with no holder left to release it, and because the leaking case was the last in the file the suite stayed green over it. Folded (
bd4460ee42): the root is one component with a slot per shell, every pop re-reads its callback at call time, andafterEachproves the latch clear by mounting a fresh screen that must pop (red on the leaking case before the fix). CodeRabbit's separate suggestion to givenavigate-backits own grant name is the shape ruling 1 rejected: no shell in the field runs pages before the flip, a new grant name would make every route requiring it native on existing shells, and the fallback goes nowhere in both designs.