Skip to content

feat(mobile): the page reads this host and keeps the app's pins (OTA phase C, C1.4) - #21503

Merged
Jinwoo-H merged 76 commits into
mainfrom
ota-c1-4-storage
Sep 19, 2026
Merged

Jinwoo-H merged 76 commits into
mainfrom
ota-c1-4-storage

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1175 $\color{#cf222e}{\Huge{\mathbf{−}}}$​215 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​960
Prod 32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​715 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​679

What this is

OTA phase C, step C1.4, stacked on C1.3: the page's host identity and storage come from the shell, so the worktree list on the web names the same host and reads the same pins and last-visited repo as the native list. Behind orca:mobileWebShellEnabled and the CI-only app bundle; released phones unchanged; init fields additive; the golden corpus is byte-identical across the whole stack.

How

  • init.host, optional and credential-free (id, name, endpoint, lastConnected). host-store.web.ts serves it; the native writes the page cannot make (updateLastConnected) settle rather than throw. deviceToken and publicKeyB64 are empty strings on the page rather than carried over the wire: the bridge carries the RPC, the page has no use for either, and the module says so.
  • init.storage plus notify { name: 'storage', key, value } behind a new storage grant. page-storage-keys.ts is the allowlist, two keys wide: orca:last-visited-worktree and the orca:pins:<hostId> prefix. The builder aliases AsyncStorage to page-async-storage.ts, which answers reads synchronously off what init primed and posts every accepted write. A key outside the allowlist is refused and not cached locally: keeping it would answer a later read with a value no other screen can see, a pin that looks set and is not.
  • The bridge host is built only once the profile and the stored keys are read, alongside the client, because init is answered once per ready and carries both.
  • Alert.alert on a failed host removal (a silent no-op on RN Web) now sets the list's own error, which exists on both platforms.
  • externalLink stays deferred to C2 per the design ruling, so Linking.openURL in the new-workspace modal remains a dead button on the page until then.

Mutations killed

A read that waits on the shell; a write kept locally after the shell refused it; the five refused key shapes including the bare orca:pins: prefix and the hybrid shell flag itself; a clear() that would empty the app's store; a page that mounts before the profile is read; the render check now asserts the list names the host instead of "Host not found", with a case that still paints not-found when the shell names no host.

Findings for C1.7

expo-router snapshots window.location at import (C1.2), so any later change to mount order must keep replaceState and the location prop in step. With the flag on, the host screen shows the shell's "Checking host" spinner until the status gate settles before it can answer native-route; confirm on device.

Verification

Mobile tsc 0; full mobile suite 668 files / 6849 tests, no golden moved anywhere in the stack; root node tsc clean; app bundle builds and verifies with a reproducible buildId; render check 13/13; ratchet OK; changed-code gate 0 new findings across 62 files; oxfmt, oxlint, anti-slop clean.

Review round 2 (SHIP AFTER FIXES, all taken)

Fresh reviewer at 9fdac6965c confirmed all five round-1 fixes under mutation, then found that one of them introduced a race. MED the first init could carry no storage (the storage and profile reads ran unordered and the host was built on the profile alone) → the host snapshot is gated on both reads; the test holds the store read open past the profile read. MED the mirror was one init stale against a native write (orca:last-visited-worktree from the session screen) → fixed at the synchronous-source boundary: src/storage/mirrored-storage-keys.ts holds the allowlisted keys and every native writer notes its write (writeLastVisitedWorktree is now the single writer), so the init answering a ready already carries it; init stays synchronous. LOW the banner and the catalog auto-clear were unasserted → two rendered tests; deleting either production line fails three. One commit (79516d71) carries both MEDs under a message naming one; recorded here rather than rewritten. HEAD_EFFECT_SHA256 refreshed in the session-route parity test (effect count unchanged at 24).

Main merged (after C0.8 landed)

origin/main a7b9ea5995 merged into every branch of the stack (merge commits, no rebase). The only conflict was the import block of bridge-rpc-client.ts, where C0.8 moved inbound dispatch into bridge-client-inbound-frames.ts and C1.1 moved outbound notifies into bridge-client-notifications.ts; resolved by keeping both factories. Both behaviours are live: the parity harness still classifies 6 goldens as result-absent-stream-release (C0.8's refused-event abandon path) and page faults still flow through the notifications module. Lead-verified per head: tsc, format, both changed-code gates against each PR's base; full mobile suite 6877 (entry) and 7005 (storage); flagged parity 788/788 on storage; root config/scripts 1923/1924 on navigate/storage.

After the merge, bridge-rpc-client-frames.test.ts stood at 835 lines (C0.8 and C1.1 had both added cases) and failed the max-lines lint. Split along the module boundary the two refactors created, no body changes, 48 cases → 37 in the client file, 4 in bridge-client-notifications.test.ts, 7 in bridge-client-inbound-frames.test.ts; the shared fake port moved to bridge-page-client-test-harness.ts. Lead-verified whole-tree oxlint, tsc, format and both gates on all four heads; full suites 6877 / 7005; parity 788; root config/scripts 1924. The split's shared harness first exported INIT as the full BridgeHostMessage union, which the tests-typecheck ratchet caught (INIT.grants no longer narrowed); it is typed as the init variant now, no cast.

…jected (OTA phase C, C1.1)

The Route A entry built no client and mounted the route tree immediately, so the
web provider minted its own: it read the page channel, built `BridgeRpcClient`
and fell back to a placeholder that rejected every call. A tree that mounts
before `init` reads synchronous getters against a client that knows no host, no
state and no build, and the first render it records is the wrong one.

The entry now owns the page's one client. It builds it from the channel at
module scope, mounts nothing until `onReady` fires, and stamps the session and
build ids `getShellSession()` returns on the document beside the mount state, so
a screenshot, the render check and a device console read the same three facts.
`client-context.web.tsx` takes that client by injection and serves it from
`acquire()` for every hostId, because the bridge protocol names no host; the
placeholder and its `BridgeTransportUnavailableError` are gone, along with the
entry that pointed at them in the unvalidated-port inventory.

A document with no channel is not inside the shell, so it says `unbridged` and
stops rather than waiting out a backoff nobody answers. The render check gains a
shell double that answers `ready` with `init`, reads the stamped session back off
the document, and proves the gate is real by opening the same route with no
double and finding an empty `#root`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…OTA phase C, C1.2)

The shell serves its document at `/` and refuses every other path, so the page's
own location matches no route in the tree it carries and expo-router paints
Unmatched. Nothing in the document can tell it otherwise, so the screen has to
cross the bridge.

`init` gains an optional `route: { pathname, params }`. The pathname is held to
what a path may be rather than to what a screen may want: rooted, single-slash,
no query and no fragment. A protocol-relative `//host` would make
`history.replaceState` throw a cross-origin SecurityError and take the mount down
with it, and the params are a field of their own so neither side parses a URL.
The shell route supplies it, the screen passes it to B4's hook, and the hook
holds it for the life of one host: the page routes once, before its first render,
so a route that changed afterwards has nothing left to change.

The page writes that URL into its history and then mounts. It also hands the same
URL to `ExpoRoot` as its `location`, because `ExpoRoot` snapshots
`window.location.href` when its module is imported, which is before any frame has
crossed the bridge: without it the router reads the `/` the shell served and
replaces the page's own path right back. A shell too old to name a route leaves
the page with nothing to open, so it paints a panel saying to update the app,
built as elements outside React because the route tree is exactly what cannot
mount there.

Both platforms stop reading the document's URL to decide a load finished. The
page rewrites its own path before its first render, so a document that committed
at `/` reports finishing at `/h/<hostId>`; reading the path withheld `ready`
forever and left the Android WebView hidden behind it. What is left is whether
the load committed, which is the question the state machine already answers.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… stays native (OTA phase C, C1.3)

The worktree list now renders from the desktop's bundle, and which routes do is
negotiated rather than decided on one side. The manifest gains
`routes: [{ pathname, grants }]`, written from one declared list the builder
checks against the tree it bundled, so a declaration naming a screen with no
module fails the build instead of reaching a phone as a page that paints
Unmatched. The field is additive because the phone reads the manifest loosely and
pins no schema version; the desktop's own writer stays `.strict()`, and the stale
comment saying there was no additive path is corrected.

The shell answers for what it can do. A route the bundle does not list, or lists
needing a grant this app does not implement, settles as `native-route` and
downloads nothing; so does a desktop that ships no bundle at all, which is the
one blocked verdict that is not a wall, because a desktop with no bundle declares
no page route and there is no workspace to refuse. The route is answered before
the compat verdict for the same reason: a bundle this shell cannot open is not a
reason to refuse a screen it was never going to open. `app/h/[hostId]/index.tsx`
mounts the shell when the flag is on and takes the native list back as the
fallback, and both routes read the flag through one hook so the census stays the
whole census.

A tap on a worktree row still opens the native session screen. The page posts
`notify { name: 'navigate', href }` behind the `navigate` grant, which is not a
convention: `notify` is a closed union, so an older shell refuses the whole frame
and the page checks the grant before it posts. The shell pushes the target over
the still-mounted view, so Back reveals the page with nothing reloaded.
`route-handoff.ts` and its web sibling are the seam, router-shaped so the list's
own hook and the recorder's adapter are untouched and no golden moves: the web
file wraps the three members that leave the document and hands back any target
outside the page routes `init` named.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…phase C, C1.4)

Three gaps the census named, and the last of them is why the page needed a second
grant.

`expo-secure-store` is `{}` on web, so the page's own `loadHosts()` answered with
an empty array and the list painted "Host not found" over the host the shell had
just opened it for. `init` gains an optional `host`, and `host-store.web.ts`
serves it: the profile the screens read, with no device token and no public key,
because the bridge already carries the connection those would have opened. The
native writes it cannot make — pairing, renaming, recency — settle rather than
throw, since recency orders a list the page never shows.

AsyncStorage's web build is `window.localStorage`, and the page has none worth
having: Android turns DOM storage off and on iOS the origin host is the session
id, so a pin set in the page was gone on the next remount. The builder aliases
the module to a page store whose values are the app's own — `init` primes the
allowlisted keys, a write is applied locally and posted over a new `storage`
grant, and the app is where it lands. The allowlist is two keys and is the whole
fence: everything the app stores shares one namespace, the hybrid shell flag
included, so a page that could write any of it could turn the feature on for a
build that never offered it. A key outside the list is refused and, crucially,
not kept locally either — a pin that looks set and is not is the failure the
grant exists to avoid.

The bridge host is built only once both have been read, because `init` is
answered once per `ready` and carries them: a host that started without them
would have to be torn down to carry them, and the list would already have mounted
against a host it could not name.

`Alert.alert` on a failed host removal is a silent no-op in React Native Web, so
inside the page that failure had no surface at all. It routes to the error the
list already shows, on both platforms.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A page that throws where it renders has nowhere to report it: the shell
sees a document that loaded and a view that never painted, so it waits
on a blank page forever. This adds the one frame that says so.

`notify { name: 'fault' }` carries the capture an `error` frame already
carries, so both directions share one bound and one reader. It rides a
grant because `notify` is a closed list on both sides: a page served by
a newer desktop into an older shell would have the whole frame refused,
so the page asks `init.grants.native` first and stays quiet on a no.

The shell answers it as `document-load-failed`, which is what happened.
That reason drops the generation and downloads once, so a page broken
by bytes this host has since replaced recovers, and one broken by its
own code stops at the failure screen rather than a blank one.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…rs their own modules

The fault report took both files over the 300-line cap, so each gives up
the group that was already separable. The page's one-way members move to
`bridge-client-notifications.ts`, which is also where the two policies
that split them can be stated: the two the native contract declares throw
before a session, and the fault report never throws at all. The host's
three error classes move to `bridge-host-errors.ts`, the mirror of the
page's own `bridge-client-errors.ts`.

No behaviour changes. The commit before this one is over the cap on its
own, which a forward-only history is the reason to say rather than hide.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ell (OTA phase C, C1.1)

Nothing in `app/h/**` exports an `ErrorBoundary` and `ExpoRoot` provides
no global one, so a throw while a route renders — or a route module that
rejects once the manifest is lazy — unmounts the tree and leaves a blank
document. The shell sees a load that finished and waits on it forever.

The entry now wraps what it mounts on `init` in one boundary that posts
the throw over the bridge. Above `ExpoRoot`, not inside its wrapper: a
route that cannot be resolved throws where the router renders it, and a
boundary below the router never sees that.

It renders nothing and offers nothing to press. The generation is on disk
and was hash-checked before the view loaded it, so the same bytes throw
again and a retry here would only throw twice; recovery belongs to the
shell, which drops the generation on the report.

The render check now grants the fault and collects what the page posts
into the errors every case already asserts empty, because a throw the
boundary caught paints nothing and logs nothing a `pageerror` listener
would hear.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
C1.5's lazy per-route manifest against C1.1's bootstrap-on-init. Two files
conflicted and both keep each side's intent.

`web-entry/index.tsx`: the wrapper stays a factory over the page's client
and the mount stays behind `init`; main's note about suspense is kept and
extended, because a route chunk that never arrives rejects rather than
suspends and that is the new boundary's, not suspense's.

`mobile-web-app-render.test.mjs`: main split the page open from the wait
and added a client-navigation check; this keeps that split, gives
`openPage` the shell double behind a flag so the unbridged case reuses it
rather than building a second page, and folds the page's fault reports
into the errors every case already asserts empty.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
C1.1's page fault boundary and C1.5's lazy manifest, over C1.2's routing.
Every conflict is an addition on both sides and keeps both.

The boundary now wraps the `ExpoRoot` that C1.2 hands a `location`, and
the "Update Orca" panel stays outside it: that path is built from DOM
nodes rather than rendered, so nothing it paints can reach a boundary.

The render check keeps C1.2's open-at-`/` shape and gains main's split
between opening a page and waiting for a route. `openPage` now takes the
shell route, so the two cases that never mount a tree reuse it instead of
building a second page, and the client-navigation check starts at `/` and
lets the page route itself, the same as every other case here.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Every source conflict is an addition on both sides. `init` now grants
`fault` alongside what the routes negotiate, with the protocol's own grant
first because no route declares it; the bridge host takes `onPageFault`
beside `onNavigate`; and the page client's notifications module keeps
C1.3's shared `post` for the three that throw before a session, with the
fault report reading the session instead, since its caller is a boundary.

`BridgeHostDisposedError` now has one home: C1.3 moved it into
`bridge-host-requests.ts` and C1.1 into `bridge-host-errors.ts` beside the
other two, which is the mirror of the page's own errors module, so the
requests module imports it from there.

C1.5 moved the route-manifest and RequireContext suites into their own
file, so this keeps only the page-route declarations here. The build now
takes those declarations as an option: they name screens in the real route
tree, and C1.5's reproducibility check bundles a synthetic one.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Additions on both sides again: `init` grants `fault` alongside `navigate`
and `storage`, the bridge host takes `onPageFault` beside `onStorageWrite`,
and the page's notifications module gains the fault report beside the
storage write.

The render check's `openPage` now carries the host and the storage the
double answers with, so `render` and the two cases that never mount a tree
all install one double rather than three. The route each case waits on is
the host row now that `init` names a host, which is the string the page
paints once it has one.

`bridge-host.test.ts` went over the 800-line test cap, so its fixture moves
to `bridge-host-test-harness.ts` and the notification suite to
`bridge-host-notifications.test.ts`. Split by concern, not by line count:
the notifications are the frames that answer nothing.

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

React may replay or discard a render, so the write belongs in the commit phase. Layout,
not passive, and declared above the host's effect: a native frame can arrive between a
commit and a passive effect, and the host must already hold this render's callback.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The page-fault ref write moved into a commit-phase effect; kept beside this
branch's snapshot read.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Same class as the page-fault ref: render must stay pure because React can replay or
discard it. Folded into the one commit-phase effect above the host's.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The route ref write moved into the commit-phase effect; this branch's own refs are
left as they were, and move next.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Same class again: the last two writes this branch adds join the commit-phase effect, so
nothing this hook holds is written while React is rendering.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The route, page-route and navigate ref writes moved into the commit-phase effect; this
branch's storage-write ref is left as it was, and moves next.

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

A `useState` setter is stable, so the identity of the callback is unchanged; the list now
says what the body reads. Reported on the line this branch rewrote.

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.

Important

Two removal-path issues worth addressing before merge: the Alert.alert → setError swap defeats the confirm re-open and replaces the native list, and the page's host removal is a silent no-op. The rest is minor.

Reviewed changes

  • Host identity over the bridge: init.host carries the credential-free profile so host-store.web.ts can answer loadHosts()/loadHostCatalog() where expo-secure-store is {}, fixing the list's "Host not found" over a real host.
  • App storage over the bridge: a new storage grant, the two-key allowlist in page-storage-keys.ts, and page-async-storage.ts aliased over @react-native-async-storage/async-storage — init primes reads, writes post notify{name:'storage'} and are only cached when the writer accepts.
  • Snapshot before the host is built: usePageHostSnapshot reads the host plus allowlisted keys natively and gates useMobileWebShellBridge on a non-null snapshot, so init is answered once with both.
  • Removal failure surface: use-host-worktree-actions.ts replaces the RN-Web no-op Alert.alert with setError.
  • Test coverage: bridge-host.test.ts split into a harness plus a notifications file; the render check now asserts the list names the shell's host and adds a no-host not-found case.

ℹ️ Nitpicks

  • usePageHostSnapshot/writePageStorage — the native read that decides what the page is handed, and its write-back — has no direct test; MobileWebShellScreen.test.tsx mocks it, so the filter/prime path is only covered indirectly by the browser render check.

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

/** Pairing happened natively before this document existed, and the page never re-does it. */
export const saveHost = (_host: HostProfile): Promise<void> => Promise.resolve()
export const saveExistingHostRelayUpgrade = (_host: HostProfile): Promise<void> => Promise.resolve()
export const removeHost = (_hostId: string): Promise<void> => Promise.resolve()

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.

The page reaches handleRemoveHost (via AuthFailedBanner when the connection is auth-failed or pairing-rejected), but this resolves without removing anything, and unregisterPushForRemovedHost is inert on the page, so removeHostAndCloseClient never rejects and the new setError catch is unreachable. The user is handed to the native home screen while the host stays paired and reopenable. If removal is deliberately deferred for the page, say so here (the saveHost/updateLastConnected no-ops carry comments; this one does not) and in the web-overrides.json reason.

Technical details
# Page host removal is a silent no-op

## Affected sites
- `mobile/src/transport/host-store.web.ts:30` — `removeHost` resolves without mutating anything.
- `mobile/src/host-screen/use-host-worktree-actions.ts:144-158` — `handleRemoveHost` treats that resolution as success and calls `leaveHost()`.
- `mobile/src/transport/host-removal-lifecycle.ts:10-19` — only the native `removeHost` mutates the stored profiles / schedules keychain cleanup.

## Required outcome
- Either the page's removal is routed to the shell (so the host is actually removed), or the action is disabled on the page and the deferral is documented.

Comment on lines +35 to +38
export function updateHostNameAndEndpoint(
_hostId: string,
_name: string,
_endpoint: string

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.

This mirrors the native name but not its shape: the native sibling is (hostId, { name?, endpoint? }) (host-store.ts:301) and its only caller passes the object (app/h/[hostId]/edit.tsx:111). TypeScript checks callers against the native declaration while the browser runs this one, so a future real implementation would silently receive an object as _name. Matching the native signature keeps the override a drop-in.

`createBridgePortPair` is generic over the shell client now; the fake-client form this
test wants is `createFakeBridgePortPair`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…hase C, C1.1)

A route module that throws while the bundle is evaluated takes the entry with it. The
document still commits and the WebView still reports it loaded, but no boundary mounts,
no fault is posted and no frame is ever sent, so the session sat in `ready` behind a
blank view forever.

The native view's finished load starts a clock; the page's first `ready` stops it;
expiry is `document-load-failed`, which deletes the generation and fetches once. Nothing
cancels the timer — a `ready` that lands first makes the expiry a no-op — so the runner
owns a clock and the reducer owns every decision.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e boundary reports

The check folded page faults into its errors but nothing ever produced one, so a boundary
that stopped reporting would have stayed green. The server now serves one real route
chunk with a throw in front of it: the module still links, so the failure is an
evaluation throw where the router renders, which is exactly what the boundary is for.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…hing before ready

`forwardNotify` acted on any frame that parsed, including a `fault` from a page that had
never asked for a session and therefore held no grant. Both refusals now go through one
rule the host shares with the frame it sends, so the list a page is told about and the
list it will be served cannot drift.

Inert while every page is offered `fault`; the ungranted arm is what C1.3 needs the
moment a grant belongs to a route rather than to the protocol.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The C1.1 batch: the ready deadline, the throwing-route render case and the host
refusing an ungranted or pre-ready notify. The init frame builder C1.1 extracted now
carries this branch's route, and C0.5's harness test names one.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e WebView (OTA phase C, C1.2)

`sendInit` put `options.route` straight on the wire and only the page's decoder checked
it, so an out-of-contract pathname made the page refuse the whole `init`, ask again on
its 2 s backoff forever, and the shell un-hide a view that would never paint. The only
trace was a `console.warn` inside the WebView.

Three changes, one failure mode. The host parses the route at construction and serves no
session at all when it will not do, reporting it as a shell failure. The pathname rule
refuses empty segments, dot segments and backslashes anywhere, because `replaceState`
normalises `/../../etc` to `/etc` and `/h/a\b` to `/h/a/b` and the page then renders
whatever came out. And the producer encodes the host id it interpolates, which is how
one carrying a query, a fragment or whitespace got there.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The route refusal, the shared pathname rule and the encoded host id. The href pattern
now starts from the same path definition the `init` pathname does, and the init frame
builder carries this branch's page routes and grants.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The app's own writers had to reach into `src/mobile-web-shell/` to note a write, which is the
dependency the wrong way round: the shell is what is built on the app's storage, not the other way.
The mirror moves to `src/storage/` and no longer knows which keys the page is allowed; the caller
names them on every read and every seat, so the allowlist stays where it is enforced. No behaviour
change.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Both sides refactored `bridge-rpc-client.ts` away from each other: C0.8 moved
the inbound dispatch into `bridge-client-inbound-frames.ts`, C1.1 moved the
outbound notifies into `bridge-client-notifications.ts`. The conflict was the
import block only, and neither side's block was correct on its own.

The types import is C1.1's (no `ForegroundNudgeReason`: `notifyForeground` now
lives in the notifications module) and the caps import is main's (no
`utf8ByteLength`/`BridgeRefusal`: the frame reader owns both now). Both factory
imports are kept, because the merged body calls both.

C0.8's refused-`event` path is untouched — the reader still routes it to
`BridgeClientSubscriptions.abandon`, which posts `cancel` before notifying — and
C1.1's `notifyPageFault` still spreads in off the notifications factory.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Import-block conflict only. C1.2 moved `BridgeShellSession` and its reader into
`bridge-client-session.ts` on the same line C0.8 used for the extracted
`BridgeRpcClientDiagnostic`. Both imports are kept; the merged body calls
`readShellSession` and re-exports the diagnostic type.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
No conflicts: C1.3 touches the navigation surface, not the bridge client's
import block, so the C0.8 resolution carried forward unchanged.

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 — the storage-mirror rework and its tests look right; one latent read-path note inline.

Reviewed changes

Since the prior pullfrog review (9fdac69), this delta reworks how the shell reads the app's stored keys, adds the two rendered tests the prior review flagged as missing, and fixes one diagnostic branch:

  • Storage mirror: mobile-web-shell/page-storage-mirror.ts becomes src/storage/mirrored-storage-keys.ts, a module-level map every native writer notes as it writes. savePinnedIds and writeLastVisitedWorktree (now the single writer of the last-visited key) call noteMirroredWrite, so the synchronous init carries the app's value as it stands rather than one read behind; usePageHostSnapshot hydrates the map before building the snapshot and reads it synchronously.
  • Both-reads gate: usePageHostSnapshot now waits on the storage hydrate and the host profile together before setting the snapshot, closing the race where a profile that beat the store primed the page from an empty map. MobileWebShellScreen's onPageReady re-seats the map after answering.
  • Refused-write diagnostic: bridge-diagnostic-log.ts names the key for storage-refused instead of falling through to the view-outlived line.
  • Tests: host-workspace-list-action-error.test.tsx renders the failure banner and its dismiss; host-worktree-catalog-action-error.test.ts asserts a confirmed catalog clears actionError while a failed request leaves it standing; use-page-host-snapshot.test.tsx covers the write-during-read guard and the both-reads gate.
  • Merge: ota-c1-3-navigate (with main/C0.8) merged in; the bridge-rpc-client.ts conflict keeps both the inbound-frame reader and the notifications factory.

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

for (const [key, value] of pairs) {
// What was asked for and nothing else: the answer is what a reader is served, so a store that
// returned a key it was not asked about must not put one in the map.
if (!keys.includes(key)) {

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.

The refactor replaced the old isPageStorageKeyForHost(key, hostId) guard with keys.includes(key), which no longer applies the PAGE_STORAGE_MAX_KEY_CHARS bound that guard carried. Because pageStorageKeysForHost always appends orca:pins:${hostId}, a host id long enough to overflow the cap is now seated here and handed to the page in init.storage, which the envelope refuses — so the whole init is dropped and the page never mounts, where the old code simply left that key out. The write path (isPageStorageKeyForHost) still refuses the same key, so read and write now disagree about it.

Technical details
# Hydrate seats a key the envelope will refuse

## Affected sites
- `mobile/src/storage/mirrored-storage-keys.ts:51` — `keys.includes(key)` replaced `isPageStorageKeyForHost(key, hostId)`, dropping the `PAGE_STORAGE_MAX_KEY_CHARS` bound.
- `mobile/src/mobile-web-shell/use-page-host-snapshot.ts:52,112` — passes `pageStorageKeysForHost(hostId)`, which always appends `orca:pins:${hostId}` regardless of length.
- `mobile/src/mobile-web-shell/page-storage-keys.ts:53` — the write path still enforces the bound, so read and write disagree for the same key.
- `mobile/src/mobile-web-shell/bridge/bridge-envelope.ts:149` — `BridgeInitStorageSchema` refuses a key over the cap, taking the whole `init` with it.

## Required outcome
- Every key `hydrateMirroredStorage`/`readMirroredStorage` is given is one the envelope's `isPageStorageKey` also admits, so an over-long host id loses its own pins rather than the whole frame.

## Suggested approach
- Filter the keys through `isPageStorageKeyForHost` before handing them to the hydrate/read, or bound the derived key where `pageStorageKeysForHost` builds it (the latter is the open thread on `page-storage-keys.ts:53`).

## Open questions for the human
- Can a host id ever exceed the 256-char cap? If not, this stays latent and the fix is only about keeping the two paths consistent.

…e created

`bridge-rpc-client-frames.test.ts` reached 835 counted lines once C0.8 and C1.1
both added cases to it, over the 800 the lint allows. The split follows the two
modules those changes extracted, so each suite now names the module it covers.

`bridge client page faults` moves to `bridge-client-notifications.test.ts` (the
outbound notify surface) and `bridge client refusals and send failures` to
`bridge-client-inbound-frames.test.ts` (the reader, including the refused-event
release that cancels at the shell). The seven suites that exercise the client as
a whole stay put. The fake port all three drive moves to
`bridge-page-client-test-harness.ts` rather than being copied three times.

No case changed and none was dropped: 48 `it` cases before, 37 + 4 + 7 after,
and all nine `describe` bodies compare byte-identical to their originals.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The harness exported `INIT` as `BridgeHostMessage`. While it was a module-local
const, control flow narrowed it to the `init` member at each use, so
`INIT.grants` read fine. An imported binding keeps its declared type instead, so
the same read lost `grants` to the union and the tests ratchet went red.

Declared as the init member, which is what every case already treats it as. No
cast: the object literal is checked against the narrower type directly.

`INIT` was the only exported fixture with this shape. `CONNECTION` is `as const`,
`GRANTS` is inferred, and nothing reads a member off an `eventFrame` result.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Main carries C1.1 as one squash (d043cfb) while this branch carries C1.1's
original commits, so every hunk C1.2 laid on top of C1.1 conflicted. Merged with
`-X ours`: the branch side is already C1.1 plus C1.2, so it is the correct side
of every one of those conflicts.

Nothing was resolved by hand, and the merge altered none of this branch's own
work: of the 115 files it brought in from main and the 32 this branch owns
against main, the intersection is empty, and `mobile/src/mobile-web-shell` is
byte-identical to the pre-merge head.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Main carries C1.2 as one squash (b8f3b1e) while this branch carries its
original commits, so the hunks C1.3 laid on top conflicted. Merged with
`-X ours`: the branch already contains C1.2 plus C1.3, so it is the correct side.

Nothing resolved by hand. The merge brought in 7 files, the branch owns 56
against main, and the intersection is empty; `mobile/src/mobile-web-shell` is
byte-identical to the pre-merge head.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@Jinwoo-H
Jinwoo-H changed the base branch from ota-c1-3-navigate to main September 19, 2026 01:54
Main carries C1.3 as one squash (ac4dc65) while this branch carries its
original commits, so the hunks C1.4 laid on top conflicted. Merged with
`-X ours`: the branch already contains C1.3 plus C1.4, so it is the correct side.

Nothing resolved by hand. The merge brought in 7 files, the branch owns 51
against main, and the intersection is empty; `mobile/src/mobile-web-shell` is
byte-identical to the pre-merge head.

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

📝 Walkthrough

Walkthrough

The mobile web bundle manifest now carries validated page routes. The bridge exchanges route patterns, host metadata, and host-scoped storage. The shell renders supported routes and falls back to native screens for unsupported routes. Navigation can cross from the page to the native shell. Host action failures now use an in-screen failure banner. Tests cover bundle building, bridge behavior, route negotiation, storage synchronization, and native fallback behavior.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to b661e

Some shell navigation and fallback paths can hang, reject existing bundles, or display the wrong cached page. These material compatibility and routing issues should be fixed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives detailed technical context, user impact, implementation details, and verification results. However, it omits required template sections, including Linked Issue, Visual Proof or a… Add the missing required sections. Include a valid issue reference under Linked Issue, attach before/after visual proof or write N/A with a reason, complete the Testing and checklist items, and address AI Disclosure, Review, Agent skill ups…
Docstring Coverage ⚠️ Warning Docstring coverage is 58.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 50 files. (33 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the mobile web change: the page receives host information and preserves app pins. It is concise and related to the primary implementation.
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.
Full details: Description check

Explanation

The description gives detailed technical context, user impact, implementation details, and verification results. However, it omits required template sections, including Linked Issue, Visual Proof or an explicit N/A justification, the checklist, and several review sections.

Resolution

Add the missing required sections. Include a valid issue reference under Linked Issue, attach before/after visual proof or write N/A with a reason, complete the Testing and checklist items, and address AI Disclosure, Review, Agent skill upstream boundary, and Notes as applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 58.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 50 files. (33 skipped: 1 unsupported, 32 over the file limit.)

✨ Finishing Touches 💡 3
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch ota-c1-4-storage
🛠️ Fix failing CI checks 💡
  • 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: 7

Caution

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

⚠️ Outside diff range comments (2)

🟠 Major · Validate cached routes before the transport fallback opens them. · mobile-web-shell-session.ts:252

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

Validate cached routes before the transport fallback opens them.

The manifest can list the current route while session.cached belongs to an older build that does not list it. If the new download fails with transport, Line 252 opens the old generation without checking cached.routes. The session also retains pageRoutes from the new manifest.

This can open the wrong cached page instead of returning to the native route. Apply the same cached-route decision used by onCacheRead.

Proposed fix
   if (failure === 'transport' && cached !== null) {
-    return openCached(session, cached)
+    const pageRoutes = implementedPageRoutes(cached.routes)
+    return rendersRoute(pageRoutes, session.routePathname)
+      ? openCached(session, cached, { pageRoutes })
+      : step(session, { pageRoutes, state: NATIVE_ROUTE })
   }
🟡 Minor · Keep host-removal failures separate from catalog refreshes. · use-host-worktree-catalog.ts:83-87

mobile/src/host-screen/use-host-worktree-catalog.ts:83-87
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep host-removal failures separate from catalog refreshes.

handleRemoveHost reopens the confirmation modal and stores the removal failure in actionError. A failed removeHostAndCloseClient call does not forget the client, and catalog refreshes continue every three seconds without checking confirmRemoveHost. A confirmed worktree.ps response therefore can reach this branch before the user retries. It confirms catalog reachability, not host-removal success.

Remove the unconditional setActionError(''). Keep the removal failure in actionError until the removal action succeeds or the user dismisses it. Let catalog state remain owned by catalogError.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1c37ac88-aa13-4681-adf8-e8d158a4e12d

📥 Commits

Reviewing files that changed from the base of the PR and between ac4dc65 and f7ab162.

📒 Files selected for processing (83)
  • config/scripts/build-mobile-web-app-bundle.mjs
  • config/scripts/build-mobile-web-app-bundle.test.mjs
  • config/scripts/build-mobile-web-bundle.mjs
  • config/scripts/build-mobile-web-bundle.test.mjs
  • config/scripts/mobile-web-app-render.test.mjs
  • config/scripts/mobile-web-app-route-manifest.mjs
  • config/scripts/mobile-web-bundle-serializer-parity.test.mjs
  • config/scripts/mobile-web-page-routes.mjs
  • mobile/app/h/[hostId]/index.tsx
  • mobile/app/h/[hostId]/index.web.tsx
  • mobile/app/h/[hostId]/web.tsx
  • mobile/app/h/_layout.tsx
  • mobile/src/components/HostRouteNoticeBanner.tsx
  • mobile/src/host-screen/HostScreen.tsx
  • mobile/src/host-screen/host-screen-action-error.test.tsx
  • mobile/src/host-screen/host-workspace-list-action-error.test.tsx
  • mobile/src/host-screen/host-workspace-list.tsx
  • mobile/src/host-screen/host-worktree-catalog-action-error.test.ts
  • mobile/src/host-screen/use-host-screen-controller.ts
  • mobile/src/host-screen/use-host-screen-state.ts
  • mobile/src/host-screen/use-host-worktree-actions.ts
  • mobile/src/host-screen/use-host-worktree-catalog.ts
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-diagnostic-log.test.ts
  • 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-init.test.ts
  • mobile/src/mobile-web-shell/bridge-host-notifications.test.ts
  • mobile/src/mobile-web-shell/bridge-host-requests.ts
  • mobile/src/mobile-web-shell/bridge-host-test-harness.ts
  • mobile/src/mobile-web-shell/bridge-host.test.ts
  • mobile/src/mobile-web-shell/bridge-host.ts
  • mobile/src/mobile-web-shell/bridge/bridge-caps.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-notifications.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-session.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-init-frame.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client-frames.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts
  • mobile/src/mobile-web-shell/bridge/page-async-storage.test.ts
  • mobile/src/mobile-web-shell/bridge/page-async-storage.ts
  • mobile/src/mobile-web-shell/bridge/page-host-profile.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-flag-census.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-gates.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session-contract.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.ts
  • mobile/src/mobile-web-shell/page-route-policy.test.ts
  • mobile/src/mobile-web-shell/page-route-policy.ts
  • mobile/src/mobile-web-shell/page-storage-keys.test.ts
  • mobile/src/mobile-web-shell/page-storage-keys.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-enabled.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-session.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-session.ts
  • mobile/src/mobile-web-shell/use-page-host-snapshot.test.tsx
  • mobile/src/mobile-web-shell/use-page-host-snapshot.ts
  • mobile/src/navigation/route-handoff.ts
  • mobile/src/navigation/route-handoff.web.test.tsx
  • mobile/src/navigation/route-handoff.web.ts
  • mobile/src/navigation/route-href.ts
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/session/use-mobile-session-keyboard-state.ts
  • mobile/src/storage/mirrored-storage-keys.ts
  • mobile/src/storage/preferences.ts
  • mobile/src/transport/client-context.web.tsx
  • mobile/src/transport/host-store.web.test.ts
  • mobile/src/transport/host-store.web.ts
  • mobile/src/transport/mobile-web-bundle-reply-schemas.ts
  • mobile/src/transport/unvalidated-rpc-request-port-inventory.ts
  • mobile/src/worktree/last-visited-worktree-repo.ts
  • mobile/web-entry/index.tsx
  • mobile/web-entry/web-overrides.json
  • src/main/runtime/rpc/methods/mobile-web-bundle.test-fixture.ts
  • src/shared/mobile-web-bundle/bundle-rpc-contract.test.ts
  • src/shared/mobile-web-bundle/manifest-contract.test.ts
  • src/shared/mobile-web-bundle/manifest-contract.ts

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

totalBytes: assets.reduce((total, asset) => total + asset.byteLength, 0),
assets
assets,
routes

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the shared manifest schema and fixtures for absent-route compatibility.
rg -n -C5 \
  'MOBILE_WEB_BUNDLE_SCHEMA_VERSION|routes:|routes\)|\.default\(\[\]\)|manifest.*parse' \
  src/shared/mobile-web-bundle mobile/src/transport config/scripts

Repository: stablyai/orca

Length of output: 50369


Preserve schema-version-1 compatibility for manifests without routes. MobileWebBundleManifestSchema requires routes and does not define a default. A runtime that parses an existing version-1 manifest without this field can reject it. Add .default([]) to the routes schema, or increment MOBILE_WEB_BUNDLE_SCHEMA_VERSION.

return (
<MobileWebShellScreen
hostId={hostId}
route={{ pathname: `/h/${hostId}` }}

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 | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'hostId|id:.*host|HostProfile|host.*schema|randomUUID|uuid' mobile/src mobile/app src/shared | head -n 240
sed -n '1,60p' 'mobile/app/h/[hostId]/index.tsx'
sed -n '1,70p' 'mobile/app/h/[hostId]/web.tsx'

Repository: stablyai/orca

Length of output: 28199


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- HostProfile and host ID declarations ---'
rg -n -C 4 'interface HostProfile|type HostProfile|HostProfileSchema|host profile|hostProfile|id: z\.|id\?:|ExecutionHostId|parseExecutionHostId' mobile/src src/shared mobile/app
printf '%s\n' '--- Host persistence and pairing producers ---'
rg -n -C 5 'loadHosts|saveHosts|storeHosts|hosts.*AsyncStorage|AsyncStorage.*host|pair.*host|attempt.*pair|result.*hostId|hostId.*result|id.*endpoint|endpoint.*id' mobile/src mobile/app
printf '%s\n' '--- route contract and consumers ---'
rg -n -C 5 'useLocalSearchParams|useGlobalSearchParams|pathname.*\[hostId\]|/h/\$\{|hostRouteWithNotice|encodeURIComponent\(hostId\)' mobile/app mobile/src | head -n 500
printf '%s\n' '--- relevant file sizes ---'
wc -l mobile/src/transport/types.ts mobile/src/transport/host-store.ts mobile/app/pair-confirm.tsx mobile/app/_layout.tsx mobile/app/h/_layout.tsx 2>/dev/null || true

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- declarations ---'
rg -l 'export (interface|type) HostProfile|interface HostProfile|type HostProfile|HostProfileSchema' mobile/src src/shared mobile/app
rg -l 'resolveHostIdentity|function resolveHostIdentity|const resolveHostIdentity|loadHosts|saveHost' mobile/src/transport mobile/src | head -n 80
printf '%s\n' '--- exact declaration matches ---'
rg -n -m 30 -C 8 'export (interface|type) HostProfile|interface HostProfile|type HostProfile|HostProfileSchema' mobile/src/transport src/shared
printf '%s\n' '--- host store symbols ---'
rg -n -m 80 -C 8 'loadHosts|saveHost|resolveHostIdentity|metadata\.host|hostIdentity' mobile/src/transport/host-store.ts mobile/src/transport/pre-profile-pairing-coordinator.ts mobile/src/transport/*identity* mobile/src/transport/*profile* 2>/dev/null || true
printf '%s\n' '--- pairing coordinator identity flow ---'
sed -n '120,165p' mobile/src/transport/pre-profile-pairing-coordinator.ts
sed -n '245,285p' mobile/src/transport/pre-profile-pairing-coordinator.ts
printf '%s\n' '--- route construction and parameter usage ---'
rg -n -m 120 -C 3 'pathname: `/h/\$\{hostId\}|href=\{`/h/\$\{hostId|/h/\$\{encodeURIComponent\(hostId\)|useLocalSearchParams' mobile/app/h mobile/src/host-route* mobile/src/host-screen mobile/src/transport | head -n 500

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- types and schemas ---'
sed -n '88,145p' mobile/src/transport/types.ts
printf '%s\n' '--- host metadata parser ---'
sed -n '1,75p' mobile/src/transport/host-metadata-store.ts
printf '%s\n' '--- host store load/save and identity resolver ---'
rg -n -C 12 'resolvePairingHostIdentity|function toStoredHostProfile|function doLoadHostListSnapshot|HostProfileSchema.parse|toStoredHostProfile' mobile/src/transport/host-store.ts
printf '%s\n' '--- route sites ---'
nl -ba 'mobile/app/h/[hostId]/index.tsx' | sed -n '16,35p'
nl -ba 'mobile/app/h/[hostId]/web.tsx' | sed -n '16,52p'
printf '%s\n' '--- route parameter contract references ---'
rg -n -C 5 'useLocalSearchParams|decodeURIComponent|URLSearchParams|dynamic segment|hostId.*decoded|decoded.*hostId' mobile/app mobile/src | head -n 240

Repository: stablyai/orca

Length of output: 29735


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- MobileWebShellScreen route consumer ---'
rg -n -C 10 'routePathname|route\.pathname|MobileWebShellScreen|fallback' mobile/src/mobile-web-shell mobile/app/h/'[hostId]'
printf '%s\n' '--- route/session validation ---'
rg -n -C 8 'pathname|routePath|rendersRoute|implementedPageRoutes|BRIDGE_ROUTE|native-route|page refuses|invalid.*route' mobile/src/mobile-web-shell | head -n 400

Repository: stablyai/orca

Length of output: 50369


Encode decoded host IDs before constructing route paths.

HostProfileSchema and StoredHostProfileSchema accept any non-empty ID, and resolvePairingHostIdentity preserves existing stored IDs. A reachable host ID can therefore contain /, ?, #, %, or similar characters. useLocalSearchParams returns the decoded value.

Raw interpolation at mobile/app/h/[hostId]/index.tsx:29 and mobile/app/h/[hostId]/web.tsx:47 can split the path, create a query or fragment, or re-decode a percent escape. The shell or fallback redirect may then target a different route instead of /h/<hostId>.

Use encodeURIComponent(hostId) at both route construction sites.

Comment on lines +71 to +72
export const BRIDGE_ROUTE_HREF_PATTERN = new RegExp(
String.raw`^${ROUTE_PATH_SOURCE}(?:\?[^#\s]*)?$`

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

Reject a final dot segment before a query.

The shared lookahead treats only / and end-of-input as segment boundaries. The new href pattern therefore accepts /h/..?x and /h/%2e%2e?x.

Add ? as a dot-segment terminator and add query-bearing test cases.

Proposed fix
-export const BRIDGE_ROUTE_SEGMENT_SOURCE = String.raw`(?!(?:\.|%2[eE]){1,2}(?:/|$))[^/\\?#\s]+`
+export const BRIDGE_ROUTE_SEGMENT_SOURCE = String.raw`(?!(?:\.|%2[eE]){1,2}(?:/|\?|$))[^/\\?#\s]+`

Based on learnings: URL path patterns must reject unintended near-match paths.

🧰 Tools
🪛 ast-grep (0.45.3)

[warning] 70-72: Do not use variable for regular expressions
Context: new RegExp(
String.raw^${ROUTE_PATH_SOURCE}(?:\?[^#\s]*)?$
)
Note: [CWE-1333] Inefficient Regular Expression Complexity. Security best practice.

(regexp-non-literal-typescript)

Source: Learnings

Comment on lines +72 to +79
notifyNavigate: (href) =>
deps.hasGrant('navigate') &&
post({ v: BRIDGE_PROTOCOL_VERSION, type: 'notify', name: 'navigate', href }),
// The page's writes reach the app's own store, which is the only store it has: its `localStorage`
// is off on Android and per-session on iOS, so a pin kept there would forget itself on remount.
notifyStorageWrite: (key, value) =>
deps.hasGrant('storage') &&
post({ v: BRIDGE_PROTOCOL_VERSION, type: 'notify', name: 'storage', key, value }),

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:

#!/bin/bash
set -euo pipefail

ast-grep outline mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts --items all
rg -n -C 5 'hasGrant|requireSession|notifyNavigate|notifyStorageWrite' \
  mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts \
  mobile/src/mobile-web-shell/bridge/bridge-client-notifications.ts

Repository: stablyai/orca

Length of output: 14856


Preserve the before-init notification contract. hasGrant evaluates session?.grants.native.includes(name) === true, so it returns false before init. The short-circuit then skips post(), and requireSession() never throws as documented. Call requireSession() before each grant check in notifyNavigate and notifyStorageWrite.

setState(sessionRef.current.state)
return invalidate
}, [hostId, invalidate, runtime])
}, [hostId, invalidate, routePathname, runtime])

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Dispatch the current gates after a route-only reset.

A routePathname change recreates the session at Line 179. The gates effect does not include routePathname in its dependencies. If the host and gate values stay unchanged, the new session receives no gates-changed event and remains in checking.

Add routePathname to the gates effect dependency list. The reset effect is declared first, so it will recreate the session before the gates effect dispatches.

Proposed fix
   }, [
     dispatch,
     hostCapabilities,
     hostId,
     hostProtocolWindow,
     reachability,
+    routePathname,
     statusPending,
     statusReadable
   ])

export function writeLastVisitedWorktree(record: LastVisitedWorktreeRecord): void {
const value = JSON.stringify(record)
noteMirroredWrite(LAST_VISITED_WORKTREE_STORAGE_KEY, value)
void AsyncStorage.setItem(LAST_VISITED_WORKTREE_STORAGE_KEY, value)

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle the AsyncStorage.setItem rejection.

void discards the promise, so a failed write produces an unhandled rejection and no signal. The mirror at Line 61 already reports the value as written, so the page keeps serving a value the store never received.

Attach a rejection handler so the failure is at least logged.

🛡️ Proposed fix
-  void AsyncStorage.setItem(LAST_VISITED_WORKTREE_STORAGE_KEY, value)
+  AsyncStorage.setItem(LAST_VISITED_WORKTREE_STORAGE_KEY, value).catch((error: unknown) => {
+    console.warn('last-visited worktree write failed', error)
+  })

Based on learnings, a mirrored write should not be reported as complete independently of the persistence outcome.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
void AsyncStorage.setItem(LAST_VISITED_WORKTREE_STORAGE_KEY, value)
AsyncStorage.setItem(LAST_VISITED_WORKTREE_STORAGE_KEY, value).catch((error: unknown) => {
console.warn('last-visited worktree write failed', error)
})

Source: Learnings

Comment on lines +211 to +213
/** Outside `buildId`, which hashes the assets alone. The routes are derived from the same
* source tree the script asset is built from, so identical assets are identical routes. */
routes: z.array(MobileWebBundleRouteSchema).max(MOBILE_WEB_BUNDLE_MAX_ROUTES)

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect bundle identity creation and every cache or generation decision that consumes it.
rg -n -C5 \
  'computeMobileWebBundleId|manifest\.buildId|\bbuildId\b|\.routes\b' \
  config mobile/src src/main src/shared

Repository: stablyai/orca

Length of output: 50370


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 15592


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate definitions ---'
rg -n -C4 'computeMobileWebBundleId|MOBILE_WEB_BUNDLE_MAX_ROUTES|routes:.*MobileWebBundleRouteSchema|buildId.*assets|assets.*buildId' src mobile config
printf '%s\n' '--- session cache decision ---'
sed -n '130,215p' mobile/src/mobile-web-shell/mobile-web-shell-session.ts
printf '%s\n' '--- generation store implementation ---'
rg -n -C3 'function createGenerationStore|stageGeneration|commitGeneration|readActiveGeneration|buildId' mobile/src/mobile-web-shell/generation-store.ts
printf '%s\n' '--- fetch/download pipeline ---'
rg -n -C4 'MobileWebBundleFetchResult|fetch.*Manifest|read-manifest|download.*manifest|manifest\.routes|stageGeneration|commitGeneration' mobile/src/mobile-web-shell mobile/src src/shared

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- manifest contract ---'
sed -n '1,245p' src/shared/mobile-web-bundle/manifest-contract.ts
printf '%s\n' '--- identity references ---'
rg -n -C5 'computeMobileWebBundleId' src mobile config
printf '%s\n' '--- buildId comparisons in non-test source ---'
rg -n -C4 'buildId\s*===|===\s*.*buildId|manifest\.buildId|buildId:' mobile/src --glob '!*.test.*'
printf '%s\n' '--- generation store symbols ---'
rg -n -C8 'export function createGenerationStore|stageGeneration|commitGeneration|readActiveGeneration|manifest\.json|buildId' mobile/src/mobile-web-shell/generation-store.ts
printf '%s\n' '--- fetch and manifest flow symbols ---'
rg -n -C6 'MobileWebBundleFetchResult|read-manifest|download-manifest|manifest\.routes|stageGeneration|commitGeneration|fetch.*Manifest' mobile/src/mobile-web-shell --glob '!*.test.*'

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

set -euo pipefail
rg -n -C5 'computeMobileWebBundleId|manifest\.buildId|buildId\s*===|stageGeneration|commitGeneration|readActiveGeneration|manifest\.routes|generation\.routes' src mobile config --glob '!*.test.*'

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- builder route and manifest construction ---'
rg -n -C10 'routeKeys|routes|grants|manifest\s*=' config/scripts/build-mobile-web-app-bundle.mjs config/scripts/build-mobile-web-bundle.mjs
printf '%s\n' '--- route derivation helpers ---'
rg -n -C8 'implementedPageRoutes|MobileWebPageRoute|pageRoutes|grants' mobile/src/mobile-web-shell src/shared/mobile-web-bundle --glob '!*.test.*'
printf '%s\n' '--- cache-hit activation and bridge inputs ---'
sed -n '70,180p' mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
sed -n '100,190p' mobile/src/mobile-web-shell/mobile-web-shell-session.ts

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

set -euo pipefail
rg -n -C10 'routeKeys|routes|grants|manifest\s*=' config/scripts/build-mobile-web-app-bundle.mjs config/scripts/build-mobile-web-bundle.mjs
rg -n -C8 'implementedPageRoutes|MobileWebPageRoute|pageRoutes|grants' mobile/src/mobile-web-shell src/shared/mobile-web-bundle --glob '!*.test.*'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- declared page routes ---'
cat -n config/scripts/mobile-web-page-routes.mjs
printf '%s\n' '--- route policy and grant consumers ---'
rg -n -C10 'implementedPageRoutes|grants|pageRoutes|route.*grant|grant.*route' mobile/src mobile/app src/shared config/scripts --glob '!*.test.*'
printf '%s\n' '--- init grant assembly ---'
rg -n -C12 'createBridgeInitFrame|BRIDGE_NATIVE_GRANTS|grant' mobile/src/mobile-web-shell/bridge --glob '!*.test.*'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

set -euo pipefail
cat -n config/scripts/mobile-web-page-routes.mjs
rg -n -C10 'implementedPageRoutes|grants|pageRoutes|route.*grant|grant.*route' mobile/src mobile/app src/shared config/scripts --glob '!*.test.*'

Repository: stablyai/orca

Length of output: 50370


Include route metadata in the bundle identity. computeMobileWebBundleId hashes only assets, while MOBILE_WEB_PAGE_ROUTES supplies route grants separately. A grant-only change can therefore keep the same buildId. The cache-hit path does not rewrite the stored manifest, and the offline path reads generation.routes; a newly granted route can remain native until the asset identity changes and the cache refreshes. Include canonical route metadata in the bundle identity.

@Jinwoo-H
Jinwoo-H merged commit e2afb5e into main Sep 19, 2026
31 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-c1-4-storage branch September 19, 2026 02:20
Jinwoo-H added a commit that referenced this pull request Sep 22, 2026
…fest accepted (OTA phase D, finding 7) (#22175)

* refactor(mobile): share the generation store's in-memory disk

The fake answers the file-system port the store is written against, and the
offline-grant suite drives the same real store against it. Two in-memory trees
answering one port differently is how a passing suite stops being evidence.

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

* test(mobile): an offline cold start reads the grants of the last manifest accepted

Finding 7 on #21503 end to end: the reducer, the runner, the real generation
store and a disk, with only the network and the platform modules doubled. A
grant-only edit keeps the bundle's build id, so the cached assets are right
under a manifest an edit behind; the verdict measured here belongs to a second
mount whose whole evidence is the tree on disk.

Both directions of the edit and both arms: a widened grant list reaches the
offline verdict, a revoked one is gone from it, and a manifest read under a wall
is not written, so offline keeps the last grants this shell could use.

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

* fix(mobile): name the extracted fake's type at its import

The store suite still spelled the local type name. `tsconfig.json` excludes test
files, so only the tests-typecheck ratchet sees this.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
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