Repository navigation
fix(mobile): open long sign-in links, and offer Copy link where the phone can't - #51303
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…hone can't The page-to-shell bridge capped external links at the route href's 2048 characters, so an OAuth page with a long scope list (PostHog's is 3594) was refused with only a console warning: Open sign-in page did nothing. Links now go up to 16 KiB on shells that advertise externalLinkLong; on older shells the sign-in shows Copy link for the same attempt.
… a stale copy error
…nd require each caller's link limit
f7058d2 to
3bb1f26
Compare
ELI5
On the phone, adding some apps to an agent (PostHog, for one) showed an "Open sign-in page" button that did nothing when tapped. The phone app limits how long a web address it will open, and PostHog's sign-in address is longer than that limit. Phones on the next app build open these long addresses. Phones on today's build show "Copy link" instead, so you can paste the address into your browser and finish signing in.
What Changed
Mechanism:
BRIDGE_MAX_EXTERNAL_LINK_CHARSis now 16 KiB and no longer reuses the route href cap (2048). The bridge frame limit is 640 KiB.externalLinkLongcapability inBRIDGE_SHELL_GRANTS. The page reads it at init (bridgeExternalLinkMaxChars) and publishes that limit with its link opener, socanOpenExternalLink/openExternalLinkand theexternalLinknotify never send a shell a link longer than it accepts.readBridgeExternalLinkUrlnow requires the limit, so no page caller can fall back to the larger cap by accident.usePhoneToolSignIn) getsuseSignInLinkCopy. It returns whether the attempt's page can open on this phone, plus a clipboard copy whose result is tied to that attempt's link./h/[hostId]/mcpdeclaresnative.clipboard.writeas optional. On a shell without it, Copy link reports that it couldn't copy.Long links opening directly needs a store build of Orca Mobile. Until then the page falls back to Copy link on installed phones.
Why
Root cause: the page-to-shell bridge capped external links at the route href's 2048 characters. That limit was set when the bridge first let pages hand links to the device ("bounded by the route href cap"). It was borrowed from navigation, never sized for real links. MCP sign-in asks for every scope a server lists, as the MCP spec says, and PostHog's scope list alone is 2,927 characters, so its authorize URL is 3,594. The page refused the link with a console warning and the sign-in page ignored the refusal. Installed shells enforce the same 2048 at the frame, so a page-only change would still do nothing on today's phones.
Of the 16 catalog apps I measured, only PostHog is over the limit today (Atlassian is next at 1,585). Any provider with a long scope list hits it, though, and so does a URL from Add by URL.
Alternatives considered:
externalNavigationprecedent and needs no new init field.Linked Issue
Fixes #48342
Visual Proof
Flow: Agent › Connectors › PostHog › Sign in. Simulator captures are an iOS 27 simulator paired with a dev desktop built from this branch.
Before (main): tapping "Open sign-in page" or "Open page again" opens nothing; the phone stays on this screen.
(screenshot removed: contained real product data)
After, on today's store build (light, then after Copy link). While the link has to be copied, step 1 reads "Copy the link below and open it in your browser."; normal shells keep "Sign in to {app} and allow access.":
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
Same, dark:
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
The chat's tool-added card on today's store build (Copy link, then Copied):
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
The sign-in page and card shots above are the real components and hook rendered in Chromium at phone width with a scripted host (a 2,758-character link at today's store-app limit); the card needs a live bot agent turn to appear in a real chat. The other shots are from the simulator.
The copied link pasted into Safari opens PostHog's real sign-in page:
(screenshot removed: contained real product data)
After, with this branch's shell (the next store build): "Open sign-in page" opens PostHog directly. The sign-in screen itself looks the same as before.
(screenshot removed: contained real product data)
Testing
Reproduced on fresh main in an iOS simulator against a hidden dev desktop. Both "Open sign-in page" and "Open page again" opened nothing for PostHog. Vercel opened Safari as expected.
With this branch's page on today's store shell (0.0.71), Copy link appeared and showed Copied, and the link pasted into Safari loaded PostHog's sign-in.
After the step 1 copy change, rendered the real sign-in page and tool-added card (with their hook) in Chromium against a scripted host: Copy link and Copied in light and dark.
With this branch's shell (its JS swapped into the installed app), "Open sign-in page" opened PostHog directly in Safari.
Measured the authorize URL length for each catalog app through
bots.tools.signIn.starton the dev host.pnpm check:changed, mobile typecheck, and the focused tests that load changed modules pass.Not run: Android. The fallback and the link limit are shared TypeScript, used the same way by both shells.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
No test added. The fix is a negotiated limit plus UI fallback, proven end to end on a device. A unit test would only pin the constant.
Performance
None, because the only new work is one memoized URL parse when a sign-in attempt's link changes, plus one clipboard write per Copy link tap. There are no timers, subscriptions or new requests, and an idle tool card does nothing. Init frames carry one extra capability name (about 19 bytes).
Risk
Level: Low
The riskiest part is the bridge limit across mixed versions:
native.link.openparams, host notify) accepts up to 16 KiB.If something goes wrong, long links on new shells could still be refused, and users would see Copy link or the old dead button. A plain revert undoes everything; nothing is persisted.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)