Repository navigation
feat(mobile): let the page hand a link to the device through the shell (OTA phase C, C2.3) - #21597
Conversation
…A phase C, C2.3)
A page has no way to open a URL outside itself: `Linking.openURL` is the
app's, and inside the shell the page is a document that cannot reach it. Adds
`notify { name: 'externalLink', url }` and a new grant name of its own in
`MOBILE_WEB_SHELL_GRANTS`, rather than a verb of `navigate` — `navigate`
opens a screen this app carries, this hands a URL to whatever the device
opens it with, and a shell implementing one and not the other is a real shell
the route policy has to be able to describe.
`https:`, `http:` and `mailto:` only, and broad inside that: any host, any
path, because a grant that named GitHub would grow a row per provider. The
rule is parsed rather than prefix-matched, since a scheme is what a URL
parser says it is and `startsWith('https:')` reads one out of
`javascript:alert("https://x")`. It is enforced at the frame as well as at
the page's call site, so a page that skipped its own check still cannot reach
the device handler. Bounded by the route href cap, per the ruling.
`BRIDGE_PROTOCOL_VERSION` is not bumped. Inert until a consumer exists: no
call site and no barrel is touched here.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…hase C, C2.3) The hook's own suite builds its caller options inline, so the new required option made it stop typechecking. `tsc -p tsconfig.json` excludes test files; only the tests-typecheck ratchet saw it. Adds the case that goes with it: a URL the page hands over reaches the caller that can leave the app, and nothing reaches the navigate path. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…phase C, C2.3) `notifyExternalLink(url)` on the page client, gated on the `externalLink` grant and on the same scheme rule the frame enforces. Checked twice on purpose. Nothing crosses back for a notify, so the boolean is the only answer a tap gets: a page that posted a URL the shell's reader then dropped would report "opened" into a frame nobody acted on, which is precisely the dead tap the grant exists to rule out. False before `init`, false after `close`, and never a throw — the callers are tap handlers with no catch around them. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e (OTA phase C, C2.3) One module with a `.web.ts` sibling, which is the shape every platform gap in this bundle already takes. Native is `Linking.openURL` with the rejection swallowed, because every caller is a tap handler and `openURL` rejects for a URL no installed app claims. Web posts the `externalLink` notify after the same scheme check the frame enforces, names its refusals and throws nothing. The opener is published by the entry rather than read from context, for the reason `publishPageStorage` is: the callers are plain functions in render trees the provider does not wrap. A document that published none refuses every URL, which is the right answer for a page with no shell. Registered in `web-overrides.json`: inside the shell's WebView, react-native -web's `Linking.openURL` opens the URL in that WebView and replaces the page rather than handing it to the system browser. No call site and no barrel is touched. The consumer PR swaps them onto this. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…s (OTA phase C, C2.3) The override reason claimed react-native-web's `Linking.openURL` opens the URL in the shell's WebView and replaces the page. It does not. Read from react-native-web 0.21.2: `openURL` calls `window.open(url, '_blank', 'noopener')` and resolves whether or not anything opened; only a `tel:` URL assigns `window.location`, and none of the three allowed schemes is one. The true failure is the worse one and the better argument for the verb. Both shells refuse `window.open` outright, measured in their own sources: iOS sets `javaScriptCanOpenWindowsAutomatically = false` and returns nil from `WKUIDelegate`'s `createWebViewWith`; Android sets the same flag false, calls `setSupportMultipleWindows(false)` and returns false from `onCreateWindow`. So nothing opens, `openURL` resolves anyway, and the native path reports success into a tap that did nothing — precisely the dead tap the grant exists to rule out. The seam's own comment now says the same, so the two files cannot drift. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
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 (7)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe mobile web shell now supports an Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed technical context, implementation details, rationale, and test coverage. However, it does not follow the required template and omits several required sections, including ELI5, Linked Issue, Visual Proof or the required N/A statement, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Restructure the description using the repository template. Add the linked issue number, provide the required visual proof or write exactly
✨ 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 |
The shell swallowed `Linking.openURL`'s rejection. Nothing crosses back to the page for a notify, so an open that failed — a `mailto:` on a phone with no mail account — was silent on both sides. That is the one dead tap this verb does not rule out, and it was the only one with no record at all. Warned with the URL and the error, in the shape the two neighbouring reports in this screen use, and still not rethrown: this runs on the native frame handler. The contract now asks for the report rather than only for the absence of a throw. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… sent (OTA phase C, C2.3) The scheme check reads the protocol through the WHATWG parser, which strips tab, LF and CR from anywhere in a URL and trims leading C0 and space before the scheme is visible. So `ht\ntps://example.com`, `https://example.com/a\r\n`, ` https://example.com/a ` and `https:example.com` all passed the check, and both sides then forwarded the original string. Not a scheme escape — the parser had already decided the scheme — but the device handler was given a URL the check never looked at, which is a dead tap through an allowed URL. `readBridgeExternalLinkUrl` answers the parsed href, and the page posts it and the host forwards it. Normalizing rather than comparing, because `https://example.com` differs from its own href by a path slash: refusing what differs from its normalization would refuse an ordinary URL. The cap now applies to the normalized form as well as the raw string, since percent-encoding expands and a string inside the cap can leave it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ed one (OTA phase C, C2.3) The case named for a document that published no opener published one first, and `post` is module state every earlier case had already set, so the default at the top of the module was never the thing under test. The only assertion was `not.toThrow()`, which passes against any implementation. `vi.resetModules()` and a fresh import, and the refusal reason is asserted. Confirmed to discriminate: flipping the default to `() => true` turns this case red and leaves the other three green. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The case added for a failed open used `mockReturnValue(Promise.reject(failure))`, which builds the rejected promise at setup time. Nothing attaches a handler until the notify frame arrives several awaits later, so the suite reported an unhandled rejection and exited 1 with every test passing — a red run that reads as green in the counts alone. A fresh rejection per call closes the window, and `openUrl` is reset between cases so the mock cannot leak into one that does not expect it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ Minor suggestions only — one test that does not exercise what it claims, and one duplicated scheme list.
Reviewed changes
This run reviewed the full 24-file diff for the new externalLink shell verb (initial review at 643511741c).
- Contract — a new closed-union notify
externalLinkwith its own grant name, mapped intoBRIDGE_NOTIFY_GRANTSandMOBILE_WEB_SHELL_GRANTSso it flows intoinit.grants.native;BRIDGE_PROTOCOL_VERSIONunchanged. - Scheme rule —
isBridgeExternalLinkUrlparses withnew URL().protocolagainsthttps:/http:/mailto:and enforces it in the envelope's zod.refineand in the page'snotifyExternalLink, so a page that skips its own check still cannot reach the device handler. - Host —
forwardNotifyroutes the notify to a requiredonExternalLink, wired inMobileWebShellScreentoLinking.openURL. - Page — native/web seam pair plus the opener published by the web entry, registered in
web-overrides.json. - Tests — caps matrix, host handling (allowed/refused/before-ready/advertised), page client, hook plumbing, both seams.
I independently traced the security path and the mixed-version negotiation and found no bypass and no skew hazard in either direction; the scheme check's correctness rests on Expo's winter runtime installing a WHATWG URL over RN's own non-spec polyfill, which is already assumed elsewhere in the app.
ℹ️ Nitpicks
- The allowed-scheme list now exists in two places —
BRIDGE_EXTERNAL_LINK_SCHEMESinmobile/src/mobile-web-shell/bridge/bridge-caps.ts:95andALLOWED_SCHEMESinmobile/src/components/pr-sidebar/markdown-link-scheme.ts:4— with the same three entries. Worth a shared constant if a future scheme addition should apply to both.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the four commits since the prior pullfrog review at 643511741c, against the full 25-file diff.
- Forward the URL the parser read —
isBridgeExternalLinkUrlbecamereadBridgeExternalLinkUrl, returning the parsedhref; both the page'snotifyExternalLinkand the host'sforwardNotifynow put that href on the wire instead of the caller's raw string, and the normalized form is held to the same 2048-char cap (percent-encoding can expand a string past it). - Report a failed open — the shell's
onExternalLinknow logs a URLLinking.openURLrejected rather than swallowing it, which is the one dead tap this verb otherwise leaves silent. - Tests — host and page normalization, the normalized-form cap, the shell warn, and the default-opener case (the prior inline thread) now assert exact values; the openURL rejection is built per call so no unhandled rejection escapes.
I re-ran the affected mobile suites (7 files, 119 tests) and they pass. I verified the WHATWG normalization and href-idempotency assumptions directly (378k random allowed-scheme inputs, no non-idempotent case), and confirmed the accepted set only narrows — the normalized-form cap is new — so there is no scheme bypass or dead-tap regression from the change.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…A phase C, C2.3) `Linking.openURL` validates before it returns anything: `_validateURL` is an `invariant` that throws for an empty string (react-native 0.83.10, `Libraries/Linking/Linking.js:117-123`). So the seam's `.catch` was attached to a promise that, in that case, never existed, and the throw went straight through a tap handler — contradicting the module's own claim to be safe in one. Both failure modes are now caught and reported, and neither is rethrown. The test double validates the way the real module does, because a mock that only rejects cannot reproduce the failure that escapes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…m (OTA phase C, C2.3) `mobile-pr-url.ts` was the seam's native body already, byte for byte, written before it. It now re-exports the seam under its own name, so the empty-URL guard and the failure report reach its four callers too. Nothing changes natively: the seam's native form is what those callers were running. On the web they would now post the notify instead, which is the behaviour they should have had; it is unreachable today, since none of them is in a page route's closure. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ase C, C2.3) The pair harness grew `externalLinks` and nothing read it. This is the `navigate` twin's shape, over the six normalization inputs: what the page put on the wire and what the shell forwarded are the same strings, read back off the frames rather than recomputed, and nothing reaches the shell's client. Two halves on purpose. The page normalizes before it posts, so over the client the host only ever receives an already-normalized URL and forwarding it raw would pass — the frame injected straight into the host at the end is what holds the host to the rule on its own. Confirmed to discriminate: reverting the host to forward `message.url` turns that assertion red. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…TA phase C, C2.3)
Three of a kind, none behavioural:
- the notify guard's docstring had a 109-character line; reflowed
- the shell's could-not-open warning passed three arguments where the three
other reports in that screen pass two; it now passes `{ url, error }`
- the native seam's suite built its rejection with `mockReturnValue`, which
is the shape `52191bab02` removed elsewhere; it now builds one per call,
through the same double that validates the way the real module does
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the four commits since the prior pullfrog review at 52191bab, against the full 27-file diff.
- Guarded the synchronous
openURLthrow —openExternalLinknow wrapsLinking.openURLin atry/catchalongside the promise.catch, becauseLinking.openURLruns_validateURL(aninvariant) before it returns a promise; an empty URL would otherwise escape the tap handler the seam promises to protect. I confirmed the contract directly against react-native 0.83.10'sLibraries/Linking/Linking.js—openURLis notasyncand validates synchronously, so the guard is reachable and the validating test double is faithful. - Collapsed the duplicate native wrapper —
mobile-pr-url.tsis now a one-line re-export ofopenExternalLink as openMobilePrUrlinstead of carrying its ownLinking.openURLcopy; its four native callers are unchanged. - End-to-end port-pair test —
bridge-rpc-client.test.tsasserts the page posts the normalized href, the host forwards byte-for-byte what the page posted, and a raw frame injected straight into the host is normalized on the host's own side. - Test fidelity and cleanup — the native seam double now validates synchronously like the real module, so the empty-string case is reachable; the shell screen's failed-open warn was reshaped to its neighbours' two-argument form; the notify-guard doc counts
externalLink;MobileWebShellScreen.test.tsxresets itsopenUrldouble per test.
The prior inline thread on the default-opener test is addressed (ad1d4db) and resolved. The security path is unchanged: the accepted set only narrows and there is no scheme bypass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

What this is
OTA phase C, C2.3: the second shell verb of the C2 series. A page has no way to open a URL in whatever the device opens it with: react-native-web's
Linking.openURLcallswindow.open(url, '_blank', 'noopener')and resolves whether or not anything opened (onlytel:assignswindow.location), and neither shell opts intowindow.open: iOS setsjavaScriptCanOpenWindowsAutomatically = falseand itscreateWebViewWithreturns nil; Android sets the same flag false,setSupportMultipleWindows(false), andonCreateWindowreturns false. So the native path reports success into a tap that did nothing, which is the dead tap the grant exists to rule out. This PR gives the page a seam that hands the URL to the shell, and gives the shell the verb to receive it.Independent PR off main (
1ef947394b), not stacked. Inert for released phones (no consumer posts the name yet; the tasks route is native until the C2.1 consumer PR) and for the dev-flagged page (no call site uses the seam yet).What changed, by layer
bridge-envelope.ts,bridge-notify-grants.ts,page-route-policy.ts):notify { name: 'externalLink', url }joins the closed client union, with its own grant name inMOBILE_WEB_SHELL_GRANTS. Not a verb ofnavigate:navigateopens a screen this app carries; this hands a URL to the device, and a shell implementing one and not the other is a real shell the route policy must be able to describe.BRIDGE_PROTOCOL_VERSIONis unchanged. The url is bounded by the envelope's existing href cap.bridge-host.ts,bridge-host-contract.ts,MobileWebShellScreen.tsx,use-mobile-web-shell-bridge.ts): the shell screen callsLinking.openURL. The scheme rule (https:,http:,mailto:only) is parsed withnew URL().protocol, not prefix-matched, becausestartsWith('https:')reads an allowed scheme out ofjavascript:alert("https://x"); a frame carrying a refused scheme never reaches the handler: it dies at the envelope asunrecognised-message, the same way any frame outside the closed union does, and nothing opens.bridge-client-notifications.ts,bridge-rpc-client.ts,src/platform/external-link.tswith its.web.tssibling,web-entry/index.tsx): one seam module. Native isLinking.openURLwith the rejection swallowed (every caller is a tap handler, andopenURLrejects for a URL no installed app claims). Web runs the same parsed scheme check at the call site, so a tap knows it went nowhere, then posts the notify; the shell refuses again on the frame, so a page that skipped its own check still cannot reach the device handler. The opener is published by the entry rather than read from context, matchingpublishPageStorage, because the callers are plain functions in trees the provider does not wrap. The override is registered inweb-overrides.json, whose gate fails on an unlisted.web.*file.What the consumer PR (C2.1) inherits
The seam replaces
Linking.openURLat ten call sites in the tasks page closure: nine undersrc/tasksacross seven files (one more than the design listed,mobile-tasks-provider-item-list.tsx:170), all reachable through themobile-tasks-dependenciesbarrel that re-exportsLinking, so they swap in one line; andMobileMarkdown.tsx:68, which imports react-native directly. The four PR-sidebar andmobile-pr-urlsites root at other screens and are not in the tasks closure by import trace; the closure computation decides.Checks
Mobile tsc, tests-typecheck ratchet, whole-tree oxlint, format, both changed-code gates against main, root
config/scriptssuite (the override gate readsweb-overrides.json), full mobile suite including the bridged parity gate (787 goldens, classes unchanged).Review round 1 (approve; three folds, one declined)
Fresh reviewer at
643511741cran a 40-input scheme matrix (thejavascript:family in every case and encoding,data:,file:,intent:,blob:,tel:, protocol-relative, unparsable and over-cap strings all refused; punycode,user:pass@andmailto:with headers allowed;new URLthrows caught inside the predicate), confirmed the host's check is independent of the page's, confirmed an old shell refuses the frame asunrecognised-messageand drops a route declaring the grant to native, and reproduced red-first per product commit. Folded: (1) a failedLinking.openURLon the shell (amailto:with no mail account) was silent on both sides, the one place the dead tap this PR rules out actually happens; the host now reports it with name and error. (2) The check parsed the URL through the WHATWG parser, which strips tab, LF and CR and trims leading control characters, but the raw string was forwarded; both sides now post and forward the parsedhref, with the cap applied to the normalized form as well (percent-encoding expands). Comparing against the normalization was rejected becausehttps://example.comnormalizes tohttps://example.com/. (3) The "no opener published" test never exercised the module default because earlier tests had published one; it now resets modules and asserts the refusal. Declined: aPromise<boolean>return on the seam; the ten inherited sites do not need it and it changes shape once one does. A fourth commit fixes the lane's own item-1 test, whosePromise.rejectbuilt at mock setup produced an unhandled rejection: a passing count with exit 1.Review round 2 (SHIP WITH NITS, all folded)
Fresh reviewer at
52191bab02ran a 16-input normalization matrix (IDN and punycode, credentials, backslashes, dot segments, encoded dots, default ports, IPv6,mailto:with headers, the four whitespace shapes,https:example.com, uppercase scheme): the posted href equals the forwarded href byte for byte andnew URL().hrefis idempotent on all; a raw string inside the cap whose normalized form leaves it is refused on both sides. Confirmed the round-1 fold's failure mode by restoring the old mock (all tests passed, one unhandled error, exit 1). Findings folded: the port-pair harness collectedexternalLinksand nothing read them, so the page-posts-what-the-host-forwards property is now asserted through the pair, plus a frame injected straight into the host so a host that forwarded raw would fail;mobile-pr-url.tsduplicated the native seam byte for byte and now imports it (its four callers are native routes, so nothing changes for them natively; they inherit the empty-URL guard and the failure report);Linking.openURLvalidates synchronously (invariant(url, 'Invalid URL: cannot be empty')) before returning a promise, so an empty url threw past the.catchand past the tap handler the seam promises to protect; both failure modes are now caught and reported (the test double was replacing the validating module with a plain resolve, so the red needed a validating double first); a 109-character comment reflowed; the failed-open warn matched to its neighbours' two-argument shape; a remaining setup-time rejection made per-call.