Skip to content

feat(mobile): hand the page's dead Back button to the shell (OTA phase C, C2.2) - #21582

Merged
Jinwoo-H merged 14 commits into
mainfrom
ota-c2-2-navigate-back
Sep 19, 2026
Merged

Jinwoo-H merged 14 commits into
mainfrom
ota-c2-2-navigate-back

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

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 with replaceState, so history.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

  • Contract (bridge-envelope.ts, bridge-notify-grants.ts): notify { name: 'navigate-back' } joins the closed client union. It rides 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.
  • Host (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) through useShellStackPop, and answers popped, nothing-to-pop or pop-pending; the host logs the two refusals as navigate-back-refused with the reason. Nothing crosses back to the page either way. No Swift or Kotlin: the pop is the RN router's.
  • Page (route-handoff.web.ts, bridge-client-notifications.ts, bridge-rpc-client.ts): useRouteHandoff now wraps back alongside push, replace and dismissTo. It pops locally when the document grew a stack of its own (expo-router's canGoBack()), otherwise posts navigate-back. A shell that granted no navigate falls 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 as unrecognised-message and logs it; the page sees nothing and its fallback goes nowhere, which is exactly where Back already went. The C2 ruling said "ungranted at 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.mjs now reads it through router.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:

  1. Presence precondition: a real tap on the host header chevron posts navigate with href / to the shell double. Without this, the two absences below would be silence.
  2. On the document the shell opens, Back moves nothing.
  3. After pushState plus popstate grows history by 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 calls dismissTo). That a back() through the seam posts navigate-back is 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/scripts suite including the render check.

Review round 1 (SHIP WITH NITS, three findings folded, one declined)

Fresh reviewer at 15187d1abc confirmed the version unbumped, MOBILE_WEB_SHELL_GRANTS unchanged, the old-shell refusal against the base parser (an unknown notify name falls to unrecognised-message and 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:

  1. Medium, folded (d819c97faf). The host pop guard read router.canGoBack(), which reads committed state, while router.back() only enqueues GO_BACK for 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). useShellStackPop now refuses a second pop while one is queued and clears on the committed route, not a timer; onNavigateBack answers popped, nothing-to-pop or pop-pending, so the refusal log names the real reason.
  2. Medium, folded (9398733fe9). The name-to-grant table was keyed on string, so a new notify name with no row passed ungated. It is now Record<BridgeNotifyName, string | null> over the envelope's union (an omitted row is a compile error), and navigate and storage gained rows: the host was enforcing the navigate grant for navigate-back but not for navigate itself.
  3. Low, folded (2eec51ff01). Browser case 3 asserts opened.errors like the other two.
  4. Low, declined. The presence precondition taps a different control (Back to hosts on the host route) than the two absences (Back on the edit route). Proving that a no-move handler ran would need an instrument the shipped page carries. The handler is expo-router's own back(), wired at edit.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: reverting route-handoff.web.ts leaves 3 of the 4 new handoff tests green because the unwrapped back is router.back; only "hands the pop to the shell" discriminates.

Review round 2 (SHIP WITH NITS, three lows and one nit folded)

Fresh reviewer at ca7119bed9 re-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 the pop-pending branch unwinds the real routing module's stack to the home screen, and dropping a table row is the claimed TS2741. Findings and what landed:

  1. Low, folded (5798912487, dc6e50c08f). The latch cleared only on a pathname transition, so a pop landing on an equal pathname, or a GO_BACK the 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 and web.tsx, and /h/a/web deep-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's state event 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.
  2. Low, folded (b34e6db89d). BRIDGE_GRANT_GATED_NOTIFY_NAMES had no production reader after round 1; deleted with its tests.
  3. Nit, folded (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).
  4. Low, declined. The presence precondition and the two absences sit on different controls (see round 1, item 4).

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, and afterEach proves the latch clear by mounting a fresh screen that must pop (red on the leaking case before the fix). CodeRabbit's separate suggestion to give navigate-back its 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.

…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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts adds BRIDGE_NAVIGATE_BACK_NOTIFY and a closed-union variant that carries no target; bridge-notify-grants.ts replaces the name-keyed gate with a name→grant map.
  • Host — bridge-host.ts acts on the notify and reports navigate-back-refused when the pop finds nothing; MobileWebShellScreen.tsx pops its own router stack guarded by router.canGoBack(); use-mobile-web-shell-bridge.ts threads the callback through a ref.
  • Page — bridge-client-notifications.ts/bridge-rpc-client.ts expose notifyNavigateBack() under the navigate grant; route-handoff.web.ts back() 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]/edit and 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ef16a12d-f212-46df-95c8-60c83dcb7c5f

📥 Commits

Reviewing files that changed from the base of the PR and between d078a3b and bd4460e.

📒 Files selected for processing (1)
  • mobile/src/mobile-web-shell/use-shell-stack-pop.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/src/mobile-web-shell/use-shell-stack-pop.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The web route handoff now supports Back navigation. It uses the page router when local history exists and otherwise sends a navigate-back bridge notification using the navigate grant. The bridge host handles this notification locally and invokes a native stack callback. The mobile screen uses explicit pop outcomes and reports refused pops with diagnostic reasons. Tests cover protocol validation, grant handling, host behavior, router fallback, stack-pop behavior, and browser flows.

Area Change
Web navigation Added local and shell Back handling.
Bridge Added the navigate-back notification and grant mapping.
Native shell Added stack-pop outcomes and refusal diagnostics.
Tests Added coverage for successful, refused, pending, and fallback paths.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.48% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 22 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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… 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 ch…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: handing the page's dead Back action to the mobile shell. It is concise and specific.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cb254a26-aa07-4bab-8bec-6909e0b47190

📥 Commits

Reviewing files that changed from the base of the PR and between e49b3aa and 15187d1.

📒 Files selected for processing (20)
  • config/scripts/mobile-web-app-render.test.mjs
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-diagnostic-log.ts
  • mobile/src/mobile-web-shell/bridge-host-contract.ts
  • mobile/src/mobile-web-shell/bridge-host-notifications.test.ts
  • mobile/src/mobile-web-shell/bridge-host-test-harness.ts
  • mobile/src/mobile-web-shell/bridge-host.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-notifications.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-notifications.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-notify-grants.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-notify-grants.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
  • mobile/src/navigation/route-handoff.web.test.tsx
  • mobile/src/navigation/route-handoff.web.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +78 to +87
// 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()
}
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 || true

Repository: 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 -200

Repository: 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 -500

Repository: 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
done

Repository: 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.ts latches a queued pop and clears on the committed usePathname(), so canGoBack()/back()'s time skew cannot unwind a three-deep stack past the host screen; the boolean contract became BridgeNavigateBackOutcome and the refusal log now names nothing-to-pop vs pop-pending.
  • Made the notify grant table total — BRIDGE_NOTIFY_GRANTS is now Record<BridgeNotifyName, string | null> over the envelope's notify union, adding navigate and storage rows so the host enforces those grants on their own names, not only on navigate-back (the prior inline note).
  • Asserted no page errors — the render check's popstate case now asserts opened.errors like its two siblings.
  • Read the routing module's members — the latch test destructures and checks canGoBack/goBack/routingQueue instead 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.

Pullfrog  | View workflow run | Using 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 6f71b82b-6d14-4331-99ac-b76cda39d39c

📥 Commits

Reviewing files that changed from the base of the PR and between ca7119b and d078a3b.

📒 Files selected for processing (5)
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/bridge/bridge-notify-grants.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-notify-grants.ts
  • mobile/src/mobile-web-shell/use-shell-stack-pop.test.tsx
  • mobile/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts moves the latch from a per-screen useRef(false) to a module-scoped pendingPop symbol 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/a and the deep-linkable /h/a/web) cannot each queue a GO_BACK.
  • Named the two pops the pathname clear never hears — the hook documents the equal-pathname pop and the GO_BACK a teardown drain discards, and why the unmount release bounds both.
  • Dropped the dead gated-name list — BRIDGE_GRANT_GATED_NOTIFY_NAMES had 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.tsx now renders one Shells root 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-scoped pendingPop set 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 1ef9473 into main Sep 19, 2026
31 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-c2-2-navigate-back branch September 19, 2026 06:09
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