Repository navigation
fix(mobile): open native chat when a new worktree launches a default agent - #19850
Conversation
`decideWorkerStartMode` was the only shared answer to "structured chat session
or terminal agent?", but it lived in an orchestration-named module and spoke
orchestration's vocabulary, so the other launch surfaces could not call it.
Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave
`orchestration-worker-start-mode` as the adapter that supplies the noun.
A worker is not a special kind of launch; it is the same launch with a dispatch
attached. Naming the receipt's subject is the only thing orchestration actually
contributed, so that is the only thing the adapter keeps: "worker" in both
sentences, plus the `--terminal` wording, which reads as nonsense anywhere a
`--terminal` flag does not exist. Both are pinned, because they are asserted.
No behavior change. The receipts are byte-identical for every reachable case,
proven by running the new pin against both implementations.
Also pins the wording, which nothing was holding. The existing suites assert
`toContain` fragments ('terminal agent', 'cannot create') and the CLI suite
asserts a receipt handed to it by a mock rather than one this code produced;
all six files stayed green against a deliberately corrupted vocabulary. A
dispatch receipt is the only place a structured-to-terminal downgrade explains
itself, so the whole sentence is the contract, not a fragment of it.
…uns it The sequencing around the launch decision was duplicated per surface, and the duplicate is where the bug lives. A new worktree was created agent-first, so its startup terminal WAS the agent and the structured branch below it could never be reached — every new-worktree launch was a PTY regardless of the user's default. Orchestration fixed that for itself in #19431; mobile and the CLI still have it. `executeAgentLaunch` inverts the order once, for everyone. When the preference is structured the worktree is created with NO startup agent, the executing host is then asked whether it can host a session for the workspace that now exists, and only then is a surface created. The host verdict cannot be hoisted above creation: `agentSession.createSupport` only answers for a workspace it can resolve, which is why the decision stays in two halves. Agent-first creation is deliberately preserved for PTY launches — it is what sequences the agent's startup command behind the setup runner, so wait-for-setup comes for free there. What actually differs per surface is only how a surface is built (an orchestration worker's session takes a dispatch hold and a mailbox a plain launch must not take), so that is injected as a factory rather than branched on. The intent also strips the reserved agent fields from a migrated create payload: a caller moving off `worktree.create` passes its existing params, and a stale `startupAgent` in there would re-create the very path this replaces. Tests assert order and arguments, not just the resulting mode. Reintroducing agent-first creation reddens 4 of 11.
Adds `agent.launch` — one host-side method that decides structured-vs-terminal and creates the surface — wired to the real runtime factories: `createManagedWorktree` for the workspace, forking on `startupAgent` exactly as the orchestration worker path does; `createStructuredAgentSessionForWorktree` for a chat session; and `createTerminal` for a PTY agent. Allowlisted for mobile, which is the surface the routing gap was reported on. `worktree.create` is untouched. Its `startupAgent` keeps meaning "spawn a PTY agent" verbatim, because it answers with `agentTerminalHandle` only on that path: a host that quietly routed it to a structured session would hand every older client a response with no handle and no error. All new behaviour sits behind `agent.launch.v1`, which the host now advertises and a remote client must negotiate, so a client that does not gets today's behaviour unchanged.
Picking an agent on the mobile create sheet always produced a terminal, even when the user's default was native chat, because all three create paths put `startupAgent` on `worktree.create`. That means "create the worktree agent-first", so its startup terminal IS the agent and the structured branch below it is unreachable — while the same phone's in-workspace "+" button opened a chat. The blank, branch and new-branch creates now send the same payload through `agent.launch` and let the host settle the surface. `worktree.create` is untouched, and a host that does not advertise `agent.launch.v1` (read from the existing `status.get` probe) keeps today's path exactly. Work-item creates stay on `worktree.create`: they pre-fill the issue/PR URL as an unsent `startupDraft`, which a structured session cannot hold yet, so routing them would submit the URL as a first turn.
…son map main removed the draft-prompt blocker in #19681 (a structured session now holds an unsent draft), so the exhaustive Record no longer typechecks.
…2025/revive-agent-launch-mode
…cast The type-assertion gate landed after this branch's base, so the new file's copy of the worker-start cast is now a changed-code finding.
…into brennanb2025/revive-agent-launch-rpc # Conflicts: # src/shared/protocol-version.ts
… casting gates The typed-method contract, the generated params catalog and the `assertionStyle: never` casting scan all landed after this branch's base. - AGENT_LAUNCH_METHODS kept an `RpcMethod[]` annotation, which widened its method name to `string` and broke assignability; every sibling infers instead. - `agent.launch` binds a schema under src/main, so it joins the catalog's RPC_METHODS_WITHOUT_SHARED_PARAMS and the parity gate's hand-listed twin. - The now-typed methods make most test casts unnecessary; the few that remain carry the line-specific SAFETY rationale the casting gate requires.
…launch-mobile Mobile's create path moved onto the typed RpcOperation contract upstream, so the two-method dispatch this branch added had to move with it rather than keep its own raw sender. - worktree-create-retry.ts picks between the worktree.create and agent.launch bound operations instead of reaching the raw request port, which the mobile boundary ratchet forbids for new code. - agent.launch was uncatalogued only because its schema literal sat under src/main; every field it binds is already shared. Moved it to src/shared/rpc-contract/agent-launch-params.ts - the same re-export shape worktree-create-schemas.ts uses - and regenerated the catalog, so RpcSendParams<'agent.launch'> exists and the method is sendable type-safely. - Both create routes carry the host's warning through, so a create that seats the workspace but cannot start the agent surface still reports why. Work-item creates stay on worktree.create with their unsent startupDraft.
…ding needs The golden RPC recordings landed upstream while this branch was out, so they first met agent.launch here. Three things had to happen, and only one of them is a fixture bump. 1. workspace-settings-mounts.ts mounts useNewWorkspaceCreateSubmit against a fixture model that throws on any member it was not given. This PR added a required getAgentLaunchSupport, so the submit aborted with "Missing model fixture" before it ever issued the create, and three cleanup checkpoints vanished. That read like a product regression and was not one. Supplying the member restores the recording byte-for-byte; it is pinned false for the same reason the cutover probe is, so the baseline stays on worktree.create. 2. Editing that adapter moves adapterSha256 for the twelve settings goldens it mounts. Their recordings are unchanged - header only, by design: the digest is per-golden so editing a module fails exactly the goldens that mounted it. 3. Five goldens changed behaviourally, and both changes are this PR's: the capability probe now reports agentLaunch, and a create whose reply carries no worktree returns "Failed to create workspace" instead of throwing a TypeError off an unguarded result.worktree read. The launch route needs that guard, since a receipt can arrive without a worktreeId.
…shape The changed-code quality gate refuses type assertions, and the eight it flagged were worth removing rather than suppressing. The production one was the point. readAgentLaunchCreateOutcome asserted the RPC payload into Partial<AgentLaunchResult> and then runtime-checked it anyway, so the assertion bought nothing and claimed a contract the host had not proven. It now narrows with `in` and validates each hop, which is the same nullability question readCreateResult already answers on the sibling path - a launch receipt can legitimately arrive without a worktreeId. AgentLaunchCreateOutcome ties worktreeId to the shared contract so a change there fails this reader's typecheck rather than passing a differently-typed field through. The test fakes claimed a whole RpcClient via `as unknown as RpcClient` while implementing one member. They now build a typed literal, matching the pattern in use-mobile-structured-agent-options.test.ts. The read sites cast params and then read one field; they now assert the payload with toMatchObject, which removes the cast and pins more of the shape than the cast did. Also pins the warning passthrough, which nothing covered: a terminal launch that seats the workspace but cannot start the pty reports why, and the absent, blank, non-string and structured-surface cases report nothing. Writing that test caught a real drop I had introduced in the reader.
There was a problem hiding this comment.
ℹ️ No critical issues — one small behavioral gap inline, plus a coverage ask on the fixed navigation path.
Reviewed changes
This reviews the mobile slice stacked on brennanb2025/agent-launch-rpc (the host-side agent.launch implementation lives on the base branch, not here).
- Mobile advertises
agent.launch.v1—mobile-runtime-client-capabilities.tsopts in, and the existingstatus.getcreate-capability probe (worktree-create-capability.ts) now reportsagentLaunchfrom the same shared promise. - Agent-carrying creates route through
agent.launch— the blank path (blank-workspace-create.ts) and the branch/new-branch composer paths pass anagentLaunchroute;worktree-create-retry.tssettles it once before the first attempt so a name-collision retry cannot switch methods. - Method refusal downgrades once — a
method_not_found/forbidden/agent_launch_unsupportedrefusal re-sends the same params asworktree.createand stays downgraded. - Receipts are read per route —
readAgentLaunchCreateOutcomereadsworktreeIdplus a terminaloutcome.warning; the legacy branch keepsworktree.{id,displayName}+warning. agent.launchparams move to shared —src/shared/rpc-contract/agent-launch-params.tsplus the regenerated catalog and therpc-params-type-parity.tsexception removal, soRpcSendParams<'agent.launch'>exists for the client.pnpm run verify:rpc-params-catalogis clean.- Work-item creates deliberately stay on
worktree.create— their unsentstartupDraftwould otherwise be submitted as a first turn.
Verification this run
pnpm run verify:rpc-params-catalog— clean.- Desktop
src/main/runtime/rpc/methods/agent-launch.test.ts— 16/16 pass. - The mobile suite could not be run here (
mobile/node_modulesis not installed in this environment), so the mobile claims are taken from the diff and author's reported run.
ℹ️ The navigation this PR fixes still has no end-to-end exercise
The user-visible step this PR exists to fix — landing on the new native chat instead of the old terminal — is covered only by the pin added in active-session-tab.test.ts:138, which stays green whether or not the host activates the launch's tab before it answers. No create test seeds a route whose first snapshot carries an activated agent-session tab, and no ablation touches it (the author calls this out in the PR body). Since this is the behaviour the bug report is about, it is worth one real pass before merge.
Technical details
# Post-create navigation coverage
## Affected sites
- `mobile/src/session/active-session-tab.test.ts:138` — pins `resolveActiveSessionTab`'s existing snapshot-active fallback; passes with or without the fix.
- `mobile/src/session/use-mobile-session-startup.ts:148` — only auto-creates an initial terminal when no tabs hydrated (`visibleTabCount === 0`), so with the launch tab present the active-tab marking comes entirely from the host.
- `mobile/src/host-screen/host-screen-overlays.tsx:225` — `onCreated` navigates to the session route with no pending tab id, relying on that host marking.
## Required outcome
- Confidence that a real `agent.launch` create lands the phone on the structured chat on the first snapshot, not the workspace shell.
## Suggested approach (optional)
- One emulator/device create against a host whose default is structured, or seed `pendingActiveSessionTabId` with the receipt handle in a create-level test.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Mobile Checks is path-filtered to mobile/**, but mobile imports the negotiated capability names straight from src/shared/protocol-version.ts and records the whole capability read verbatim in its goldens. So a capability added desktop-side rewrites a mobile fixture while never triggering the suite that would catch it. That is what happened here: #19849 introduced agent.launch.v1 and Mobile Checks never ran on it. Verified at the run level rather than by check name - the window-free check-runs API on 3837ae8 returns 49 check-runs across six runs (PR Checks x2, PR test LoC x2, Track Community PRs, Review) and no Mobile Checks among them. The breakage surfaced only in this PR, which happens to touch mobile/**. The workflow already concedes this pattern for terminal-file-link-conformance.ts; protocol-version.ts has the stronger claim, since mobile records its output. Also corrects the mount adapter's SAFETY comment. It claimed the recorder supplies only the members the hook reads, which was false the moment the hook gained a required getAgentLaunchSupport - and the assertion it annotates is exactly what stopped the compiler from saying so. The twelve goldens are adapterSha256 churn from that comment: every body is byte-identical, which is the digest doing its job.
There was a problem hiding this comment.
✅ No new issues in the incremental changes. The two notes from the prior review still stand and are not addressed by this delta.
Reviewed changes (delta since 9edaccc)
- Launch receipt is narrowed, not asserted —
readAgentLaunchCreateOutcomenow usesin-narrowing over the raw payload and delegates the terminal warning to a newterminalLaunchWarning, andAgentLaunchCreateOutcome['worktreeId']is tied toAgentLaunchResult['worktreeId']so a contract change fails this reader's typecheck. - Warning tests added — a terminal launch warning is carried through, while blank / absent / non-string / structured-surface warnings report none.
- Test assertions de-casted — the create tests replace
ascasts withtoMatchObject/not.toHaveProperty. - Recording fixture supplied —
workspace-settings-mounts.tspassesgetAgentLaunchSupport: async () => false(old-host baseline), and 18 create/capability goldens were regenerated. Thematrix-worktree.create-retrygolden now records a cleanFailed to create workspaceinstead of the previousTypeErroron a malformed legacy reply, which matches the newreadCreateResultnull path.
Verification this run
- No non-generated production code changed in this delta beyond
readAgentLaunchCreateOutcome/terminalLaunchWarning; the narrowing is sound fornull, arrays, and non-object warnings. - Mobile suite still could not be run here (
mobile/node_modulesabsent).
Prior review findings still open
- The launch path does not surface the worktree-create warning (e.g. a skipped worktree-include copy) that
worktree.createreturned;agent-launch-worktree-creation.ts:67dropsresult.warning. - Post-create navigation is still only pinned, not exercised end to end.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…tion The decision was never moved out of orchestration-worker-start-mode; this PR adds a second copy beside it. Say so, and name the unenforced agreement.
…at has not happened The header asserted two things the tree does not support: that every launch surface routes through the executor, and that the mode decision "already lived" in `agent-launch-mode`. `agent.launch` is the executor's only consumer, and `orchestration-worker-start-mode.ts` is byte-identical (blob 92dc5c6, 217 lines) at the merge base and all three stack heads, still used by workers.ts. Describe the two live copies and leave the cutover to later stack work.
…into brennanb2025/revive-agent-launch-rpc
…launch-mobile The base moved 31 commits: #19849 merged main forward, #19848 landed on main as a squash, and several mobile domains migrated onto typed RpcOperations. The only conflicts were 12 settings goldens, and only in two header digests. Both sides had moved a digest for a legitimate and different reason: upstream added ~35 files under src/test-support/rpc-recording/, which recorderSha256 covers, while this branch edited workspace-settings-mounts.ts, which adapterSha256 covers - and upstream never touched that adapter. So neither side's pair described the merged tree, and taking either wholesale would have committed a header that lies about the sources it was recorded from. Resolved by re-recording from the merged tree, which computes both digests from the actual merged files. The result pairs upstream's recorderSha256 with this branch's adapterSha256. All 12 bodies are byte-identical to what was already on disk, so nothing behavioural changed: the conflict was entirely provenance. The golden set grew 208 -> 509 with upstream's new scenarios; recorded set and on-disk set match exactly, with no stale and no missing files.
…oundary anti-slop/no-object-parameters flagged terminalLaunchWarning's `result: object`. The rule is pointing at a real seam rather than a style nit: the helper advertised a loose object and did the narrowing inside itself, so every caller handed it unparsed wire data and nothing downstream held a real type. Parsed at the boundary instead. parseTerminalLaunchOutcome takes `unknown` and returns TerminalLaunchOutcome | null, so the narrowing happens once, where the untrusted payload enters, and the consumer works with a named type. The type is taken from the shared contract rather than restated - a Pick over the terminal member of AgentLaunchOutcome - so a change to that union fails here instead of flowing through. `handle` is deliberately excluded: nothing reads it, and requiring it would drop the warning off a reply that omitted one, which is a behaviour change smuggled in under a typing change. No assertion and no config exemption: reintroducing `as Partial<AgentLaunchResult>` would trade this finding for the defect removed earlier in this branch, and the rule is correct here. The rule arrived with the merge-forward (#20781, newer than this branch's merge-base), and anti-slop is not one of the changed-code gate's six scans - it runs only repo-wide - which is why a clean local gate did not predict it. Behaviour is unchanged across all five warning cases, and the positive case was re-ablated on the new parser: dropping the warning reddens exactly it, 1 failed | 18 passed, restored byte-identical to 19 passed.
… second session A replayed agent.launch could create a second structured session in the same worktree, with activate: true. dedupeWorktreeCreate wrapped only the worktree half, inside the workspace factory. On a replay the create was reused, and the executor then continued to createSurface and built another surface inside it. The terminal route hid this: its cached create carries a startup terminal handle, so the executor returns on early. A structured create has no handle by construction - that is the whole point of the structured fork - so it fell through every time. Mobile replays this method deliberately on a delivery-ambiguous response, up to five attempts, so the path is reachable by design rather than in theory. The handler now wraps the entire launch in the same dedupe, on the same (repo, clientMutationId) identity, exactly as worktree.create wraps its own body. A replay returns the original AgentLaunchResult instead of re-running createSurface, which makes the two routes replay-identical. The inner dedupe is removed rather than kept. Wrapping both levels on one key deadlocks: dedupeWorktreeCreate stores the in-flight promise before the inner call runs, so the inner call would be handed the outer's promise, which is waiting on it. The launch-level memo subsumes the worktree-level one. Failures are still dropped rather than cached, so an unknown outcome stays unknown instead of replaying as a fabricated success. The guard replays a STRUCTURED launch: the terminal route cannot reproduce this and a test there would pass either way. Ablated against the pre-fix files - 1 failed | 22 passed, "expected vi.fn() to be called 1 times, but got 2 times", which is the duplicate session - then restored to 23 passed. The stub's dedupe had to be made faithful for that to be observable; the shared one passes through so other tests can see raw calls.
…t mint a second session" This reverts commit 59bc5e9. The same defect was already fixed upstream on this stack's base branch by 539e283, which landed while this was being written. That change is broader (it also cancels the setup wait) and namespaces the dedupe key, so it supersedes this one. Reverting rather than hand-merging keeps a single implementation instead of a hybrid nobody chose. The behavioural guard from this commit is ported back on top of the upstream implementation separately: it asserts exactly one structured session survives a replay, where the upstream tests assert the dedupe wiring.
There was a problem hiding this comment.
Important
Moving the replay dedupe to wrap the whole agent.launch launch fixes the success path but drops the create-level memo, so a same-clientMutationId replay after a post-create failure now re-creates the worktree. dedupeWorktreeCreate deletes its key on rejection and createManagedWorktree has no idempotency of its own, so the retry resolves past the now-existing branch to name-2 and strands the first workspace. Detail inline.
Reviewed changes
This run reviews the delta since the prior pullfrog review at 2f602f1b2e — commit 59bc5e9b04 ("memoize the whole launch so a replay cannot mint a second session").
- Replay identity moved to the whole launch —
agent.launchnow wrapsexecuteAgentLaunchinruntime.dedupeWorktreeCreateforcreate-worktreetargets, and the create-level wrapper was removed fromagent-launch-worktree-creation.ts, so a replayed structured launch returns the memoized receipt instead of minting a second session. - Replay tests added —
agent-launch.test.tsgains a memoizingdedupeWorktreeCreatestub shape (memoizeCreates) plus three cases: same-mutation replay returns the original receipt, a different mutation id still launches, and a failed launch is not memoized. agent.launchexception list tidied —rpc-params-type-parity.tscollapsesUncataloguedMethodtoemulator.install | orchestration.send | orchestration.taskUpdate, following through the earlier shared-catalog move.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| return context.runtime.dedupeWorktreeCreate( | ||
| params.target.create.repo, | ||
| params.target.create.clientMutationId, | ||
| run | ||
| ) |
There was a problem hiding this comment.
dedupeWorktreeCreate drops its entry the moment the launch rejects, and this commit removed the create-level memo that used to survive a post-create failure. A delivery-ambiguous replay after the worktree exists but a later step failed therefore re-enters createManagedWorktree with the same clientMutationId, which has no idempotency — the candidate resolver suffixes the now-existing branch to name-2 and a second workspace is created while the first is stranded. The removed inner wrapper returned the cached worktree for the full TTL window, so this replay could not duplicate before.
Technical details
# Whole-launch memo trades duplicate-surface for duplicate-worktree on the failure path
## Affected sites
- `src/main/runtime/rpc/methods/agent-launch.ts:117` — the launch is now the memoized unit; `dedupeWorktreeCreate` (`orca-runtime-terminal-create-deduplication.ts:193-203`) deletes the key on rejection (`void created.then(() => {…}, drop)`), before the host even serializes the error.
- `src/main/runtime/rpc/methods/agent-launch-worktree-creation.ts:42-55` — the create-level `dedupeWorktreeCreate` was removed, so `createManagedWorktree` is now a bare call.
- `src/main/runtime/runtime-local-worktree-create-candidate.ts:94,171-173` — on a local branch conflict it `continue`s to suffix 2; `createManagedWorktree` never receives `clientMutationId` (`worktree-create-args.ts:20-92`), so the second call is a genuine second create.
- `mobile/src/tasks/worktree-create-retry.ts:204,213` — mobile replays the same `clientMutationId` on cutover / delivery-unknown, independent of whether the host's launch failed.
- `src/main/runtime/orca-runtime-core.ts:69-72` — the doc on `WORKTREE_CREATE_RESULT_TTL_MS` states the guarantee this now breaks on the failure path.
## Trigger
1. Mobile sends `agent.launch` with mutation id `M`; `createManagedWorktree` succeeds (worktree + branch `task`).
2. A later step rejects the outer `run` with the worktree already on disk: `createSurface` throws a non-definitive error (`agent-launch-executor.ts:145-156`), or the terminal downgrade / terminal-surface create throws (`:158-168`, `:225-229`).
3. The memo is dropped; the host returns an error response; the transport loses it.
4. Mobile replays `M`; the memo is gone, so `createManagedWorktree` re-runs, sees branch `task` as a local conflict, and creates `task-2`.
## Required outcome
- A same-`clientMutationId` replay after a post-create launch failure must reuse the worktree that was already created; worktree-create idempotency must not depend on the later surface/mode step succeeding.
## Suggested approach (optional)
- Keep the create-level memo and make the surface step idempotent per launch, or cache the launch rejection too (the shared `dedupeWorktreeCreate` deliberately drops failures), or give `createManagedWorktree` its own `clientMutationId` idempotency. Author's call.
## Note
- `agent-launch.test.ts:404-414` asserts `createStructuredSession` twice but never asserts `runtime.createManagedWorktree`; it passes while encoding this duplicate create.…launch-mobile Takes 539e283's replay fix wholesale. This branch's own attempt at the same defect was reverted first, so the merge is clean and there is one implementation rather than a hand-merged hybrid.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the host-side replay fix this PR carried was superseded by the base branch and reverted onto it.
Reviewed changes
This run reviews the delta since the prior pullfrog review at 59bc5e9b04 — commits d464adf718 (revert) and 272d2a7eed (merge of base 539e283c0f).
- Host-side replay fix reverted —
d464adfreverts59bc5e9; the base branch's539e283("dedupe complete launch and cancel setup wait") already carries a broader version — a namespacedagent.launch:<mutationId>dedupe key plus an abortable setup wait — soagent-launch.ts,agent-launch-worktree-creation.tsandagent-launch.test.tsare now identical to base and drop out of this PR's diff. - Base merged in —
272d2a7mergesbrennanb2025/agent-launch-rpc; no mobile file changed in either new commit, so the behaviour the earlier reviews covered is untouched. - Behaviour now inherited from base — a replayed
create-worktreelaunch memoizes the whole launch (successes reused, failures still dropped), and a structured launch's setup wait aborts on its 60s timeout.
The two findings from earlier reviews — the create-level warning dropped on the launch path, and the failure-path duplicate worktree on a replayed launch — remain open; neither is touched by these commits.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Three review findings, all narrow. Mobile Checks is path-filtered, and this branch made mobile's types depend on the shared RPC contract: rpc-params-contract.ts is a type-only re-export of the generated params catalog, and mobile/tsconfig.json includes **/*.ts. So a desktop-only edit under src/shared/rpc-contract/ could break mobile's typecheck with no mobile signal at all - the same blind spot the protocol-version.ts entry closed, one directory over. Added src/shared/rpc-contract/** to the paths filter. agent.launch had no cross-version trigger. Added the three prefixes a paired peer actually exchanges: the intent contract, the wire schema, and the RPC method. src/main/agent-launch/ is deliberately NOT listed - the executor shapes behaviour but is not itself wire, and AgentLaunchResult's shape is already covered by agent-launch-intent. Extending the cross-version SUITE to cover a negotiated handshake is separate work, not this. The break branch that answers an accepted-but-empty reply with "Failed to create workspace" had no unit coverage; the golden that used to discriminate it collapsed five partitions into one shared error when the null guard replaced the unchecked read. Covered on BOTH routes - worktree.create with no worktree.id and agent.launch with no worktreeId - since the branch serves both. Ablated by bypassing the guard: 2 failed | 11 passed, the two new cases returning a fabricated worktree instead of the error, restored to 13 passed.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviews the delta since the prior pullfrog review at 272d2a7 — commit b9dfdcad ("ci(mobile): close the round-1 signal gaps around agent.launch"). All three files are CI/test surface; no mobile product code changed.
- Added
src/shared/rpc-contract/**to Mobile Checks' path filter — mobile'srpc-params-contract.tsis a type-only re-export of the generated params catalog, so a desktop-only schema edit can break mobile's typecheck with no other mobile signal; the glob is valid and covers the catalog plusrpc-send-params. - Extended the cross-version-wire trigger with three
agent.launchprefixes —src/shared/agent-launch-intent,src/shared/rpc-contract/agent-launch-paramsandsrc/main/runtime/rpc/methods/agent-launch. Verified the shipped CLI classifies all three ascross-version-wire=true, andconfig/scripts/pr-code-change-scope.test.mjsstill passes 31/31. - Covered the accepted-but-empty reply break branch on both routes — the new
it.eachinblank-workspace-create.test.tsdrives legacyworktree.createwith noworktree.idandagent.launchwith noworktreeId, assertingFailed to create workspacewith a single call. The guard is discriminating: an unchecked reader returns a fabricated worktree instead.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…complete
createManagedWorktree reports an unspawned startup terminal or an uncopied
working tree as a top-level `warning`, and worktree.create hands it straight to
mobile. The launch path narrowed that result down to
{worktreeId, startupTerminalHandle} and dropped it, so every agent.launch create
lost a warning the old method surfaces - on both arms.
The channel was also asymmetric by accident rather than design: a terminal
outcome could carry `warning`, a structured one had nowhere to put it, so the
arm this PR exists to enable was the arm that could not report an incomplete
create at all.
Now there is exactly one place a launch warning lives: AgentLaunchResult.warning,
at the top level. It is about the create as often as the surface, it applies to a
structured session and a terminal alike, and a reader should not branch on
outcome.kind to discover the workspace it just opened is missing something. The
terminal arm's own `warning?` is removed rather than left beside it - two homes
for one fact is how they drift. Every producer folds in: the create, the surface,
and the refusal downgrade.
Consumer census before removing it: one production reader (mobile's
readAgentLaunchCreateOutcome) and no others - the renderer and mobile launch
call sites never read it. The mobile reader now reads the top-level field, which
also lets its outcome parser go away entirely.
Guard ablated by restoring the pre-fix narrowing: 2 failed | 24 passed, both
carriers reporting `expected undefined`, which is the dropped warning itself;
restored to 26 passed. The third case asserts an absence and stays green under
the mutation by construction - it pins shape, not the defect.
There was a problem hiding this comment.
ℹ️ No new issues — the previous warning-passthrough finding is now addressed. Two small accuracy notes, one inline.
Reviewed changes
This run reviews the delta since the prior pullfrog review at b9dfdcad28 — commit e970278166 ("fix(agent-launch): give a launch one place to say the workspace is incomplete").
- Launch warning moved to one top-level home —
AgentLaunchResult.warningis now the single place an incomplete launch is reported;AgentLaunchOutcome's terminal variant loses its ownwarning, so a reader never has to branch onoutcome.kind. - Host threads the create warning through —
AgentLaunchWorkspaceFactory.createWorktreenow returnsresult.warningfromcreateManagedWorktree,resolveWorkspacecarries it, andexecuteAgentLaunchemits it on both the agent-first terminal early return and the main path. - Mobile reads the new shape —
readAgentLaunchCreateOutcomereads top-levelwarninginstead ofoutcome.warning, and a new test pins that a warning left on the oldoutcomesurface is ignored. - Coverage added — desktop
agent-launch.test.tsgains a "create that succeeded but is incomplete" suite (structured and agent-first terminal arms);withoutReservedAgentCreateFieldsis now generic so the stripped create keeps the caller's type.
Verification this run: desktop agent-launch.test.ts 26/26; mobile agent-launch-worktree-create / worktree-create-retry / blank-workspace-create 59/59; pnpm tc:node, tc:web and mobile tsc --noEmit clean; verify:rpc-params-catalog clean; changed-code quality gate 0 findings across 34 files.
ℹ️ Nitpicks
- The PR body still describes the pre-
e970278contract: item 2 under "Behaviour changes a reviewer must see" says a terminal launch carries the warning on its outcome and lists a "structured-surface" no-warning case. The warning now lives atAgentLaunchResult.warningfor both surfaces, and that case was replaced by "ignores a warning left on the outcome".
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Picks up #20874 (6c03bb6), which removes the Reflect.get this branch was carrying as an inherited anti-slop error. The file arrives from main untouched - its blob here is now main's 6a85b39 - and audit:anti-slop reports zero findings for the first time on this branch. Twelve settings goldens conflicted, the same set as before and for the same reason: main moved recorderSha256 while this branch owns adapterSha256, so neither side's header describes the merged tree. Resolved by re-recording from the merged sources so both digests derive from what is actually there. Unlike the previous merge, the BODIES changed too, and that is correct rather than a regression: main rewrote the recording harness and run-recording.ts now projects a `sent` counter on every effect. The re-recorded bodies gain only `sent` lines - pure additions, no deletions, no modifications - matching the ~629 goldens that took main's side cleanly. The header delta is baseline (main repinned it) and recorderSha256; adapterSha256 is unchanged because this branch already held the right one. The golden set is unchanged in both directions at 641.
Round 2 found the comment here was false. A create warning and a surface warning
CAN both be set, on two reachable paths:
1. The create warns precisely BECAUSE it produced no startup terminal -
didSpawnStartup stays false when that spawn throws, and
orca-runtime-create-managed-worktree.ts:283 gates startupTerminal on it - so
the executor's early return is skipped and a second surface is built, which
can warn too.
2. An untracked-copy warning, then a definitive structured refusal downgrading
to a terminal that also warns.
`??` kept the first and lost the second with nothing saying so. They are now
combined the way the create combines its own failures - appendFailure in
runtime-local-worktree-terminal-startup.ts, and the startup-terminal catch in
runtime-remote-managed-worktree-create.ts - which append rather than replace.
The comment is rewritten to say what is true, and records the gap NOT fixed
here: a create warning about a failed startup terminal is stale once the launch
recovers by building a working one, so a user can be told the agent did not start
while looking at it. Distinguishing those needs createManagedWorktree to stop
multiplexing two unrelated failures into one string.
Guarded and ablated: restoring `??` reddens exactly the new test, with the
surface clause missing from the received string; restored to 27 passed. The
structured-create stub had to admit its real ok-or-refusal union for the
downgrade path to be modellable at all - it previously declared only the ok arm.
Also: mobile.yml gains src/shared/agent-launch-intent.ts. It is the sole holder
of the agent.launch RESULT shape - the rpc-contract catalog holds params only -
and mobile imports it as a value. CROSS_VERSION_WIRE_PREFIXES already treats it
as wire-critical; without this, one gate does and the other cannot see it.
And the agent-first warning test no longer pairs "startup terminal failed" with a
returned handle, a combination the producer cannot emit.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (18)
🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe pull request adds the shared Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A creation that succeeds but returns an incomplete receipt may be presented as failed. Retrying could create another workspace, so this behavior should be resolved or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the implementation, rationale, testing, limitations, and checklist. However, the required Linked Issue is missing, and the required visual proof for this UI behavior change is not attached. Full details: Docstring CoverageExplanation Docstring coverage is 28.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 33 files. (17 skipped: 17 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 90b7a655-a1d9-4cfd-9775-e1795778380b
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (52)
.github/workflows/mobile.ymlconfig/scripts/pr-code-change-scope.mjsmobile/rpc-foundation/goldens/matrix-settings.task-workspace-create-settings.get-1.jsonmobile/rpc-foundation/goldens/matrix-settings.task-workspace-create-worktree.create-1.jsonmobile/rpc-foundation/goldens/matrix-settings.task-workspace-settings.get-1.jsonmobile/rpc-foundation/goldens/matrix-settings.workspace-submit-settings.get-1.jsonmobile/rpc-foundation/goldens/matrix-worktree.create-retry-worktree.create-1.jsonmobile/rpc-foundation/goldens/matrix-worktree.runtime-capabilities-status.get-1.jsonmobile/rpc-foundation/goldens/settings-task-workspace-create-linear.jsonmobile/rpc-foundation/goldens/settings-task-workspace-create-pr-start-point.jsonmobile/rpc-foundation/goldens/settings-task-workspace-fulfilled.jsonmobile/rpc-foundation/goldens/settings-task-workspace-refused.jsonmobile/rpc-foundation/goldens/settings-task-workspace-transport-error.jsonmobile/rpc-foundation/goldens/settings-workspace-submit-fulfilled.jsonmobile/rpc-foundation/goldens/settings-workspace-submit-refused.jsonmobile/rpc-foundation/goldens/settings-workspace-submit-transport-error.jsonmobile/rpc-foundation/goldens/tw-capabilities-advertised.jsonmobile/rpc-foundation/goldens/tw-capabilities-cutover-retried.jsonmobile/rpc-foundation/goldens/tw-capabilities-legacy-idempotency.jsonmobile/src/components/NewWorktreeModal.tsxmobile/src/components/use-new-workspace-create-submit.tsmobile/src/session/active-session-tab.test.tsmobile/src/tasks/agent-launch-worktree-create.test.tsmobile/src/tasks/agent-launch-worktree-create.tsmobile/src/tasks/blank-workspace-create.test.tsmobile/src/tasks/blank-workspace-create.tsmobile/src/tasks/mobile-workspace-create-operations.tsmobile/src/tasks/source-workspace-create.test.tsmobile/src/tasks/source-workspace-create.tsmobile/src/tasks/workspace-create-params.test.tsmobile/src/tasks/workspace-create-params.tsmobile/src/tasks/worktree-create-capability.test.tsmobile/src/tasks/worktree-create-capability.tsmobile/src/tasks/worktree-create-retry.tsmobile/src/test-support/rpc-recording/adapters/workspace-settings-mounts.tsmobile/src/transport/mobile-runtime-client-capabilities.test.tsmobile/src/transport/mobile-runtime-client-capabilities.tssrc/main/agent-launch/agent-launch-executor.test.tssrc/main/agent-launch/agent-launch-executor.tssrc/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-06.spec.tssrc/main/runtime/rpc/methods/agent-launch-schemas.tssrc/main/runtime/rpc/methods/agent-launch-surfaces.tssrc/main/runtime/rpc/methods/agent-launch-worktree-creation.tssrc/main/runtime/rpc/methods/agent-launch.test.tssrc/main/runtime/rpc/methods/agent-launch.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-method-allowlist.tssrc/shared/agent-launch-intent.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/agent-launch-params.tssrc/shared/source-scan/source-tree-walk.test.ts
💤 Files with no reviewable changes (1)
- src/shared/source-scan/source-tree-walk.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| lastError = 'Failed to create workspace' | ||
| break |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Preserve an uncertain result for an invalid create receipt.
Both deferred operations accept an ok response before readCreateResult validates the receipt. A missing or invalid worktreeId then reaches mobile/src/tasks/worktree-create-retry.ts:123-124, which reports a definite failure. The submit hook leaves the modal open and re-enables Create. With idempotency enabled, the next submission mints a new clientMutationId; host deduplication only matches the original repository and mutation ID. If the first request committed before returning the malformed receipt, the retry can create another workspace, including after a name-collision suffix.
Return an explicit uncertain state that blocks a new mutation ID. Replay the original mutation ID within the host dedupe window, or require a workspace refresh before enabling another create.
#19850 was retargeted to main after #19849 landed as a SQUASH, so this branch held #19849's original commits while main held the squashed equivalent - the same content under different SHAs, which git reported as dirty. Five files conflicted add/add, all of them files this PR also edits. Neither side was takeable wholesale: theirs would have discarded this PR's work, ours would have discarded anything main gained. Verified first that main's blob for each is byte-identical to 539e283 - the #19849 head this work builds on - so ours is a strict superset and the conflict is purely the squash artifact. Then took ours on all five. Two things auto-merged WRONG, outside any conflict region, and neither showed a marker: - rpc-params-type-parity.ts silently reverted to main's copy, putting 'agent.launch' back in UncataloguedMethod while the catalog still holds the entry. Typecheck caught it: TS2344 at :45. Re-applied. - the generated params catalog was stale against main's new methods. Regenerated; agent.launch stays catalogued and the uncatalogued list is back to three. Audited every file this branch authored against main's copy afterwards: none other reverted. The only file matching main verbatim is src/relay/pty-handler.ts, which this branch never touched.
There was a problem hiding this comment.
✅ No new issues found in this delta. Approval is withheld only because an earlier Pullfrog thread on the base branch's replay behavior (
agent-launch.ts, now outside this PR's diff) is still open — nothing in these commits touches it.
Reviewed changes
This run reviews the delta since the prior pullfrog review at e970278166 — the main merge b625f55e84 (no PR-owned source change) and commit eac3e56351 ("fix(agent-launch): combine both launch warnings instead of dropping one").
- Both launch warnings are now combined, not preferred —
executeAgentLaunchreplacesplaced.warning ?? created.warningwithcombineLaunchWarnings, which appends the surface warning to the create one instead of silently dropping it. The comment is rewritten to state the real invariant and records the deliberately-unfixed staleness gap (createManagedWorktreemultiplexing untracked-copy and startup-terminal failures into one string). - A discriminating test pins the co-occurrence — the structured-create stub now models its real ok-or-refusal union (it previously declared only the ok arm, so the downgrade path was unmodellable), and the new case asserts the exact combined string (the old
??reddens it). The agent-first warning test no longer pairs "startup terminal failed" with a returned handle, a combination the producer cannot emit. - Mobile Checks now re-runs for
src/shared/agent-launch-intent.ts— mobile importswithoutReservedAgentCreateFieldsas a value from it, andCROSS_VERSION_WIRE_PREFIXESalready classifies it as wire-critical.
Verification this run: desktop agent-launch.test.ts 27/27 + agent-launch-executor.test.ts 13/13. The prior thread on agent-launch-executor.ts:176 was replied to and resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues — this delta is a merge-only sync of
mainwith no PR-authored change.
Reviewed changes
This run reviews the delta since the prior pullfrog review at eac3e56351 — commit 55327fe893 ("Merge branch 'main' into brennanb2025/agent-launch-mobile").
- Merge of
main, no PR source changed —git diff eac3e56351 55327fe893lists only main-side files (terminal shell-override, CLI help text, pty spawn preflight, protocol-version), none undermobile/,src/main/agent-launch/, or theagent.launchRPC family. The merged tree'sagent-launch-executor.ts— includingcombineLaunchWarningsand the warning comment the previous review covered — is byte-identical to the reviewed version. - Diff-base files shifted, not the branch — several base-branch files now resolve identically on both sides and drop out of the PR diff (45 files vs 53); that is the merge base advancing past them, not a change in this branch.
Verification this run at the merged head 55327fe893: pnpm run verify:rpc-params-catalog --check clean; desktop agent-launch.test.ts 27/27 + agent-launch-executor.test.ts 13/13.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
agent.launch moved `warning` from the terminal outcome to the top level of the
result. That is the right shape - a reader should not branch on `outcome.kind`
to learn the workspace it just opened is incomplete - but on the wire it is a
REMOVAL, and mobile only read the new place.
A host built before the move still advertises the same `agent.launch.v1`
capability, so the capability probe cannot tell the two apart and mobile takes
this route against one:
protocol-version.ts:360 AGENT_LAUNCH_RUNTIME_CAPABILITY is in
RUNTIME_CAPABILITIES, the host list
orca-runtime-get-status.ts:64 publishes it via status.get; the filter drops
only browser.screencast.v1 and three E2E-gated
capabilities, never agent.launch
agent-launch-executor.ts such a host writes warning INSIDE outcome
The result was a regression rather than a contract cleanup: the worktree.create
path this replaces returned the warning at the top level and mobile read it, so
a create that seated the workspace but could not start the agent surface - pty
exhaustion, untracked files not copied - stopped explaining itself on the phone.
Read both shapes for as long as such a host can be paired. Top level wins, and
cannot be shadowed: AgentLaunchOutcome has no `warning` on either arm, so a
current host cannot nest one.
The test that pinned the old behaviour is inverted here. Its comment was the
actual defect - it framed a legitimate warning from an older peer as a stale
shape to defend against, which is what made dropping it look deliberate.
There was a problem hiding this comment.
✅ No new issues in this delta. Approval is withheld only because the earlier Pullfrog thread on the base branch's replay behavior (
agent-launch.ts, now outside this PR's diff) is still open — nothing in this commit touches it.
Reviewed changes
This run reviews the delta since the prior pullfrog review at 55327fe893 — commit 5c58ad38fd ("fix(mobile): read a launch warning an older host nests on the outcome").
- The launch reader now also reads a warning nested on the terminal outcome —
readAgentLaunchCreateOutcomefalls back tooutcome.warningwhen the top level carries none, with the top-level value winning. A host from the base branch nests the warning there and advertises the sameagent.launch.v1, so this mobile-only upgrade path would otherwise lose the incomplete-create notice theworktree.createpath already delivered. The fallback is live rather than dead code: the reply is read throughrpcUncheckedPayloadReader('agent-launch-receipt'), sooutcome.warningis not stripped before the reader sees it. - Both directions are pinned — one test reads a nested warning the previous top-level-only reader would have dropped (it reddens against that reader); another pins that a top-level warning shadows a nested one, so the migration fallback can never mask the fresher value.
- No host change — the diff is confined to
mobile/src/tasks/agent-launch-worktree-create.tsand its test; the earlieragent-launch-worktree-create.ts:61thread stays resolved and is unaffected.
Verification this run: mobile/node_modules is absent in this environment, so the mobile suite could not be run here. The change is confined to one reader function and its tests, and no host file changed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…gent-launch-mobile
Review + QA statusReadiness review: PASS — no P0, no P1. Head Fixed during reviewA shipped-wire regression that 5,551 green mobile tests could not see. Mobile's new reader took only the top-level It survived every gate because the reader dropped the field and a test asserted the drop — code and test written from the same premise, agreeing with each other while both were wrong. Fixed mobile-side in two files (executor blob byte-identical, zero goldens touched), and ablated at the final head: RED on exactly the nested-read test, byte-identical restore verified by hash, GREEN. The precedence test still passes in the RED arm, which is what shows the new test targets the fallback specifically rather than being incidentally coupled to it. Validation at
|
#20911 retired the duplicated launch-mode policy, so main now describes `agent-launch-mode` as the single owner with `orchestration-worker-start-mode` as a thin adapter over it. The executor did NOT conflict. Main's only change there is the module header prose (lines 3-12); every change this branch makes to that file starts at line 81, so the two auto-merged cleanly. Verified both halves survived rather than assuming: main's "shared, not copied" wording is present, the stale "duplicated rather than shared" wording is gone, and combineLaunchWarnings is intact. Fifteen mobile RPC goldens conflicted, all on recorderSha256/adapterSha256 plus value-pool entries. Both sides had legitimately re-recorded them - this branch for the getAgentLaunchSupport adapter, main for its own new recordings - so NEITHER side's hashes are correct for the merged source and picking a side is wrong in both directions. Resolved by re-recording instead. Seeded from main's side deliberately, so a re-record that failed to run would drop this branch's agentLaunch fields and fail loudly rather than silently keeping stale local values. The re-record touched 16 files, not the whole corpus: the 15 conflicted plus tw-capabilities-cutover-retried.json, which auto-merged but still needed its hash refreshed. Proven behaviour-preserving by comparing added and removed content lines as multisets, with pool keys and hash fields normalised out: added 127 / removed 119 content lines net added: 8x "agentLaunch": false net removed: none So every value main recorded is preserved, and the only semantic delta is this branch's own adapter field. Goldens then re-validated in normal (non-record) mode: 17 files, 793 passed.
32 commits, the largest forward on this branch so far. No agent-launch file moved on main: the executor, agent-launch-intent, the shared launch params and both mobile task modules are all byte-identical to the merge base, so nothing in the contract shifted underneath this work. Twelve mobile RPC goldens conflicted, every hunk on recorderSha256/adapterSha256. Both sides re-record, so neither side's hashes are right for the merged source and picking a side is wrong in both directions. Re-recorded instead, seeded from theirs so a recorder that failed to run would fail loudly rather than preserve stale local values. The re-record touched exactly those 12 files; the other 694 changed goldens were staged by the merge itself and are main's, not mine. Behaviour-preserving, proven by comparing added and removed content lines as multisets with pool keys and hash fields normalised out: net added: 0 net removed: 0 so the only delta is the source hashes themselves - 24 hash lines - which is the signature of a pure recorder-source shift with no semantic change. Re-validated in normal (non-record) mode afterwards: 17 files, 810 passed.
Six commits. No agent-launch contract moved: agent-launch-intent, the shared launch params, the executor and the mobile task module are all byte-identical to the merge base. protocol-version.ts did change, but not for this work - #20767 adds BROWSER_IDENTITY_RUNTIME_CAPABILITY ('browser.identity.v1'). Checked rather than assumed, because that file is one of the ones #20999 moves; agent.launch.v2 is still absent from main, so nothing here adapts to it. Twelve goldens conflicted, all on recorderSha256/adapterSha256. Both sides re-record, so neither side's hashes fit the merged source. Re-recorded, seeded from theirs so a recorder that failed to run would fail loudly. Twelve files written by the re-record; the other 705 changed goldens were staged by the merge and are main's. Behaviour-preserving, by multiset comparison of added vs removed content lines with pool keys and hash fields normalised out: net added: 0 net removed: 0 Only the 24 source-hash lines moved - a pure recorder-source shift with no semantic change. Re-validated in normal (non-record) mode: 17 files, 821 passed.
…h receipt main landed `unchecked-rpc-reader-inventory.ts`, a ratchet on RpcOperation readers that re-type their reply instead of validating it. Its ceiling for mobile-workspace-create-operations.ts is 4, counted on a tree without this branch's `agentLaunchRun`, so the merge produced "listed 4, found 5". The inventory's own header prescribes this case: a merge is the one time a line goes up without a migration undoing itself, and the instruction is to raise it and name the PR that brought it. It describes main landing an operation the branch never saw; here it is the mirror - the branch holds one main had not seen - so the line is annotated with #19850 rather than left bare. Not converted to `rpcResultVariant(variant, schema)`, which would lower the line instead. That is a validation change rather than a migration, which is exactly what the file's own comment says these five readers deliberately are not; the agent.launch reply is already guarded at the consumer, where readAgentLaunchCreateOutcome returns null on a malformed payload and the create surfaces "Failed to create workspace". Writing a schema now would also target a reply shape #20999 is actively redefining. Ablated: with the line back at 4 the ratchet fails "listed 4, found 5"; at 5 it passes.
There was a problem hiding this comment.
✅ No new issues found in this delta. Approval is withheld only because an earlier Pullfrog thread on the base branch's replay behavior (
agent-launch.ts, now outside this PR's diff) is still open — nothing in these commits touches it.
Reviewed changes
This run reviews the delta since the prior pullfrog review at 5c58ad38fd — merge a599c3bca1 ("Merge branch 'main' ...") and commit 313f356a32 ("chore(mobile): raise the unchecked-reader ceiling for the agent.launch receipt").
mainmerged in, with a mechanical golden re-record — all 705 goldens now carry one uniformrecorderSha256 d08bf9cd…andbaseline a28085ad…; the 12 settings goldens keepadapterSha256 c2eed306…. No golden body changed, so every PR behavioural assertion still holds. The merge also re-wrapped two main-side files (serve-stdout-boundary.ts,BrowserPane.tsx) into their single-line form;oxfmt --checkpasses on the merged tree and fails on main's multi-line version, so that is a formatting fix rather than a formatting violation.- The
agent.launchreader is named in the unchecked-reader inventory —mobile-workspace-create-operations.ts's ceiling moves 4 → 5 with a comment naming#19850, following the inventory's own merge rule. The file holds fiverpcUncheckedPayloadReadercalls, so the listed ceiling matches what the ratchet will observe, and no other entry changed.
Verification this run: all 705 goldens share the single new recorder hash and baseline; oxfmt --check clean on the two re-wrapped files. mobile/node_modules is absent here, so the mobile suite was not run.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Every golden and the scenario manifest take main's fenced corpus: the 705 shared goldens are byte-identical to `origin/main` and the manifest keeps main's `baseline` (9add08b). The branch's 11 scenarios and 31 goldens ride along unrecorded here; the next commit repins and re-records them. `unchecked-rpc-reader-inventory.ts` auto-merged cleanly: the session block stays deleted, and main's raise of `mobile-workspace-create-operations` from four readers to five (#19850's `agent-launch-receipt`) survives. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…agent (stablyai#19850) * refactor(agent-launch): make the launch-mode decision surface-neutral `decideWorkerStartMode` was the only shared answer to "structured chat session or terminal agent?", but it lived in an orchestration-named module and spoke orchestration's vocabulary, so the other launch surfaces could not call it. Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave `orchestration-worker-start-mode` as the adapter that supplies the noun. A worker is not a special kind of launch; it is the same launch with a dispatch attached. Naming the receipt's subject is the only thing orchestration actually contributed, so that is the only thing the adapter keeps: "worker" in both sentences, plus the `--terminal` wording, which reads as nonsense anywhere a `--terminal` flag does not exist. Both are pinned, because they are asserted. No behavior change. The receipts are byte-identical for every reachable case, proven by running the new pin against both implementations. Also pins the wording, which nothing was holding. The existing suites assert `toContain` fragments ('terminal agent', 'cannot create') and the CLI suite asserts a receipt handed to it by a mock rather than one this code produced; all six files stayed green against a deliberately corrupted vocabulary. A dispatch receipt is the only place a structured-to-terminal downgrade explains itself, so the whole sentence is the contract, not a fragment of it. * feat(agent-launch): add the launch intent and the one executor that runs it The sequencing around the launch decision was duplicated per surface, and the duplicate is where the bug lives. A new worktree was created agent-first, so its startup terminal WAS the agent and the structured branch below it could never be reached — every new-worktree launch was a PTY regardless of the user's default. Orchestration fixed that for itself in stablyai#19431; mobile and the CLI still have it. `executeAgentLaunch` inverts the order once, for everyone. When the preference is structured the worktree is created with NO startup agent, the executing host is then asked whether it can host a session for the workspace that now exists, and only then is a surface created. The host verdict cannot be hoisted above creation: `agentSession.createSupport` only answers for a workspace it can resolve, which is why the decision stays in two halves. Agent-first creation is deliberately preserved for PTY launches — it is what sequences the agent's startup command behind the setup runner, so wait-for-setup comes for free there. What actually differs per surface is only how a surface is built (an orchestration worker's session takes a dispatch hold and a mailbox a plain launch must not take), so that is injected as a factory rather than branched on. The intent also strips the reserved agent fields from a migrated create payload: a caller moving off `worktree.create` passes its existing params, and a stale `startupAgent` in there would re-create the very path this replaces. Tests assert order and arguments, not just the resulting mode. Reintroducing agent-first creation reddens 4 of 11. * feat(agent-launch): expose the launch executor as the agent.launch RPC Adds `agent.launch` — one host-side method that decides structured-vs-terminal and creates the surface — wired to the real runtime factories: `createManagedWorktree` for the workspace, forking on `startupAgent` exactly as the orchestration worker path does; `createStructuredAgentSessionForWorktree` for a chat session; and `createTerminal` for a PTY agent. Allowlisted for mobile, which is the surface the routing gap was reported on. `worktree.create` is untouched. Its `startupAgent` keeps meaning "spawn a PTY agent" verbatim, because it answers with `agentTerminalHandle` only on that path: a host that quietly routed it to a structured session would hand every older client a response with no handle and no error. All new behaviour sits behind `agent.launch.v1`, which the host now advertises and a remote client must negotiate, so a client that does not gets today's behaviour unchanged. * feat(mobile): route workspace creates through agent.launch Picking an agent on the mobile create sheet always produced a terminal, even when the user's default was native chat, because all three create paths put `startupAgent` on `worktree.create`. That means "create the worktree agent-first", so its startup terminal IS the agent and the structured branch below it is unreachable — while the same phone's in-workspace "+" button opened a chat. The blank, branch and new-branch creates now send the same payload through `agent.launch` and let the host settle the surface. `worktree.create` is untouched, and a host that does not advertise `agent.launch.v1` (read from the existing `status.get` probe) keeps today's path exactly. Work-item creates stay on `worktree.create`: they pre-fill the issue/PR URL as an unsent `startupDraft`, which a structured session cannot hold yet, so routing them would submit the URL as a first turn. * fix(agent-launch): drop the deleted draft-prompt blocker from the reason map main removed the draft-prompt blocker in stablyai#19681 (a structured session now holds an unsent draft), so the exhaustive Record no longer typechecks. * chore(agent-launch): carry a SAFETY rationale on the agent placement cast The type-assertion gate landed after this branch's base, so the new file's copy of the worker-start cast is now a changed-code finding. * chore(agent-launch): carry agent.launch through main's RPC typing and casting gates The typed-method contract, the generated params catalog and the `assertionStyle: never` casting scan all landed after this branch's base. - AGENT_LAUNCH_METHODS kept an `RpcMethod[]` annotation, which widened its method name to `string` and broke assignability; every sibling infers instead. - `agent.launch` binds a schema under src/main, so it joins the catalog's RPC_METHODS_WITHOUT_SHARED_PARAMS and the parity gate's hand-listed twin. - The now-typed methods make most test casts unnecessary; the few that remain carry the line-specific SAFETY rationale the casting gate requires. * test(mobile): supply the agent-launch fixture the create-submit recording needs The golden RPC recordings landed upstream while this branch was out, so they first met agent.launch here. Three things had to happen, and only one of them is a fixture bump. 1. workspace-settings-mounts.ts mounts useNewWorkspaceCreateSubmit against a fixture model that throws on any member it was not given. This PR added a required getAgentLaunchSupport, so the submit aborted with "Missing model fixture" before it ever issued the create, and three cleanup checkpoints vanished. That read like a product regression and was not one. Supplying the member restores the recording byte-for-byte; it is pinned false for the same reason the cutover probe is, so the baseline stays on worktree.create. 2. Editing that adapter moves adapterSha256 for the twelve settings goldens it mounts. Their recordings are unchanged - header only, by design: the digest is per-golden so editing a module fails exactly the goldens that mounted it. 3. Five goldens changed behaviourally, and both changes are this PR's: the capability probe now reports agentLaunch, and a create whose reply carries no worktree returns "Failed to create workspace" instead of throwing a TypeError off an unguarded result.worktree read. The launch route needs that guard, since a receipt can arrive without a worktreeId. * refactor(mobile): decode the launch receipt instead of asserting its shape The changed-code quality gate refuses type assertions, and the eight it flagged were worth removing rather than suppressing. The production one was the point. readAgentLaunchCreateOutcome asserted the RPC payload into Partial<AgentLaunchResult> and then runtime-checked it anyway, so the assertion bought nothing and claimed a contract the host had not proven. It now narrows with `in` and validates each hop, which is the same nullability question readCreateResult already answers on the sibling path - a launch receipt can legitimately arrive without a worktreeId. AgentLaunchCreateOutcome ties worktreeId to the shared contract so a change there fails this reader's typecheck rather than passing a differently-typed field through. The test fakes claimed a whole RpcClient via `as unknown as RpcClient` while implementing one member. They now build a typed literal, matching the pattern in use-mobile-structured-agent-options.test.ts. The read sites cast params and then read one field; they now assert the payload with toMatchObject, which removes the cast and pins more of the shape than the cast did. Also pins the warning passthrough, which nothing covered: a terminal launch that seats the workspace but cannot start the pty reports why, and the absent, blank, non-string and structured-surface cases report nothing. Writing that test caught a real drop I had introduced in the reader. * ci(mobile): re-run Mobile Checks when a shared capability changes Mobile Checks is path-filtered to mobile/**, but mobile imports the negotiated capability names straight from src/shared/protocol-version.ts and records the whole capability read verbatim in its goldens. So a capability added desktop-side rewrites a mobile fixture while never triggering the suite that would catch it. That is what happened here: stablyai#19849 introduced agent.launch.v1 and Mobile Checks never ran on it. Verified at the run level rather than by check name - the window-free check-runs API on 3837ae8 returns 49 check-runs across six runs (PR Checks x2, PR test LoC x2, Track Community PRs, Review) and no Mobile Checks among them. The breakage surfaced only in this PR, which happens to touch mobile/**. The workflow already concedes this pattern for terminal-file-link-conformance.ts; protocol-version.ts has the stronger claim, since mobile records its output. Also corrects the mount adapter's SAFETY comment. It claimed the recorder supplies only the members the hook reads, which was false the moment the hook gained a required getAgentLaunchSupport - and the assertion it annotates is exactly what stopped the compiler from saying so. The twelve goldens are adapterSha256 churn from that comment: every body is byte-identical, which is the digest doing its job. * docs(agent-launch): stop the receipt-wording comment claiming a migration The decision was never moved out of orchestration-worker-start-mode; this PR adds a second copy beside it. Say so, and name the unenforced agreement. * docs(agent-launch): stop the executor comment claiming a migration that has not happened The header asserted two things the tree does not support: that every launch surface routes through the executor, and that the mode decision "already lived" in `agent-launch-mode`. `agent.launch` is the executor's only consumer, and `orchestration-worker-start-mode.ts` is byte-identical (blob 92dc5c6, 217 lines) at the merge base and all three stack heads, still used by workers.ts. Describe the two live copies and leave the cutover to later stack work. * fix(agent-launch): preserve setup and refusal fallbacks * refactor(mobile): parse the launch outcome into a named type at its boundary anti-slop/no-object-parameters flagged terminalLaunchWarning's `result: object`. The rule is pointing at a real seam rather than a style nit: the helper advertised a loose object and did the narrowing inside itself, so every caller handed it unparsed wire data and nothing downstream held a real type. Parsed at the boundary instead. parseTerminalLaunchOutcome takes `unknown` and returns TerminalLaunchOutcome | null, so the narrowing happens once, where the untrusted payload enters, and the consumer works with a named type. The type is taken from the shared contract rather than restated - a Pick over the terminal member of AgentLaunchOutcome - so a change to that union fails here instead of flowing through. `handle` is deliberately excluded: nothing reads it, and requiring it would drop the warning off a reply that omitted one, which is a behaviour change smuggled in under a typing change. No assertion and no config exemption: reintroducing `as Partial<AgentLaunchResult>` would trade this finding for the defect removed earlier in this branch, and the rule is correct here. The rule arrived with the merge-forward (stablyai#20781, newer than this branch's merge-base), and anti-slop is not one of the changed-code gate's six scans - it runs only repo-wide - which is why a clean local gate did not predict it. Behaviour is unchanged across all five warning cases, and the positive case was re-ablated on the new parser: dropping the warning reddens exactly it, 1 failed | 18 passed, restored byte-identical to 19 passed. * fix(agent-launch): dedupe complete launch and cancel setup wait * fix(agent-launch): memoize the whole launch so a replay cannot mint a second session A replayed agent.launch could create a second structured session in the same worktree, with activate: true. dedupeWorktreeCreate wrapped only the worktree half, inside the workspace factory. On a replay the create was reused, and the executor then continued to createSurface and built another surface inside it. The terminal route hid this: its cached create carries a startup terminal handle, so the executor returns on early. A structured create has no handle by construction - that is the whole point of the structured fork - so it fell through every time. Mobile replays this method deliberately on a delivery-ambiguous response, up to five attempts, so the path is reachable by design rather than in theory. The handler now wraps the entire launch in the same dedupe, on the same (repo, clientMutationId) identity, exactly as worktree.create wraps its own body. A replay returns the original AgentLaunchResult instead of re-running createSurface, which makes the two routes replay-identical. The inner dedupe is removed rather than kept. Wrapping both levels on one key deadlocks: dedupeWorktreeCreate stores the in-flight promise before the inner call runs, so the inner call would be handed the outer's promise, which is waiting on it. The launch-level memo subsumes the worktree-level one. Failures are still dropped rather than cached, so an unknown outcome stays unknown instead of replaying as a fabricated success. The guard replays a STRUCTURED launch: the terminal route cannot reproduce this and a test there would pass either way. Ablated against the pre-fix files - 1 failed | 22 passed, "expected vi.fn() to be called 1 times, but got 2 times", which is the duplicate session - then restored to 23 passed. The stub's dedupe had to be made faithful for that to be observable; the shared one passes through so other tests can see raw calls. * Revert "fix(agent-launch): memoize the whole launch so a replay cannot mint a second session" This reverts commit 59bc5e9. The same defect was already fixed upstream on this stack's base branch by 539e283, which landed while this was being written. That change is broader (it also cancels the setup wait) and namespaces the dedupe key, so it supersedes this one. Reverting rather than hand-merging keeps a single implementation instead of a hybrid nobody chose. The behavioural guard from this commit is ported back on top of the upstream implementation separately: it asserts exactly one structured session survives a replay, where the upstream tests assert the dedupe wiring. * ci(mobile): close the round-1 signal gaps around agent.launch Three review findings, all narrow. Mobile Checks is path-filtered, and this branch made mobile's types depend on the shared RPC contract: rpc-params-contract.ts is a type-only re-export of the generated params catalog, and mobile/tsconfig.json includes **/*.ts. So a desktop-only edit under src/shared/rpc-contract/ could break mobile's typecheck with no mobile signal at all - the same blind spot the protocol-version.ts entry closed, one directory over. Added src/shared/rpc-contract/** to the paths filter. agent.launch had no cross-version trigger. Added the three prefixes a paired peer actually exchanges: the intent contract, the wire schema, and the RPC method. src/main/agent-launch/ is deliberately NOT listed - the executor shapes behaviour but is not itself wire, and AgentLaunchResult's shape is already covered by agent-launch-intent. Extending the cross-version SUITE to cover a negotiated handshake is separate work, not this. The break branch that answers an accepted-but-empty reply with "Failed to create workspace" had no unit coverage; the golden that used to discriminate it collapsed five partitions into one shared error when the null guard replaced the unchecked read. Covered on BOTH routes - worktree.create with no worktree.id and agent.launch with no worktreeId - since the branch serves both. Ablated by bypassing the guard: 2 failed | 11 passed, the two new cases returning a fabricated worktree instead of the error, restored to 13 passed. * fix(agent-launch): give a launch one place to say the workspace is incomplete createManagedWorktree reports an unspawned startup terminal or an uncopied working tree as a top-level `warning`, and worktree.create hands it straight to mobile. The launch path narrowed that result down to {worktreeId, startupTerminalHandle} and dropped it, so every agent.launch create lost a warning the old method surfaces - on both arms. The channel was also asymmetric by accident rather than design: a terminal outcome could carry `warning`, a structured one had nowhere to put it, so the arm this PR exists to enable was the arm that could not report an incomplete create at all. Now there is exactly one place a launch warning lives: AgentLaunchResult.warning, at the top level. It is about the create as often as the surface, it applies to a structured session and a terminal alike, and a reader should not branch on outcome.kind to discover the workspace it just opened is missing something. The terminal arm's own `warning?` is removed rather than left beside it - two homes for one fact is how they drift. Every producer folds in: the create, the surface, and the refusal downgrade. Consumer census before removing it: one production reader (mobile's readAgentLaunchCreateOutcome) and no others - the renderer and mobile launch call sites never read it. The mobile reader now reads the top-level field, which also lets its outcome parser go away entirely. Guard ablated by restoring the pre-fix narrowing: 2 failed | 24 passed, both carriers reporting `expected undefined`, which is the dropped warning itself; restored to 26 passed. The third case asserts an absence and stays green under the mutation by construction - it pins shape, not the defect. * fix(agent-launch): combine both launch warnings instead of dropping one Round 2 found the comment here was false. A create warning and a surface warning CAN both be set, on two reachable paths: 1. The create warns precisely BECAUSE it produced no startup terminal - didSpawnStartup stays false when that spawn throws, and orca-runtime-create-managed-worktree.ts:283 gates startupTerminal on it - so the executor's early return is skipped and a second surface is built, which can warn too. 2. An untracked-copy warning, then a definitive structured refusal downgrading to a terminal that also warns. `??` kept the first and lost the second with nothing saying so. They are now combined the way the create combines its own failures - appendFailure in runtime-local-worktree-terminal-startup.ts, and the startup-terminal catch in runtime-remote-managed-worktree-create.ts - which append rather than replace. The comment is rewritten to say what is true, and records the gap NOT fixed here: a create warning about a failed startup terminal is stale once the launch recovers by building a working one, so a user can be told the agent did not start while looking at it. Distinguishing those needs createManagedWorktree to stop multiplexing two unrelated failures into one string. Guarded and ablated: restoring `??` reddens exactly the new test, with the surface clause missing from the received string; restored to 27 passed. The structured-create stub had to admit its real ok-or-refusal union for the downgrade path to be modellable at all - it previously declared only the ok arm. Also: mobile.yml gains src/shared/agent-launch-intent.ts. It is the sole holder of the agent.launch RESULT shape - the rpc-contract catalog holds params only - and mobile imports it as a value. CROSS_VERSION_WIRE_PREFIXES already treats it as wire-critical; without this, one gate does and the other cannot see it. And the agent-first warning test no longer pairs "startup terminal failed" with a returned handle, a combination the producer cannot emit. * fix(mobile): read a launch warning an older host nests on the outcome agent.launch moved `warning` from the terminal outcome to the top level of the result. That is the right shape - a reader should not branch on `outcome.kind` to learn the workspace it just opened is incomplete - but on the wire it is a REMOVAL, and mobile only read the new place. A host built before the move still advertises the same `agent.launch.v1` capability, so the capability probe cannot tell the two apart and mobile takes this route against one: protocol-version.ts:360 AGENT_LAUNCH_RUNTIME_CAPABILITY is in RUNTIME_CAPABILITIES, the host list orca-runtime-get-status.ts:64 publishes it via status.get; the filter drops only browser.screencast.v1 and three E2E-gated capabilities, never agent.launch agent-launch-executor.ts such a host writes warning INSIDE outcome The result was a regression rather than a contract cleanup: the worktree.create path this replaces returned the warning at the top level and mobile read it, so a create that seated the workspace but could not start the agent surface - pty exhaustion, untracked files not copied - stopped explaining itself on the phone. Read both shapes for as long as such a host can be paired. Top level wins, and cannot be shadowed: AgentLaunchOutcome has no `warning` on either arm, so a current host cannot nest one. The test that pinned the old behaviour is inverted here. Its comment was the actual defect - it framed a legitimate warning from an older peer as a stale shape to defend against, which is what made dropping it look deliberate. * chore(mobile): raise the unchecked-reader ceiling for the agent.launch receipt main landed `unchecked-rpc-reader-inventory.ts`, a ratchet on RpcOperation readers that re-type their reply instead of validating it. Its ceiling for mobile-workspace-create-operations.ts is 4, counted on a tree without this branch's `agentLaunchRun`, so the merge produced "listed 4, found 5". The inventory's own header prescribes this case: a merge is the one time a line goes up without a migration undoing itself, and the instruction is to raise it and name the PR that brought it. It describes main landing an operation the branch never saw; here it is the mirror - the branch holds one main had not seen - so the line is annotated with stablyai#19850 rather than left bare. Not converted to `rpcResultVariant(variant, schema)`, which would lower the line instead. That is a validation change rather than a migration, which is exactly what the file's own comment says these five readers deliberately are not; the agent.launch reply is already guarded at the consumer, where readAgentLaunchCreateOutcome returns null on a malformed payload and the create surfaces "Failed to create workspace". Writing a schema now would also target a reply shape stablyai#20999 is actively redefining. Ablated: with the line back at 4 the ratchet fails "listed 4, found 5"; at 5 it passes. --------- Co-authored-by: Merge Sim <sim@local>

ELI5
On your phone, creating a new worktree with a default agent (Claude/Codex) opened the old terminal chat instead of the new native chat — even though the "+ new agent tab" button in an existing workspace opened native chat correctly. Same phone, two flows, two answers. This makes the create flow ask the same question the rest of the app asks.
Stack: 3 of 5. Stacked on #19849. This is the PR that fixes the reported bug.
What Changed
agent.launch.v1(mobile-runtime-client-capabilities.ts) — without it the method is refused outright.status.getprobe inworktree-create-capability.tsis extended, not duplicated: it already read create-idempotency from that response, and now readsagent.launch.v1from the same shared promise.mobile/src/tasks/agent-launch-worktree-create.tsbuilds the launch request from an existing create payload and decodes the receipt.worktree-create-retry.tsgained an optionalagentLaunch; the route settles once, before the first attempt, so a name-collision retry cannot land on a different method than the attempt it replaced.agent.launch.agentLaunchCreateFieldsrenamedstartupAgentCreateFields— it means "create agent-first", now one of two routes.agent.launchmoved into the shared params catalog, and mobile sends it through a typedRpcOperationrather than the raw request port. See Shared-contract move below — this was forced by gates that postdate the branch, not a drive-by.Why
Mobile's create paths put
startupAgentonworktree.create, which creates the worktree agent-first, so the structured branch was unreachable. Meanwhile the in-workspace "+" button calledcreateMobileStructuredAgentSessiondirectly — which is why one flow worked and the other didn't.Scope boundary: work-item creates deliberately excluded
buildTaskWorkspaceCreateParamssetsstartupDraft: item.source.urlwhenever an agent is picked, unconditionally — so every agent-carrying work-item create has an unsent draft. Structured sessions cannot hold an unsent draft today, and three call sites already forward drafts asprompt, which the structured outbox sends immediately (its states arequeued | dispatching | unconfirmed; there is no held state). Routing work items now would silently turn the issue URL into a submitted first turn nobody pressed enter on, with nothing going red.So both work-item entry points stay on
worktree.create.createWorkItemWorkspacedoes not acceptagentLaunchSupported, so it cannot be wired up by accident. Pinned by a test.Shared-contract move: forced, and why this shape
src/main/runtime/rpc/methods/agent-launch-schemas.tsbecame a re-export of a newsrc/shared/rpc-contract/agent-launch-params.ts, and the generated params catalog was regenerated. Reviewers will reasonably ask why a mobile PR moves shared-contract files, so:mobile/src/transport/unvalidated-rpc-request-port-boundary.test.tsholds the raw-sendRequestboundary as an inventory and fails with "New code must send through an RpcOperation. Nothing may be added to unvalidated-rpc-request-port-inventory.ts." Upstream had also just migratedworktree-create-retry.tsoff that port, so re-introducing a raw sender there was closed.defineRpcOperationrequiresMethod extends RpcMethodName, andagent.launchsat inRPC_METHODS_WITHOUT_SHARED_PARAMS.src/main.AgentLaunchbinds onlyzod,isTuiAgent,TuiAgentandWorktreeCreate— andsrc/main/.../worktree-create-schemas.tsis itself a bare re-export ofsrc/shared/rpc-contract/worktree-create-params. Nothing reached intosrc/main.worktree-create-schemas.tsis exactly this re-export pattern.RPC_METHODS_WITHOUT_SHARED_PARAMSdrops to three entries, and'agent.launch'was removed from the hand-maintainedUncataloguedMethodtwin inrpc-params-type-parity.ts.verify:rpc-params-catalog --checkpasses, so the generated file is not hand-edited drift.Behaviour changes a reviewer must see
Two, both deliberate and neither a fixture bump:
readCreateResultpreviously readresult.worktree.displayNameunguarded, so a reply missingworktreesurfaced asTypeError: Cannot read properties of undefined (reading 'worktree'). It now returns{ error: 'Failed to create workspace' }. The launch route requires this: a launch receipt can legitimately arrive without aworktreeId. This is visible as a recorded-behaviour change inmatrix-worktree.create-retry-worktree.create-1.warningis carried on both routes. Upstream addedwarningpassthrough onworktree.createwhile this branch was out; it would have been silently dropped on the newagent.launchroute. A terminal launch that seats the workspace but cannot start the pty now still reports why — dropping it is what leaves the phone on an unexplained empty session. Newly pinned by test, including the absent, blank, non-string and structured-surface cases.Merge notes
Merged
brennanb2025/agent-launch-rpcrather than rebasing. Five conflicts, all inmobile/; four were plain unions. Three things auto-merged outside any conflict region and are worth naming, since zero conflict markers did not mean a correct tree:WorkspaceCreateParams(nowRpcSendParams<'worktree.create'>) silently replacedRecord<string, unknown>in untouched regions.worktreeCreateRun.interpretcontract replaced the oldRpcSuccesscast.warningpassthrough above.The golden RPC recordings (
mobile/rpc-foundation/goldens) landed upstream and metagent.launchhere for the first time. Seventeen were updated: twelve are header-only (adapterSha256, bodies byte-identical) because the settings mount adapter was edited, and five changed behaviourally for the two reasons above. The adapter edit itself is a fixture gap, not a product change —observableModelthrows on any member it was not given, so the newly requiredgetAgentLaunchSupportmade the recorded submit abort before issuing its create. It is pinnedfalse, like the cutover probe beside it.CI gap this PR closes
Mobile Checks is path-filtered to
mobile/**, but mobile imports the negotiated capability names directly fromsrc/shared/protocol-version.tsand records the whole capability read verbatim in its goldens. Soagent.launch.v1— added desktop-side in #19849 — rewrote a mobile fixture without ever triggering the suite that would have caught it, and the breakage surfaced only here, in the first PR of the stack that touchesmobile/**.Verified at the run level rather than by check name (the workflow is named Mobile Checks but its job is
verify, so filtering check names for "mobile" returns zero even for PRs where it demonstrably ran): the window-free check-runs API on the base commit returns 49 check-runs across six runs — PR Checks ×2, PR test LoC ×2, Track Community PRs, Review — and no Mobile Checks among them.mobile.ymlnow listssrc/shared/protocol-version.tsin its paths filter, matching the existingsrc/shared/terminal-file-link-conformance.tsprecedent, which is there for the same reason.Linked Issue
Fixes #
Visual Proof
None. No device or emulator QA was performed on this PR. The constraint under which it was revived prohibits computer-use and OS-level automation, so the mobile UI was not exercised end to end by anything here. Coverage is unit/integration only.
This is an outstanding gap before merge, not a completed step — the user-visible behaviour this PR claims to fix has not been observed on a device.
Testing
All figures measured at the current head, not carried over from an earlier one.
tsc --noEmit: clean. Mobileoxlint: clean. Mobileoxfmt --check: clean across 1,974 files.pnpm tcdoes not covermobile/. It checkstsconfig.node.json,tsconfig.tc.cli.jsonandtsconfig.tc.web.jsononly; mobile has its owntsconfigand is typechecked by the Mobile Checks workflow. A greenpnpm tcon a mobile PR says nothing about mobile, andmobile/node_modulesis empty until you install that workspace separately. Mobile's typecheck above was run explicitly.src/main/runtime/rpcandsrc/shared/rpc-contract. Rootpnpm tc,oxlintandoxfmt --checkclean.verify:rpc-params-catalog --checkclean.consistent-type-assertionsfindings; those were removed rather than suppressed — the production one by narrowing the receipt withininstead of asserting it, the test ones by building a typedRpcClientliteral and asserting payloads withtoMatchObject.agentLaunchSupported: falseand assert the wire call isworktree.createwithstartupAgent/createdWithAgent. Every pre-existing create test is pinned tofalse, so they guard the legacy payload byte-for-byte.method_not_found/forbidden/agent_launch_unsupported— the advertisement race), the same candidate re-sends asworktree.createand stays downgraded.max-linesdisable or cap bump. No lockfile in any commit;pnpm-lock.yamlandmobile/pnpm-lock.yamlare byte-identical to the merge base.Ablations: recorded at
57883f0e19(the pre-merge head) and NOT re-proven across the merge. Eleven ablations were red on their intended tests and reverted — including A2 (ignore the probe), A3 (don't strip reserved fields), A6 (route work-items), A7 (remove the method-refusal downgrade). Treat them as evidence about that commit only: a later commit can add a second reason an assertion holds, so ablation evidence does not automatically survive a merge. The newly added warning-passthrough test was written against the fixed reader and has not been ablated either, though it is deterministic that it discriminates — it asserts a field the unfixed reader omitted.Reviewer attention: post-create navigation is unverified against a live host
No route param or pending tab id was seeded. The reasoning:
agent.launchcreates the session withactivate: true, and the host setsactiveTabIdbefore the RPC answers, so the fresh route's first snapshot already marks the chat active andresolveActiveSessionTab's snapshot-active fallback selects it. Same ordering keepsshouldAutoCreateInitialSessionTerminalfrom firing.That avoided re-pinning ~10 SHA constants in the route-parity ratchet for a mechanism argued to be redundant with host activation — but it is the exact user-visible step this PR claims to fix, and it has not been exercised end to end. A contract pin was added in
active-session-tab.test.ts; it is a pin, not an ablation, and is green either way by design.Platforms: macOS host.
mobile/is a separate pnpm workspace and was installed with--frozen-lockfile; zero lockfile drift.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Mixed versions: old mobile + new host keeps working (
worktree.createunchanged). New mobile + old host falls back via the capability probe, proven by test rather than inspection. New mobile + new host routes correctly.Note
mobile/src/session/mobile-session-route-parity.test.tsis a re-pin ratchet over the session route source family; it passes unmodified here because no file in that family was touched. ItstoHaveLength(5)is over calls insideSessionScreenand is unrelated to the advertised capability list.Security: no new surface beyond the allowlisted method —
agent.launchwas already in the mobile method allowlist. Cross-platform: no platform-dependent paths. Remote SSH: remote hosts downgrade to terminal. Performance: one extra capability read on an existing probe response — no additional round-trip.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)