* Agent message cards keep their sender's agent icon when the agent can't be found A card names its sender by a snapshot written with the message, but drew the icon only from a live lookup, so a sender the lookup missed (a worker on another host, a terminal after restart, a closed agent) showed "?". Every writer (worker start, mail, task, federated start) now saves the sender's agent kind beside its name, and the card draws it when no live row names the agent. Live rows stay the source of icon and status whenever they match. * Preserve known worker agents on federated cards and mail * Resolve agent message senders through shared host identity * Retain acquired worker launch identity for later sender snapshots * Prune repeated worker sender contract checks * Combine worker command contract projection imports * Keep sender identity bounded and scoped per worktree - A worktree removal frame drops only its own scope; a host stays publishing once any frame carried the field. - Identity history rebuilds follow writes to the facts it reads (connection-local triggers), not heartbeats, read marks or receipts; new mail is read incrementally. - One principal per paired peer replaces every federated route ever made. - Unchanged worktrees keep their scope object; a refresh republishes only worktrees whose scope changed. Chat records key on the store's state generation instead of serialising every record. - The publication rides client frames only, and phone frames drop it. - A failed history read keeps the last good publication and is not marked indexed; malformed rows are skipped; opening the database for display never throws. - A located chat keeps its tab's agent icon for cards saved without one. * Save each agent card's sender identity and open the pane it names Orca now records who sent each agent message and created each task when it accepts them, and the chat card resolves that saved identity against what each host says runs now. The avatar dot, label and click all read that one answer: a located terminal opens through the sidebar's own activation path, a closed chat reopens through its lineage, and a sender no host can prove shows its saved icon and says it is no longer available instead of opening whichever agent now holds the old pane. Publication now has the host's pairing key from the RPC server, so it no longer fails on every build. * Resolve agent card senders by the terminal handle every card saves A card's sender is now the terminal its saved handle names, the worker lineage its Dispatch continued into, or its chat session. That survives a normal restart, works with hooks off, from a plain shell and for replies, and needs no newly saved sender data, so the hook-conversation records, their table and the saved identity key are gone. The avatar, link and click read one answer. A terminal that now runs a different kind of agent than the card saved, or a sender two places claim, shows the saved icon as a plain name. A terminal that exited or was respawned keeps the host's own lookup on click without a status dot, behind one switch. Chat senders rebuild only when a chat appears, moves, clears or closes, and each live pane's worker reads go through the existing partial indexes. * Send sender identity once per revision and judge every host by one rule The host's sender publication now carries an in-memory epoch and content revision that move only when what clients read changes. A window's graph sync sends the revision it applied and gets "unchanged" instead of the rows; each session-tab stream sends a worktree's scope once per revision. The window keeps the whole-host publication as its baseline and a newer worktree scope over it, by revision, so a delayed reply never undoes a newer scope and repeated deliveries cost nothing. An older paired host's cards now go through the same resolution as everyone else's: a terminal that runs a known different agent shows the saved icon as a plain name, and what the host's lookup returns is judged by the same row. Pi and OMP, and Claude and its teams wrapper, count as one agent. Failure text names the agent and says what to do. WSL chats are published, closed chat history no longer counts as open before the tab table exists, and paired principals are read again only after a pairing changes. * CI: keep the sender delivery contract test out of the web project and fix its types The cross-process delivery test moves to tests/e2e, where tests that span main and renderer live, so the web typecheck no longer pulls main files in. It now drives the stream encoder main uses. The worker lineage walk takes a reader type without a this binding, the stream delta composes with the proof delta's own frame type, alias buckets accept terminal and chat tab arrays, and the publication test builds fully typed fixtures. * CI: share the dispatch-address link rule and align the merged view test with saved-kind icons The base's worker command contract test reads the shared rule that a dispatch: address is never a link; the card's link check now calls that shared rule instead of repeating it. The base's sender view test expected a different agent's live row to replace the saved icon; this branch shows the saved kind without that row's status, so the test asserts that. * Use the sender snapshot resolver in main's new receiving-account tests * Read a saved "unknown" agent kind as no kind for the card's icon and its replaced check A hooks-off agent whose last status came from a terminal report without an app id saves the kind "unknown". That kind proved nothing, yet it vetoed the live agent in its own terminal: the card showed "?" with no dot as a plain name, and a raced click said another agent was running there. One shared read now treats it as no saved kind for the veto and the icon, on every path. * Apply a frame's sender scopes when the window receives it, ordered by each scope's own revision A stream counts a sender scope as sent once a frame carries it, but the window applied it only inside the tab apply, behind the tab version, resume census, receipt recovery and frames-draw checks. A frame those checks dropped could hold the only copy, so a paired host's cards stayed on stale rows (no dot while the sidebar showed the agent) until that worktree's senders changed again. Each receipt path now folds the frame's sender scopes in right after its connection, pairing and runtime checks; the tab apply keeps only a worktree's removal. A scope now also yields to that scope's own newer delivery, not only to a newer whole-host baseline, so a delayed list reply can't put back older rows. Every publishing host stamps a revision, so the content-comparison path for unrevisioned publications is gone. * Read chat senders from open chats and their /clear predecessors, not every saved chat Each chat tab opened or closed, chat created or moved, or /clear committed rebuilt the chat senders by listing every saved chat (42 ms at 10,000 on the main thread) only to keep the open ones. The record store now keeps an in-memory reverse of the saved /clear pointer, built at load and updated for the rows each commit writes; nothing new is saved. The sender read starts from the open chats and follows that index to their predecessors, so its work no longer grows with closed history. * Walk live terminals once per session-tab inventory or broadcast, not once per worktree A one-shot inventory or a broadcast built every worktree's frame through its own sender refresh, and each refresh walks every live terminal: 20,000 visits for 1,000 terminals over 20 worktrees. Both passes now build their frames from one refresh. The publisher counts its leaf and terminal visits, and a test drives the real inventory and broadcast methods at 100 and 1,000 terminals. * Re-read a tab bucket's sender aliases only when a host it read changes The window's sender aliases were recomputed for every open tab whenever any workspace-owner input changed, such as switching workspaces or writing a setting, though a bucket reads those inputs only through one host per worktree. Each bucket now keeps the host values it read and, when owner inputs move, checks just those before reusing its aliases. The delivery contract test counts alias work through workspace switches, settings writes and a title-only change. * CI: restore the single-frame builder declaration and compare sender content without its revision R4 swapped the inventory's abstract single-frame declaration for the batch one, but the headless browser-tab emit and the runtime-owned terminal create still build one worktree's frame through it; both keep the per-frame sender scope. The publisher's content comparison now takes publications without their revision stamp, which R4 made required. * CI: give the sender no-op test's heartbeat a fixed timestamp instead of the wall clock The heartbeat only has to be a write that changes no sender identity, so a fixed time keeps the assertion and satisfies the flaky-test gate. * CI: assert one terminal walk per orchestration RPC and no identity reads in the sender refresh test R4 added leaf and terminal visit counts to the publisher's work counters, and each orchestration RPC's refresh walks the live terminals once, so the whole-counter comparison failed. The test now compares history, chat and lineage reads, unchanged, and asserts exactly one walk per RPC. * CI: reach the sender pass methods through a typed view of their prototypes The test read the runtime's protected inventory and broadcast methods with Reflect.get and an object-typed owner. It now names the three methods it drives in narrow types over their real prototypes and calls them on the same stand-in; the assertions are unchanged. * CI: list every sender target kind in the link switch and merge the duplicate sender-type import The link check's switch now names the ambiguous and replaced kinds, which return false as the default did; the publisher imports its sender types from one statement. * Skip a paired host's floating-terminal sender scope at receipt, as the tab apply does Applying sender data on receipt took a paired host's floating-terminal scope that the window never mirrors, so its sender drew as a link whose click activated a pane this window lacks and did nothing. The receipt now uses the tab apply's own floating rule for paired hosts: that sender opens by asking its host, as before. This machine's own floating terminal still publishes. * Read /clear predecessors through the record store's existing successor index The sender's chat read reached each open chat's /clear predecessors through an in-memory reverse index the record store built at load and kept per commit. The store already has an indexed query for that link, which its lineage read uses; the sender now shares that query and checks each candidate on its conversation, so branching, unreadable and cyclic predecessors resolve as before, and the second index and its commit bookkeeping are gone. * Keep live workers' sender history between builds and re-read only what a write reaches Any write to a Dispatch, worker terminal or remote attachment re-read the history of every live terminal (three queries and the lineage reads per pane) on the main process: about 20 ms at 100 live workers and 150 ms at 1,000, for a write none of them read. The connection's triggers now also record the panes and Dispatch ids a write's old and new rows name. The history keeps each live pane's reads and each Dispatch's verdict with every key it read, lookups that found nothing included, so a write re-reads only the panes and lineages it reaches. Federated Dispatches move their own counter, so worker writes no longer re-read paired principals. A commit from another connection, which no trigger sees, still rebuilds everything. * CI: build each sender trigger from a typed event list so its SQL parts are plain strings * CI: give startup runtime fakes the sender peer-key setter and drop new test type assertions for typed fixtures * Ask the host to reveal a located sender this window holds no tab for, as the lookup did before * Keep no worker history read inside an open transaction, and forget workers and keys no live pane reaches * Test that sender names render only when what they show changes * CI: pass the sender target's dispatch id explicitly and write a real sidebar body in the delivery test * Read terminals' existing handles for sender rows instead of issuing them The sender publication walked every live terminal through the runtime's handle-issuing functions, so each display build could mint, adopt or rebind terminal handles. During a renderer reload or a split close that changed which handle a terminal held and what retirement frames published. Sender rows now read only the handles terminals already hold; a terminal with no issued handle has no row, and no card can name it. * Open a located sender's own pane through its host when this window has no tab for it When a card's sender was found in a pane this window had not loaded yet, the click asked the host about the card's saved terminal instead. For a worker reopened by a follow-up, that opened its first terminal, or said the pane was gone, while the card showed the reopened worker running. The click now opens that same pane: by the handle its status row holds on that host, else by asking the host for that pane in the host's own coordinates. It checks the card again after the host answers, and a closed pane says the agent is no longer running. The saved-address lookup stays only for senders no host has located. * Read a terminal's start-time handle for its sender row while no window graph exists When the window graph went away, the host cleared its handle records but kept each terminal's start-time handle, which its agent's mail cards save as the sender. The read-only handle lookup required a record, so the running terminal lost its sender row and its cards showed no dot until a window came back. It now returns the handle issuing would reuse, record or not, and still changes nothing. * CI: type the open helper's target as any runtime target so the paired-host case typechecks * Lease the sidebar rows a sender name's link check reads, as its avatar does A sender name drawn without an avatar (queued mail, a card's later senders) checked for a different agent through a source nothing leased, so every store write rebuilt that worktree's sidebar rows. The name's link now holds the same lease the avatar does, and a card with no saved agent kind skips the row read entirely. * Index a build's terminal handle records once instead of scanning them per terminal The read-only handle lookup fell back to a scan of every handle record for each leafless terminal holding no handle, on every sender build. A build now gets one reader that indexes the records on its first miss and answers each terminal from that index, with the same handles issuing reuses. * Lease a replaced card's sidebar rows from where its sender runs before the kind check A card whose terminal now runs a different agent resolved no location, so it leased no row source and rebuilt its worktree's rows on every store write. Both the avatar and the link now lease from the candidate location the kind check reads; their answers are unchanged. * Show a paired host's worker status dot on its card when this window mirrors the whole tab A paired host names a pane <tab>:<leaf>; this window mirrors that tab whole as web-terminal-<tab> with the leaf ids kept, and its status rows use that key. The alias projection mapped only per-pane mirrors, so the card located the host's key and found no row to draw a dot from. The terminal bucket now also maps a whole-tab mirror's host tab, and a host pane takes this window's name from either form; two names for one pane still locate neither. * Publish a chat sender change even when the terminal read in the same refresh fails The chat rows and their key were stored before the terminal read; when that read threw, nothing was published, and the next build saw both keys as handled, so the chat change waited for an unrelated identity change. The refresh now publishes whatever changed beside the last good terminal rows, and the read's error still reaches the build's warning. * Bound sender projection work to current consumers and lineage facts * Update runtime call assertions for sender demand options * Preserve mobile sender navigation availability
Orca Mobile
React Native companion app for Orca. Monitor worktrees, view terminal output, and send commands from your phone.
Local development uses two processes:
- Orca desktop/Electron from the repo root. This hosts the mobile WebSocket RPC server on port
6768. - Expo Metro from
mobile/. This serves the React Native app on port8081.
Unless a command says otherwise, run mobile app commands from the mobile/ directory.
The Node commands pnpm rpc:diff and pnpm rpc:record use a development dependency linked to ../src/packages/process-host. Mobile's install supplies the link, and tsx runs its source with the orca-source condition, so these command wrappers do not require a desktop install or package build. Keep that source directory in sparse checkouts. The recording suites still need root dependencies when they exercise desktop modules. The React Native app does not import this host package.
Prerequisites
- Node.js 24+
- pnpm
- Xcode and/or Android Studio tooling for simulator or device builds
- Expo Go on your phone, or a development client build when native modules are needed
- Phone and desktop on the same LAN when testing a physical phone
Start Desktop Orca
From the repository root:
pnpm install
pnpm dev
Confirm the mobile RPC server is listening:
lsof -nP -iTCP:6768 -sTCP:LISTEN
Restart pnpm dev after changing Electron main-process code. Metro hot reload only applies to the mobile JavaScript bundle.
Start The Mobile App
cd mobile
pnpm install
pnpm start
Scan the Expo QR code with your phone's camera on iOS, or Expo Go on Android.
For a native dev-client build:
pnpm native ensure ios # or: pnpm native ensure android [--device <name|udid|serial>]
pnpm start --dev-client
ensure computes the Expo fingerprint of the native inputs (native dependencies, config plugins,
modules/, patches/, and the Expo config). On a HIT it installs the cached build on the booted
simulator or the running emulator in a few seconds. On a MISS it regenerates ios/ or android/,
runs expo run:<platform>, and caches the result. --rebuild forces a fresh build.
Builds are cached per fingerprint in the user cache directory (~/Library/Caches/orca-mobile/native-builds
on macOS, $XDG_CACHE_HOME/orca-mobile/native-builds on Linux, %LOCALAPPDATA%\orca-mobile\native-builds
on Windows, or ORCA_MOBILE_NATIVE_BUILD_CACHE_DIR), so every worktree reuses them. The newest three
per platform are kept. app.config.js also registers the cache as Expo's buildCacheProvider, so a
plain pnpm ios / pnpm android installs a cached build instead of compiling. Only ensure writes to
the cache, because expo run reuses an existing ios/ or android/ directory even when it was
generated from older inputs. Expo caches iOS Simulator builds only, not physical devices.
pnpm native fingerprint prints the current hashes. On pull requests, the Mobile native fingerprint
job reports in its summary whether the PR changes them, which means dev clients need a native rebuild.
Pair With Desktop Orca
- Open Orca desktop.
- Go to Settings > Mobile.
- Scan the pairing QR code from the mobile app.
- Confirm the mobile host endpoint is
ws://<desktop-ip>:6768.
For the Android emulator, use ws://10.0.2.2:6768. For a physical phone, use the desktop LAN IP, for example ws://192.168.0.179:6768.
If the phone has a stale host entry, remove it from the app and pair again.
Development Paths
Android Phone
- Install Expo Go from Google Play
- Run
pnpm start, scan QR with Expo Go - For native modules:
pnpm exec expo run:android - Run with
pnpm start --dev-client
iOS Simulator
- Install Xcode from the App Store
- Run
pnpm start --iosto open in iOS Simulator
Physical Phone Debugging
The phone can be inspected through the connected device tooling:
orca snapshot --json
orca click --element @e3 --json
orca fill --element @e1 --value "ls" --json
orca screenshot --json
Use snapshot first to find the current element refs, then click/fill those refs. After mobile file edits, Metro usually hot reloads automatically, but navigating out of and back into the session screen can be useful because it re-runs terminal.subscribe.
Terminal Streaming Repro Without A Phone
Use this when terminal output does not render on device and you need to split server streaming bugs from WebView/UI bugs:
cd mobile
ORCA_MOBILE_WS_URL=ws://127.0.0.1:6768 pnpm exec tsx scripts/test-subscribe.ts <deviceToken> <serverPublicKeyB64>
You can pass a worktree selector as the third argument:
pnpm exec tsx scripts/test-subscribe.ts <deviceToken> <serverPublicKeyB64> "id:<worktreeId>"
pnpm exec tsx scripts/test-subscribe.ts <deviceToken> <serverPublicKeyB64> "path:/absolute/worktree/path"
pnpm exec tsx scripts/test-subscribe.ts <deviceToken> <serverPublicKeyB64> "name:my-worktree"
The expected result includes:
streamSawMarker: true
readSawMarker: true
If this repro fails, debug the desktop runtime/PTY path before the mobile WebView. If it passes but the phone is blank, debug the session screen or TerminalWebView readiness/queueing path.
Terminal Color Repro Without A Phone
Use this when terminal colors disappear after switching tabs. Open a Claude Code terminal and at least one other terminal in the target worktree, then run:
cd mobile
ORCA_MOBILE_WS_URL=ws://127.0.0.1:6768 pnpm exec tsx scripts/repro-terminal-colors.ts \
<deviceToken> <serverPublicKeyB64> "id:<worktreeId>"
The script captures terminal.subscribe snapshots in an A → B → A sequence and writes raw snapshots to mobile/terminal-color-repro/. If the two A snapshots have different sgrColor counts, the desktop snapshot changed during the switch. If they match, the ANSI color data is still present and the bug is in mobile replay/rendering.
Validation
Run these checks before committing mobile terminal changes:
cd mobile
pnpm exec tsc --noEmit
pnpm run check:tests-typecheck
pnpm lint
cd ..
pnpm typecheck:node
tsc --noEmit reads tsconfig.json, which excludes test files so Metro never bundles them.
tsconfig.test.json puts them back, and pnpm run typecheck:tests shows their errors in full.
check:tests-typecheck is the gate over it: a ratchet against tests-typecheck-baseline.txt, the
127 test files that do not typecheck yet. It fails when a file that checks today stops checking,
and when a baseline entry starts checking (prune it with
node scripts/check-tests-typecheck-ratchet.mjs --prune). The list may only shrink.
The same gate censuses the program first: every *.test.ts(x) on disk must be in it, or named in
the script's TESTS_OUTSIDE_PROGRAM with a reason. Without that, a test excluded from
tsconfig.test.json — or a Foo.test.tsx shadowed by a Foo.test.ts beside it, which a wildcard
include drops for the higher-priority extension — would leave the ratchet silently.
Localization
UI copy goes through src/i18n, with the same call shape and languages as desktop:
- In components and hooks:
const t = useMobileTranslation(), thent('area.thing.label', 'English text'). The function changes with the language, so list it in memo and callback dependencies. - In helpers and imperative code (alerts, notifications):
translate(key, fallback, options)fromsrc/i18n/mobile-i18n, called when the text is shown, never at module scope. - Counts:
count === 1 ? t('x.files_one', '{{count}} file', { count }) : t('x.files_other', '{{count}} files', { count }). - Dates and numbers: pass
getUiIntlLocale()toIntlformatters instead ofundefined. - Keep identity separate from display text: never compare or key on a translated string.
Run pnpm sync:mobile-localization from the repo root to add new keys to src/i18n/locales/en.json;
other catalogs may lag and fall back to English. pnpm verify:mobile-localization and
pnpm verify:mobile-localization-coverage run in CI. iOS permission prompts live in locales/<lang>.json.
Protocol Version Compatibility
Mobile and desktop talk over a versioned protocol. Because mobile updates lag desktop by 24-48h via the App Store, both sides exchange version numbers on status.get so a genuinely incompatible combo can hard-block instead of silently misbehaving.
Constants live in two files (Metro can't resolve outside mobile/):
src/shared/protocol-version.ts—DESKTOP_PROTOCOL_VERSION,MIN_COMPATIBLE_MOBILE_VERSIONmobile/src/transport/protocol-version.ts—MOBILE_PROTOCOL_VERSION,MIN_COMPATIBLE_DESKTOP_VERSION
Today all four are set so evaluateCompat always returns { kind: 'ok' } — nothing blocks. The wire format is in place to flip a switch when needed.
When to bump
Bump DESKTOP_PROTOCOL_VERSION (and the mobile mirror MOBILE_PROTOCOL_VERSION when relevant) for breaking changes:
- Removed RPC method or required parameter that mobile uses
- Changed meaning (units, nullability) of an existing field mobile reads
- Changed encryption, framing, or auth handshake
Do not bump for additive changes:
- New RPC methods
- New optional fields on existing methods
- New event types in
terminal.subscribe
Set MIN_COMPATIBLE_MOBILE_VERSION (kill-switch) when desktop ships a change that requires a minimum mobile version to function safely. Same for MIN_COMPATIBLE_DESKTOP_VERSION from the mobile side.
When a verdict is blocked, mobile/src/components/ProtocolBlockScreen.tsx renders a screen pointing the user at the update that clears it. When mobile is too old it opens the newest release if the installed app's update check knows one, otherwise the App Store (iOS) or GitHub Releases (Android). When desktop is too old it opens GitHub Releases.
To exercise the block screen locally: set MIN_COMPATIBLE_DESKTOP_VERSION = 999 in mobile/src/transport/protocol-version.ts, rebuild, pair to any desktop. Revert before merging.
Mock Server
Develop the mobile app without a running Orca desktop instance:
pnpm mock-server # starts mock WebSocket server on port 6768
Connect from the app using endpoint ws://localhost:6768 and token mock-device-token.
Environment variables
MOCK_NATIVE_CHAT=1— serve the native-chat scenario (one live agent tab, empty transcript, image upload) instead of the default terminal fixtures.MOCK_CHAT_AGENT=omp— withMOCK_NATIVE_CHAT=1, present an OMP tab and four decoded transcript messages, including a tool call and result, instead of the default Claude scenario. It deliberately omitstranscriptPathto exercise legacy-hook readability discovery; current OMP hooks may report a path.MOCK_SERVER_KEY_FILE— persist the server keypair across restarts so a paired device keeps its public-key pin. A missing or invalid file is re-keyed with a warning, which forces a re-pair.
Scenario control files
Read on every request, so behaviour can be flipped mid-session without a restart (a restart would re-key E2EE and force a re-pair). Write the mode into the file, or delete it for the default.
MOCK_SEND_MODE_FILE(defaultorca-mock-send-modein the system temporary directory) —accept(default) accepts the send,errorfails it withmobile_input_floor_unavailable, anything else reports the send as rejected.MOCK_TERMINAL_LIST_MODE_FILE(defaultorca-mock-terminal-list-modein the system temporary directory) —omitreturns an empty terminal list,otherreturns a list that omits the chat handle, anything else lists it.MOCK_TERMINAL_STREAM_MODE_FILE(defaultorca-mock-terminal-stream-modein the system temporary directory) —deadanswers a subscribe withsubscribedthenend(a gone PTY), which is what exercises the rearm bound and terminal prune; anything else streams normally.
Connecting to Real Orca
- Start Orca desktop with WebSocket transport enabled
- In Orca, go to Settings > Mobile and scan the QR code with this app
- The QR encodes the connection endpoint, device token, and TLS fingerprint
Project Structure
mobile/
├── app/ # Expo Router screens (file-based routing)
│ ├── _layout.tsx # Root layout with navigation stack
│ ├── index.tsx # Home screen — paired hosts list
│ └── pair-scan.tsx # QR code scanning screen
├── src/
│ ├── terminal/ # Terminal WebView and xterm bridge
│ └── transport/ # WebSocket RPC client
├── scripts/
│ ├── test-subscribe.ts # Desktop streaming repro without a phone
│ └── mock-server.ts # Standalone mock WebSocket server
└── assets/ # App icons and splash screen