Skip to content

fix(mobile): keep an in-page hop local only when the session's grants cover it (OTA phase C, C2.9) - #21723

Merged
Jinwoo-H merged 26 commits into
mainfrom
ota-c2-9-handoff-grants
Sep 21, 2026
Merged

Jinwoo-H merged 26 commits into
mainfrom
ota-c2-9-handoff-grants

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​652 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​602
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​504 $\color{#cf222e}{\Huge{\mathbf{−}}}$​43 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​461

Summary

Phase C, C2.9 (seventeen commits: five product, two merges of main with their folds, a files-route render case with its helper fix, the round-1 fold, two test folds, and the narrow case aimed at C2.10's header): an in-page hop is taken only to a route the session's grants cover. Otherwise the page hands the hop to the shell, which opens the target natively under a session carrying the target's own grants.

The defect

Grants are resolved once per session from the route the shell opened: init.grants.native on the page and grantsForRoute(session.routePathname) on the host. useRouteHandoff kept a push local whenever the target matched any pattern in init.pageRoutes, so a page route reached by a local push ran under the opener's grants. On a wide layout the shared host layout renders the sidebar HostScreen beside every /h route, and its header pushes /h/<id>/tasks through the handoff, so from the worktree list, agent history or the files pages the tasks page ran without native.clipboard.write and its copy actions refused silently (found by pullfrog and round 3 on #21710). C3.1 patched the one hop it owned by widening a grant list; the sidebar reaches every route, so no pairwise list keeps up.

The rule

init.pageRouteGrants target outcome
absent (older shell) any page route local, as before
present listed page route with no entry handed off (never guess in the direction that loses grants)
present entry whose grants ⊆ the session's local
present entry with a grant the session lacks handed off

Commits

commit what
83b3041de5 init.pageRouteGrants, the manifest's own route/grant pairs, optional in both directions; grammar imported from the manifest contract (MobileWebBundleGrantNameSchema) rather than restated; the host validates the pairs before building the frame and refuses the session on failure, as for a malformed route; schema split into bridge-page-route-grants.ts and the session reducer's three spellings of "patterns, their grants, this route's grants" collapsed into one routeViewOf (two files at their line cap, split not bumped)
b41312bb13 servedHere means served and covered, three answers as above; the explorer ⊇ preview case stays local under the rule
0ad04f967a render check on the shared harness, which now forwards pageRouteGrants: wide viewport without the clipboard grant posts exactly one navigate notify, the document stays put and no new chunk is fetched (the page did not quietly render tasks under the wrong grants); wide with the grant moves the document with no notify; no pairs keeps the old behaviour; narrow asserts the hop does not exist there (only the wide header labels its controls)
e2d7816650, 1f1425c566 merge of main (ac024d4f05, C3.1) and the fold of C3.1's pairwise pin: run against the merged manifest the census failed immediately and named six new uncovered hops (the sidebar into the files explorer from the worktree list and from agent history, and both files routes into tasks), all now pinned handed-off; it does not name explorer → preview, because the preview declares no more than the explorer, which is C3.1's pairwise pin derived rather than stated, so that block and its import are deleted and the case asserts the relation through the manifest; the file's seam and clipboard-absence checks stay (they are about the closure's contents, which the census does not cover)
2fcb999128, 411c105423 the sidebar hop proved from a files route, not only the worktree list: opened on /h/<id>/files/<wt> with that route's own grants, the sidebar's Tasks control posts exactly one navigate notify, the document stays on the files route and no new chunk is fetched (five cases in the file); the render helper now waits on the text its caller names (a dead awaitText parameter had let the case pass only because the files route happens to render the host name the helper was waiting on)
706b07807b round 1 blocker: the session reducer's download branch built its ready state without pageRouteGrants, so every first install and every OTA update handed off every in-page hop; now every branch derives through one routeViewOf, moved to page-route-policy.ts beside grantsForRoute (the reducer sat at its line cap; split, not bumped); three reducer cases (cold download, cached hit, generation change), two red before the fix
e23bc80c29 round 1: the census's targets come from navigation call sites only (mobile-app-navigation-targets.mjs: arguments to push/replace/navigate on a router, plus navigateFromHostList; a local binding or href builder followed one step), not from every route template in the sources, which had made the reachability filter inert; with the header's two tasks pushes removed the presence case and the pin both red, where the old derivation stayed green
359001f9f8, 8870d40e04 round 1 lows: the preview-declares-something guard restored; mobile-web-page-routes.mjs comments rewritten for the rule
dae6ea7553 CodeRabbit: both fixtures mirror the manifest's four tasks grants, plus one unit case that discriminates (clipboard held, externalLink not: still handed off)
adfcbaf685 a stalled hop names its cause: the render test's timeout carries the pathname, page errors, notifies, body text and every script response since the click
fc61b73177, 079e84e4ee config/scripts census: every page route is an opener (the sidebar reaches all of them), targets derived from the hrefs the app builds, so an unwritten hop is not pinned and a new one is; two hops pinned as handed off, both into tasks; a presence case keeps the sidebar's tasks push found; widening the worktree list's grants to cover tasks fails the pin; an unused import dropped
086c192f9a merge of origin/main (169bccc544, carrying #21727's query-string patch and C2.10's header labels; three conflicts: pr.yml took main's side, whose config/scripts/mobile-web-app- prefix already registers the render file; the render harness and the bridge hook test took unions, pageRouteGrants beside main's streams/windowCaps and BRIDGE_SCREENCAST_BINARY_GRANT)
d5a9a9f7fe test(mobile): aim the narrow hop at the control C2.10 named — at 390 px exactly one labelled Tasks control exists, tapping it posts exactly one navigate notify for /h/<id>/tasks, the document stays on /h/<id>, no new script chunk is fetched, no page errors; the old absence case reds against the merged header (expected 1 to be +0); granting the session native.clipboard.write reds the new case (expected [] to deeply equal [ { …name: 'navigate', href: '/h/render-check-host/tasks' } ])
f3facf1501 GitHub merge of origin/main (8a3a119052)
671bedcd01 docs(mobile): drop the pre-C2.9 one-liner that contradicted the handoff predicate's comment (round 2)
a4dc78acb0 test(mobile): pin the pageRouteGrants: refusal reason and that the diagnostic and callback carry the same string; control: a malformed route reports its own issue without that prefix (round 2)
7cf2532ef6 refactor(mobile): make implementedPageRouteEntries and implementedPageRoutes module-local; the test reads the list through routeViewOf(...).pageRoutes (round 2; red 7 failed with the exports gone and the test untouched)
c3372948e5 merge of origin/main (35005fb65c, PR E haptics and PR B mermaid): bridge-envelope.ts as a union (now exactly 300 of 300 lines); page-route-policy.ts keeps the split with PR E's paragraph re-homed onto the entries helper and BRIDGE_HAPTICS_GRANT carried; PR E's two policy cases routed through routeViewOf
c28271172a test(mobile): give each handoff fixture its opener route's real grants — both carried pre-E lists (tasks 4 vs the manifest's 5) and agreed with the rule by accident; with the token on the pairs alone two covered hops flip to handed-off (35 + 5 render + 870 shell)
0a6fdb1c90 merge of origin/main (2d697a4012, #21908)
1cf1b302b7 test(config): re-record the session route's page closure at 4,326 — #21908's bridge-haptics-notify.ts plus this PR's bridge/bridge-page-route-grants.ts and mobile-web-bundle/manifest-contract.ts, reaching every page closure through bridge-envelope.ts (red expected [ …(4326) ] to have a length of 4324)

No frame kind, no cap change, no BRIDGE_PROTOCOL_VERSION bump. The host side stays bound to the opened route.

Verified

  • Lead gate on 1cf1b302b7 (round-2 folds, the fixture fix, merges of main through 2d697a4012) against 2d697a4012 (verify-gates.sh in the lane tree with the patched install, four artifacts rebuilt): tsc 0, ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0 (bridge-envelope.ts at exactly 300 of 300), root oxlint over 29 changed files 0, machine paths 0; config/scripts 240 files / 2,177 passed, 0 failed; mobile 774 files / 8,671 passed, 0 failed.

  • Round 2 (delta, on d5a9a9f7fe): approve, four lows, all folded above; merge integrity, both engines, three narrow-case controls, the patched query-string resolution and the census reproduced by the reviewer.

  • Lane gates on 411c105423: mobile tsc, ratchet, oxlint from mobile and root (0 errors), oxfmt, full mobile suite (718 files, 8186 passed, no Errors), config/scripts suite with mobile deps required (222 files, 2006 passed), changed-code quality, react-doctor, merge-tree clean, machine-path grep clean.

  • Parity: no family moved; 787 goldens, classes unchanged; nothing under mobile/rpc-foundation/.

  • Lead reproduction: verify-gates.sh on 1f1425c566, 411c105423, 8870d40e04, dae6ea7553 and adfcbaf685 against ac024d4f05; the stripped-tasks-pushes mutation reds the presence case and drops the four -> tasks rows; machine-path grep over every changed file.

  • Round 1 (on 1f1425c566): one blocker and two majors, all reproduced and folded above.

  • CI on 411c105423: the two local-hop render cases time out. Not this PR: on a lockfile-faithful install the local push crashes in React Navigation's getPathFromState (queryString.stringify is not a function), because fix(deps): update vulnerable transitive packages #21652's query-string 9.5.1 override exports only default; every lane tree still ran 7.1.3. Fixed by fix(mobile): restore query-string's named exports under the 9.5.1 override #21727 (169bccc544); merged here as 086c192f9a. In the lane's tree with a lockfile-faithful mobile/ install, expo-router resolves [email protected]_patch_hash=8624f1be… whose index.js ends export * from './base.js', query-string-named-exports.test.ts passes, and both local-hop render cases pass. Lead gate on d5a9a9f7fe against 169bccc544 (verify-gates.sh, run in the lane tree with the patched install, artifacts rebuilt): tsc 0, ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 27 changed files 0, root oxfmt over 7 files 0, machine paths 0; config/scripts 238 files / 2,137 passed, 0 failed; mobile 771 files / 8,616 passed, 0 failed. These cases are the first in CI to make a real expo-router push in a browser, which is why main stayed green.

Noted, not changed

The narrow-viewport host header's Accounts control: C2.10 (cef4416115) named the header's controls, and this PR's narrow case now taps the labelled Tasks control (d5a9a9f7fe in the commit table); nothing else in that header is asserted here.

Part of the mobile OTA plan (Phase C). Reference PR #13386, never merged.

…C, C2.9)

The page decides an in-page hop from `init.pageRoutes`, which says which patterns
this shell would render and nothing about what each one costs. So a push kept
local on the strength of the pattern alone runs the target under the opener's
grants — which is how the tasks page is reached from the wide-layout sidebar
without `native.clipboard.write`, and why its copy actions refuse silently.

`init` now also carries `pageRouteGrants`, the manifest's own route/grant pairs,
from the manifest the shell already holds. Optional in both directions: an older
shell omits it and an older page ignores it, and a page that receives none keeps
today's rule. No new frame kind, no cap change, no protocol bump.

The grammar is the manifest's, imported rather than restated
(`MobileWebBundleGrantNameSchema`, now exported for this), so a grant name the
bundle could not have declared cannot reach the page through this field either.
The host validates the pairs before it builds the frame and refuses the session
when they fail, for the reason it already refuses a malformed route: an `init`
the page would reject whole is worse than no session at all.

Two files were at their line ceiling and are split rather than bumped. The pairs
schema moves to `bridge-page-route-grants.ts`, which is read by both the envelope
and the host, so it belonged in one place anyway. In the session reducer the
three sites that each spelled out "patterns, their grants, this route's grants"
become one `routeViewOf`; that is a net reduction and removes the fourth spelling
before it is written.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The rule the page was using is "the shell would render this pattern", and that is
not the question. Grants are resolved once, from the route the shell opened, so a
push kept local runs the target under the opener's list. On a wide layout the
sidebar renders beside every `/h` route and pushes `/h/<id>/tasks` through this
seam, so from the worktree list, agent history or the files pages the tasks page
ran without `native.clipboard.write` and its copy actions refused with nothing on
screen to say why.

`servedHere` now means served here *and* covered: the target's declared grants
must be a subset of this session's. An uncovered page route is handed to the
shell exactly like a non-page route, and the shell opens it as its own session
with its own grants — which is the mechanism that already exists, rather than a
new one.

Three answers, not two, because an absent field is not an empty one. A shell that
sent no pairs keeps the old behaviour: `null` is "nobody told me", and an older
shell has to keep working. A target the shell lists but names no entry for is
*not* covered — the page cannot justify that hop, so it hands it over rather than
guessing in the direction that loses grants.

This is C3.1's explorer ⊇ preview finding without its pairwise pin: that hop is
covered by this rule and stays local, and the rule scales to the sidebar, which
reaches every route and which no pairwise list can keep up with.

Red first on the two cases only the new rule answers; the other four are the
regression guards and passed before and after. Two whole-session assertions
gained `pageRouteGrants: null`, which is what the reader now returns.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… own grants

The unit tests pin the decision; only a browser shows the control exists, is
reachable at the viewport where the sidebar renders, and that the document does
not move when the hop is handed over.

Four cases on the shared harness, which now forwards `pageRouteGrants` (omitted
when a caller names none, because an absent field is not an empty one and the
page reads the difference).

- Wide, session without `native.clipboard.write`: tapping Tasks posts exactly one
  `navigate` notify, the document stays on the worktree list, and **no new chunk
  is fetched** — which is what says the page did not quietly render tasks under
  the wrong grants.
- Wide, same tap with the grant added: no notify, the document moves to `/tasks`.
  Without this the first case would pass on a page that simply never navigates.
- Wide, shell sending no pairs at all: the old behaviour, local. An older shell
  must not start handing every hop over on a field nobody sent.
- Narrow: asserts the absence rather than a tap. `app/h/_layout.tsx` renders the
  sidebar only on a wide layout, and only that header branch labels its Accounts
  and Tasks controls; the narrow header's are unlabelled pressables. So the hop
  does not exist at that viewport, and `getByLabel('Tasks')` finding nothing is
  the honest assertion. That unlabelled narrow header is a real accessibility gap
  and is not this lane's to fix.

Registered in `pr.yml`'s `mobile_web_app` job beside the other render checks.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The rule landed in the commit before this one decides each hop; this says which
hops those are, so a route's grants growing — or a new push between two page
routes — shows up here rather than as a verb that silently refuses on a device.

Openers are every page route, not the one that happens to push. On a wide layout
`app/h/_layout.tsx` renders the worktree-list sidebar beside every `/h` route and
its header pushes tasks, which is exactly why a pairwise pin is the wrong shape:
the sidebar reaches everything, so the census has to be the cross product of what
the manifest declares against what the source actually builds.

Targets come from the hrefs the app builds, read out of `mobile/src` and
`mobile/app` and reduced to route patterns, so a hop nobody writes is not pinned
and a hop someone adds is. A presence case asserts the sidebar's tasks push is
among them, because a census that stopped finding hops would go quietly green.

Two hops are pinned as handed off today, both into tasks, which is the only route
declaring more than `navigate` and `storage`. A third case asserts the other half
of the rule on the manifest: a target asking for no more than its opener stays in
the document.

Checked that it discriminates rather than assuming: widening the worktree list's
grants to cover tasks fails the pin, and restoring them passes it.

**No pin was deleted.** The brief expected C3.1's pairwise explorer/preview pin to
be replaced here, but C3.1 is not on this base — `MOBILE_WEB_PAGE_ROUTES` has
three routes and no `files` entry, so there is nothing to remove. When C3.1 lands,
its pin is this census's to subsume.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`statSync` was imported and never used; `oxlint` fails it. My error: I committed
the census on a green test run without waiting for lint, the same order mistake I
made earlier in this lane. Fixed forward rather than amended, because the lane
forbids rewriting a commit that exists.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
C3.1 landed while this branch was open, and it brought the case this lane
generalises: the explorer pushes to its own preview, that push stays in the
document, so the preview runs under the explorer's grants. Its pin asserted that
one pair by name.

The census now covers it as a consequence rather than a rule. With the files
routes in the manifest the cross product finds six more hops the session cannot
cover — the sidebar into files from the worktree list and from agent history, and
both files routes into tasks — and it does **not** find explorer → preview,
because the preview declares no more than the explorer. That absence is the
pairwise pin, derived.

So the pairwise block is deleted, with its import. The rest of that file stays:
its external-link seam checks and its clipboard-absence control are about what
the files closure contains, which this census says nothing about.

Checked the extended census still discriminates: granting the explorer
`native.clipboard.write` fails the pin, restoring it passes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…worktree list

The defect is not "the worktree list pushes tasks". On a wide layout the sidebar
renders beside every `/h` route, so the same hop exists from the files explorer,
whose session carries `externalLink` but not `native.clipboard.write`. One opener
proving the rule would have left the general case to inference, which is the
inference C3.1's pairwise pin already made once.

Opened on `/h/<id>/files/<wt>` with the files route's own grants, the sidebar's
Tasks control posts exactly one `navigate` notify, the document stays on the
files route, and no new chunk is fetched.

The harness helper now takes the route and the text to wait for, so a case can
open on something other than the worktree list without a second copy of it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The `awaitText` parameter I added in the commit before this one was never wired
into the wait, so it was dead and `oxlint` failed it. The case still passed,
because the files route renders the host name in its sidebar and that is what the
helper was still waiting on — which is exactly the kind of accident a dead
parameter hides.

Third time in this lane I have committed on a green test run before lint
finished. Fixed forward, not amended.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`onManifestRead`'s download branch set `pageRoutes` and `routeGrants` from the
new manifest and dropped `pageRouteGrants`; nothing downstream recomputes it, so
every first install and every OTA update reached `ready` with the default or the
previous generation's pairs. The page then read each target as listed-with-no-
entry and handed off every in-page hop.

`routeViewOf` moves to `page-route-policy.ts`, beside the two functions it calls,
to keep the reducer under its line cap without a bump; its stale neighbouring
comment, which described a filter that moved into it, goes.

Red first: the cold-cache and generation-change cases failed, the cached-hit case
already passed.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

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: b534139e-d455-4b96-b863-48e31414ccb9

📥 Commits

Reviewing files that changed from the base of the PR and between adfcbaf and f3facf1.

📒 Files selected for processing (11)
  • config/scripts/mobile-web-app-files-external-links.test.mjs
  • config/scripts/mobile-web-app-handoff-grants-render.test.mjs
  • config/scripts/mobile-web-app-render-harness.mjs
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-host-contract.ts
  • mobile/src/mobile-web-shell/bridge-host-init.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/page-route-policy.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
💤 Files with no reviewable changes (1)
  • config/scripts/mobile-web-app-files-external-links.test.mjs

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


📝 Walkthrough

Walkthrough

The mobile web shell now carries per-route grant declarations through session state and bridge initialization. The page keeps route hops local only when the target route’s grants are covered by the current session. Invalid grant declarations refuse route initialization. Older shells preserve the previous local-navigation behavior. New static census, unit, integration, and browser render tests validate route coverage, handoff behavior, viewport variants, and legacy compatibility.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 26 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description gives detailed coverage of the change, rationale, implementation, testing, and compatibility behavior. However, it does not follow the required template structure and omits a Fixes #… Restructure the description using all required template headings. Add a Fixes #<issue> link, attach visual proof or state N/A with a reason, complete the Testing and AI Disclosure sections, address Review, Agent skill upstream boundary,…
✅ 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 summarizes the main change: in-page hops remain local only when the session grants cover the target route. The scope and phase marker are relevant.
Full details: Description check

Explanation

The description gives detailed coverage of the change, rationale, implementation, testing, and compatibility behavior. However, it does not follow the required template structure and omits a Fixes # issue link, visual proof or an explicit N/A justification, AI disclosure, review notes, and the checklist confirmations.

Resolution

Restructure the description using all required template headings. Add a Fixes #&lt;issue&gt; link, attach visual proof or state N/A with a reason, complete the Testing and AI Disclosure sections, address Review, Agent skill upstream boundary, Notes, and Checklist items.

  • 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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Store pageRouteGrants on the fresh-download path. · mobile-web-shell-session.ts:211-214

mobile/src/mobile-web-shell/mobile-web-shell-session.ts:211-214
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Store pageRouteGrants on the fresh-download path.

onManifestRead derives pageRouteGrants, but the download patch stores only pageRoutes and routeGrants. The session therefore keeps its initial empty array. The bridge sends that array explicitly, so matching page routes have no grant entry and are handed to the shell.

Proposed fix
     {
       pageRoutes,
+      pageRouteGrants,
       routeGrants,
       state: {

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3059d760-4b23-450d-92be-324665de11ea

📥 Commits

Reviewing files that changed from the base of the PR and between ac024d4 and 411c105.

📒 Files selected for processing (25)
  • .github/workflows/pr.yml
  • config/scripts/mobile-web-app-files-external-links.test.mjs
  • config/scripts/mobile-web-app-handoff-grants-render.test.mjs
  • config/scripts/mobile-web-app-render-harness.mjs
  • config/scripts/mobile-web-page-route-hop-coverage.test.mjs
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-host-contract.ts
  • mobile/src/mobile-web-shell/bridge-host-init.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-session.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-init-frame.ts
  • mobile/src/mobile-web-shell/bridge/bridge-page-route-grants.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client-frames.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session-contract.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.ts
  • mobile/src/mobile-web-shell/page-route-policy.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/mobile-web-shell/use-mobile-web-shell-session.ts
  • mobile/src/navigation/route-handoff.web.test.tsx
  • mobile/src/navigation/route-handoff.web.ts
  • src/shared/mobile-web-bundle/manifest-contract.ts
💤 Files with no reviewable changes (1)
  • config/scripts/mobile-web-app-files-external-links.test.mjs

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

The reachability filter was inert. Harvesting every `/h/${…}` template caught the
five screens that declare their own mount pathname, two `pathname ===`
comparisons and the route template types, so every declared route was reachable
through its own mount: the pinned table was the all-pairs one, eight hops with
the filter and eight without.

Targets now come from the arguments of `router`/`navigation` `push`, `replace`
and `navigate`, and of `navigateFromHostList`; mounts, comparisons and types are
excluded by construction because they are not navigation arguments. Two real
hops are not written as a literal, so a local binding or a call is followed one
step to the function that returns the pathname: the files explorer is pushed as
`{ pathname: descriptor.pathname }` and the preview as
`push(createMobileFilePreviewHref(...))`. A call site whose target cannot be read
is returned rather than dropped.

Derived patterns go from 11 to 10; the pinned table stays at eight because all
five page routes are genuinely pushed to. What changes is that the filter now
discriminates: deleting the header's two tasks pushes reds the presence case and
drops the four `-> tasks` rows from the pin, where the old derivation stayed
green on the same deletion because `app/h/[hostId]/tasks.tsx` still declared the
pathname. A push added at a real call site appears in the set.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The pairwise pin this case replaced asserted the preview declares at least one
grant before asserting the explorer covers them all; without it two empty lists
satisfy the subset check and a route that lost its grants passes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Two passages described the world before this PR: the explorer's note said the
census pins its pair with the preview, and a closing paragraph left the sidebar's
tasks hop open for a later PR. This is that PR. Covering the preview now buys the
in-document hop rather than making it correct, an uncovered target is handed to
the shell and reopened under its own grants, and the census reads the explorer to
preview relation off this list rather than pinning it by name.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
CodeRabbit on #21723: both fixtures declared the tasks route as `navigate`,
`storage`, `native.clipboard.write` while the manifest also declares
`externalLink`, so no covered-session case ever required it.

Both now mirror the manifest's four, and the covered sessions hold them. That
alone does not make an `externalLink`-blind rule fail, since those sessions hold
every grant either way, so the unit suite gains the case that does: a session
holding the clipboard but not `externalLink` must still hand the hop off.
Mutating the rule to treat `externalLink` as always held reds that one case and
no other.

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.

Caution

The new pageRouteGrants is not carried through the download step in the session reducer, so on a fresh download the page receives [] and hands off every in-page hop — the exact opposite of this PR's fix, and a later manifest read can leave stale pairs that keep an uncovered hop local. Details inline.

Reviewed changes

  • init.pageRouteGrants crosses the wire. The manifest's {pathname, grants} pairs are added to the host contract/init frame/envelope as an optional field (absent = older shell, old rule), validated by the same grammar as the manifest (MobileWebBundleGrantNameSchema), and the host refuses the session on a malformed pair.
  • routeViewOf collapses three spellings. mobile-web-shell-session.ts derives pageRoutes, pageRouteGrants, and routeGrants together from one manifest read, and implementedPageRouteEntries is added to page-route-policy.ts.
  • servedHere requires coverage. route-handoff.web.ts keeps a hop local only when the matched pattern has a pair whose grants are all in session.grants.native; a listed pattern with no pair, or a pair with an uncovered grant, is handed to the shell.
  • Test assets. A Playwright wide/narrow render check proves the sidebar hop hands over without moving the document or fetching the target chunk, unit tests pin the rule, and a source-scanning census pins which hops must be handed off (folding in C3.1's pairwise pin).

ℹ️ The census pins the manifest, not the rule

config/scripts/mobile-web-page-route-hop-coverage.test.mjs derives its handed-off set from MOBILE_WEB_PAGE_ROUTES and compares it to the hand-written HANDED_OFF list. It is a useful tripwire for a manifest grant change, but it cannot fail if servedHere itself regresses to matching pageRoutes alone. It also derives "the hops the app actually builds" from every `/h/${…}` template literal under mobile/src and mobile/app, which includes shell route declarations (app/h/[hostId]/tasks.tsx:31) and pathname comparisons (host-screen/use-host-worktree-actions.ts:171) as well as real pushes — so deleting the sidebar's actual push would not fail its first case. Not a merge blocker; flagged so the pin is not read as covering more than it does.

Technical details
# Census scope

## Affected sites
- `config/scripts/mobile-web-page-route-hop-coverage.test.mjs:5,113-123` — imports only the manifest; no reference to `page-route-policy.ts` or `route-handoff.web.ts`.
- `config/scripts/mobile-web-page-route-hop-coverage.test.mjs:24,40-56` — `HOST_HREF` scans every non-test `.ts`/`.tsx` under `src` and `app`, not `router.push` / `navigateFromHostList` call sites.

## Required outcome
- (Optional) If the census is meant to be the tripwire for "a new push appears", note in its header that removals and non-push literals are out of scope. The runtime rule is already pinned by `route-handoff.web.test.tsx` tests 1 and 6.

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

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

Caution

The two new commits are clean test additions, but the blocker from the previous review is still present and these commits do not touch it: mobile-web-shell-session.ts:209-223 (onManifestRead's fetching step) still patches pageRoutes and routeGrants without pageRouteGrants, so a fresh-download session hands off every in-page hop. See the inline comment on the prior review for the full trace. This PR should not merge until that field is carried through the download step (and the reducer output pinned by a test).

Reviewed changes (delta since review 5257545979 at 1f1425c)

  • Files-route render case. config/scripts/mobile-web-app-handoff-grants-render.test.mjs opens the shell on /h/<id>/files/<wt> with that route's grants (externalLink, no clipboard) and proves the sidebar's Tasks control posts exactly one navigate notify, the document stays on the files route, and no target chunk is fetched. It fails under the pre-fix rule, so it is a real regression guard.
  • Render helper signature. openHostRoute gains route and awaitText parameters (the wait had been hardcoded to SHELL_HOST.name), and pageRoutes now lists the files pattern alongside host and tasks. Defaults preserve the existing four cases.

The prior critical finding (pageRouteGrants not carried through the download step) is unchanged by this delta.

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

Both waits for the hop to land read as a bare 30 s timeout when it does not. The
CI failure that sent this file back was a `TypeError` inside React Navigation
that blanked the document, and it was invisible here because the error
assertions run after a wait that never returns.

The wait now throws with the page's own account: the pathname it stayed on, the
collected page and console errors, the `navigate` notifies posted, the first 300
characters of the body, and every `.js` response since the click with its status.
The response listener records every script answer rather than only the 200s, so a
chunk the navigation waits on can be seen failing; the 200-only list the
no-new-chunk assertions read is unchanged, as is everything the five cases
assert. Kept in this file because no other render file waits on the pathname
moving.

Proved by mutating the rule to hand every hop off: the covered case fails naming
the pathname it stayed on, an empty error list, the notify it posted and no
scripts since the click — which is the handoff signature, distinct from the
crash signature CI saw.

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.

The blocker from the previous review is fixed, and the new test assets discriminate. Reviewed the delta since the prior pullfrog review (5257557052 at 411c105).

Reviewed changes

  • pageRouteGrants now survives the download path. onManifestRead's fetching step spreads the same routeViewOf result as its sibling sites, so a cold-download or post-update ready session carries the pairs derived from its own manifest rather than the empty default. mobile-web-shell-session-grants.test.ts pins the cold-download, cached-hit, and generation-change outputs with exact toEqual.
  • The hop census derives targets from call sites. New config/scripts/mobile-app-navigation-targets.mjs reads push/replace/navigate/navigateFromHostList arguments (following one local binding or builder call), replacing the old every-/h-template harvest that made the reachability filter inert. Removing the sidebar's tasks pushes now reds the presence case.
  • Preview guard restored and route comments rewritten. mobile-web-page-routes.mjs documents the new handoff rule, and the census re-asserts the explorer ⊇ preview relation the deleted pairwise pin used to hold.
  • Fixtures mirror the manifest and one case withholds externalLink alone. Both render/unit fixtures give tasks the same four grants the manifest declares; the new unit case fails a rule that reads only the verb grants.
  • A stalled hop names its cause. The render test's waitForTasksRoute timeout reports pathname, page errors, notifies, body text, and script responses since the click.

Verified locally: mobile-web-shell-session-grants (6), bridge-host-init (21), use-mobile-web-shell-bridge (22), route-handoff.web (35), mobile-web-shell-session (67), and the census (3) all pass.

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

Jinwoo-H and others added 3 commits September 20, 2026 23:48
# Conflicts:
#	.github/workflows/pr.yml
#	config/scripts/mobile-web-app-render-harness.mjs
#	mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.ts
The narrow case asserted the absence of a labelled Tasks control, which
was true only because the narrow toolbar carried no accessibility props.
C2.10 gave it the wide sibling's role and label, so the assertion was
red on the merge and, worse, the rule this file is about went unproven
on the branch the phone actually presses.

It taps that control now: at 390 px there is exactly one, and the tap
posts exactly one navigate notify for the tasks route while the document
stays on the worktree list and fetches no new chunk. Red first against
the merged header (count 1, expected 0); with the session given
native.clipboard.write the hop goes local and the case reds, which is
what says the assertions discriminate.

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 (delta since prior pullfrog review 5257684890 at adfcbaf)

  • Narrow-viewport hop is now exercised, not assumed. After main's C2.10 gave the narrow host header's Tasks control the same role and label as the wide sidebar's, the 390 px render case in mobile-web-app-handoff-grants-render.test.mjs taps that control instead of asserting it absent, and proves the same handoff: exactly one navigate notify for /h/<id>/tasks, the document stays on the host route, and no new chunk is fetched. It reaches the handoff through navigateFromHostList → router.push (the non-embedded branch), so it genuinely pins servedHere on this branch.
  • Two merges of origin/main. 086c192f9a and f3facf1501 carry C2.10's header labels and later Phase C work into the branch; no PR-authored product change in this delta.
  • pageRouteGrants still derived through routeViewOf. The prior review's blocker fix (carried through the download path) is untouched here, and the census and unit cases remain as reviewed.

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

The pre-C2.9 summary said the answer is whether this document renders
the target, which is exactly the claim the block comment below it
replaced: the predicate now also requires the target's grants to be
covered. Two doc comments on one declaration, the first of them wrong.

Comment only; the 35 handoff cases are unchanged and green.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The host builds `pageRouteGrants: <issue>` so a refusal says which of the
two checked inputs failed, and nothing read it: the case counted
refusals, so a host that reported the route's own verdict for a malformed
pair would have stayed green while sending whoever reads the refusal to a
pathname that was never the problem.

The case pins the prefix, a non-empty issue behind it, and that the
diagnostic and the callback carry the same string. The control is an
opener that fails the other way: a malformed route reports its own issue
and does not take this prefix, without which the pin would hold on any
reason at all.

Red first with the field branch dropped from the reason: the prefix
assertion fails and the control stays green.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… calling

`implementedPageRouteEntries` and `implementedPageRoutes` were the
reducer's two ways in before it moved to `routeViewOf`. The entries form
had no caller anywhere afterwards and the patterns form had only this
test, so the module's public surface advertised two functions no product
code reaches. Both are module-local now; the surface is
`matchesRoutePattern`, `pageRendersRoute`, `grantsForRoute`,
`routeViewOf` and the grant list.

The test reads the same list through `routeViewOf(...).pageRoutes`, which
is the reducer's own view of it, so no assertion changed and no export is
kept for a test.

Red first: with both un-exported and the test untouched, seven cases fail
with `implementedPageRoutes is not a function`; routed through the view
all nineteen pass. Still discriminating, as a control: with the grant
filter dropped from the entries helper, four of them fail.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
# Conflicts:
#	mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
#	mobile/src/mobile-web-shell/page-route-policy.ts
PR E's two haptics cases arrived with the merge calling
`implementedPageRoutes`, which this branch had already made module-local,
so the merged file was red with `implementedPageRoutes is not defined`
on both of them. They read the same list through `pageRoutesOf`, the view
the rest of the file already uses, so neither assertion changes.

PR E's paragraph named that function for the filter it describes; the
filter now sits in the entries helper the view is built on, so the
sentence says that instead of naming a function the reader cannot see.

Red: the two cases above on the merge. Green: all 21, PR E's two included.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
PR E put `haptics` on all five manifest routes, and these fixtures still
carried the pre-E grant lists: tasks with four grants where the manifest
now declares five. A fixture that is short the same token on both sides
of the subset check agrees with the rule by accident, and would have gone
on agreeing after the token stopped being universal.

The pairs mirror the manifest now, and each session carries what its
opener route would actually be granted, since the host narrows a route's
declared grants to what the shell implements and the shell implements the
token.

Red first, with the token added to the pairs alone: the two covered-hop
cases flip to handed-off, `stays in this document when the session
already covers the target` and `keeps the hop in the document when the
session covers tasks`. Green once the sessions carry it, 35 and 5.

The hop census needed nothing: it reads `MOBILE_WEB_PAGE_ROUTES` itself.
Measured there, all 5 routes declare the token and it is the missing
grant in 0 of the 8 uncovered pairs, so it cannot decide a hop and the
rule still reads only `pageRouteGrants`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…osure

#21908 recorded this pin at 4,324 for the haptics notify module. C2.9
adds two more that the same closure reaches: the page-route-grants schema
and the manifest contract whose grant grammar it imports rather than
restates, both pulled in by `bridge-envelope.ts`, which the page reads to
parse `init`.

Named in the docstring beside #21908's sentence rather than folded into
its number, because the three modules arrived from two PRs and a single
count with one reason invites the next author to assume the rest.

Red first against 4,324: expected 4,326. Measured on this head, not
inferred -- a control worktree at pristine main gives 4,324, so the two
are this branch's.

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 (delta since prior pullfrog review 5263031024 at f3facf1)

  • Refusal prefix pinned by a discriminating case. bridge-host-init.test.ts asserts a malformed pageRouteGrants pair is refused with a pageRouteGrants: prefix and that the diagnostic and the callback carry the same string, with a malformed-route control that must not take the prefix — so the pin cannot hold on any reason at all (a4dc78acb0).
  • Handoff fixtures mirror the manifest's haptics token again. The merged PR E put haptics on all five page routes; the render/unit fixture pairs and the sessions both carry it now, so the subset checks no longer agree by accident (c28271172a, 62bccfd7f7).
  • The route filter left the module's public surface. implementedPageRouteEntries / implementedPageRoutes are module-local now that the reducer reads routeViewOf; the test reads the same list through routeViewOf(...).pageRoutes (7cf2532ef6).
  • Session route closure re-recorded at 4,326. #21908's haptics module plus C2.9's bridge-page-route-grants.ts and manifest-contract.ts, both reaching every page closure through bridge-envelope.ts (1cf1b302b7).
  • Two merges of origin/main bring C7.10 E haptics, C7.10 B mermaid, and #21908; no PR-authored product change in this delta (c3372948e5, 0a6fdb1c90).
  • The contradicted pre-C2.9 predicate one-liner is gone (671bedcd01).

The product rule (servedHere requiring the target's grants to be covered) is unchanged since the reviewed and resolved blocker fix, and the merged haptics token is on both sides of every coverage check, so it cannot decide a hop.

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

@Jinwoo-H
Jinwoo-H merged commit 5d13a70 into main Sep 21, 2026
32 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-c2-9-handoff-grants branch September 21, 2026 05:29
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