Repository navigation
fix(agent-launch): resolve a launch scope, not a git worktree record - #21193
Conversation
`agent.launch` asked the runtime for a managed worktree record and then read exactly one field off it, `.id`. That record does not exist for every workspace a launch can run in, so the request refused launches the method could otherwise run: the floating workspace resolves to a scope with an id and a path but no worktree row, and `showManagedTerminalWorkspace` throws `selector_not_found` rather than hand back the id it had already resolved. A folder workspace survived that only because the resolver fabricates a worktree row for it. The scope is the answer that is real for all three kinds, so the launch asks for that instead. `showManagedTerminalWorkspace` is unchanged - callers that genuinely need the git record still get it, and still get the refusal. With floating now reaching the mode decision, the host must know which kind of workspace it resolved. The kind is derived from the id it resolved itself, never accepted from a caller, and the route module's existing `floating` blocker does the rest: a workspace with nowhere to keep a session runs a terminal agent. Behaviour change, deliberate: a floating-workspace `agent.launch` used to fail with `selector_not_found` and now succeeds as a terminal agent. That is what lets the floating titlebar agent button move onto the shared launch command instead of driving tab startup itself. No wire change: `AgentLaunchTarget` is untouched.
|
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 (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds a shared workspace-kind type and resolver. Existing workspace launches now resolve a general launch scope for git worktrees, folder workspaces, and the floating sentinel. The host passes the resolved kind into launch-mode selection. Floating workspaces use terminal launches. Folder workspaces and git worktrees use structured sessions. Tests and fixtures update the runtime method and cover each workspace kind. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The floating-workspace launch path is covered for scope resolution and terminal routing, with no concrete merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, deliberate behavior change, testing, and out-of-scope work. However, it omits the required Linked Issue entry, Visual Proof or an explicit N/A explanation, the testing checklist items, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the final Checklist. Resolution Add a valid issue reference under Linked Issue, such as
✨ 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.
✅ No new issues found.
Reviewed changes
- Resolve a scope, not a worktree record —
agent.launchnow resolves an existing workspace through the newshowTerminalWorkspaceLaunchScopeinstead ofshowManagedTerminalWorkspace, so the floating sentinel resolves to anid/pathscope rather than throwingselector_not_found. Only.idwas ever read, and the folder scope id (folder:<id>) matches the fabricated worktree row's id, so git/folder behavior is unchanged. - Host-derived workspace kind —
executeAgentLaunchderivesworkspaceKindfrom the resolved id via the sharedworkspaceKindForWorktreeIdand forwards it throughdecideAgentLaunchModeintoresolveStructuredNativeChatSupport, making the pre-existingfloating-workspaceblocker reachable on the host. - Shared helper —
workspaceKindForWorktreeIdmoved from the renderer tosrc/shared/workspace-launch-kind.tsand is re-exported from its old home;WorkspaceLaunchKindreplaces the duplicated inline unions inagent-launch-routing.tsandstructured-native-chat-launch-route.ts. - Tests — executor tests pin floating→terminal and folder/git-worktree→structured; the RPC fixture and replay tests follow the renamed resolver.
ℹ️ Mobile reachability of the floating sentinel
The PR body flags this as unverified. It resolves cleanly: mobile's only agent.launch producer is agentLaunchCreateParams in mobile/src/tasks/agent-launch-worktree-create.ts, which always builds { kind: 'create-worktree', create: … }. No mobile code constructs an existing target, so widening which selectors the RPC accepts does not change mobile behavior.
Technical details
# Mobile cannot address an existing workspace via agent.launch
## Evidence
- `mobile/src/tasks/agent-launch-worktree-create.ts:36` — `agentLaunchCreateParams` returns `target: { kind: 'create-worktree', create: … }` unconditionally.
- A repo-wide grep of `mobile/` for `kind: 'existing'` returns no matches; the only `agent.launch` callers (`worktree-create-retry.ts`, `blank-workspace-create.ts`, `source-workspace-create.ts`) all route through that builder.
- `mobile/src/tasks/mobile-workspace-create-operations.ts:28` is the only `agent.launch` operation binding.
## Required outcome
None — informational only. If a future mobile surface starts sending `existing` targets, the floating sentinel becomes addressable from a phone, which is the product question the author raised.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is a single test-only commit, 901f0df, which directly closes the coverage gap that review flagged (no direct test of the new scope method's floating resolution).
- Floating resolution covered against the real resolver — the new
agent-launch-floating-workspace.test.tsconstructs a realOrcaRuntimeServiceand assertsshowManagedTerminalWorkspacestill rejectsselector_not_foundfor both the bare andid:-prefixed floating sentinel, whileshowTerminalWorkspaceLaunchScoperesolves each to{ id, path: homedir(), connectionId: null, repo: null, folderWorkspace: null }. - Launch decision pinned through the RPC boundary — for a floating target and both values of
openAgentTabsInChatByDefault,agent.launchsettles on a terminal (structured_unsupported_on_host/user_default), never callsgetStructuredAgentSessionCreateSupportorensureStructuredAgentSessionHost, and creates the terminal forid:global-floating-terminal.
Verified locally: the new file runs 6/6 green and oxlint reports no findings.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Electron/SSH validation at
The app used isolated user data and stayed hidden throughout CDP validation. A macOS Keychain setup stall required restarting the disposable app with Chromium's test keychain switch. All test terminals, app processes, container, and temporary keys were cleaned up. Grok could not run because its weekly quota was exhausted; these screenshots and checks were performed by the review coordinator using Playwright CDP. Live Windows/WSL and native mobile UI were not exercised. Floating terminal: SSH terminal: |
|
Review status at
Outstanding: CI shard 7 fails the untouched terminal hook-parity assertion (209 expected, 211 observed). The test passes at this PR head; newer base code adds the two hooks. Resolve that integration failure outside this focused fix before merging. Live Windows/WSL, native mobile UI, old-client replay, network fault injection, and release-scale performance benchmarks were not run; no corresponding behavior or wire-format change was introduced here. No merge performed. |
…tablyai#21193) * fix(agent-launch): resolve a launch scope, not a git worktree record `agent.launch` asked the runtime for a managed worktree record and then read exactly one field off it, `.id`. That record does not exist for every workspace a launch can run in, so the request refused launches the method could otherwise run: the floating workspace resolves to a scope with an id and a path but no worktree row, and `showManagedTerminalWorkspace` throws `selector_not_found` rather than hand back the id it had already resolved. A folder workspace survived that only because the resolver fabricates a worktree row for it. The scope is the answer that is real for all three kinds, so the launch asks for that instead. `showManagedTerminalWorkspace` is unchanged - callers that genuinely need the git record still get it, and still get the refusal. With floating now reaching the mode decision, the host must know which kind of workspace it resolved. The kind is derived from the id it resolved itself, never accepted from a caller, and the route module's existing `floating` blocker does the rest: a workspace with nowhere to keep a session runs a terminal agent. Behaviour change, deliberate: a floating-workspace `agent.launch` used to fail with `selector_not_found` and now succeeds as a terminal agent. That is what lets the floating titlebar agent button move onto the shared launch command instead of driving tab startup itself. No wire change: `AgentLaunchTarget` is untouched. * test(agent-launch): cover floating RPC workspace resolution



What was wrong
agent.launchasked the runtime for a managed worktree record and then read exactly one field off it —.id:showManagedTerminalWorkspacethrowsselector_not_foundwhen there is no git worktree row. But not every workspace a launch can run in has one. The floating workspace resolves to a perfectly good scope — anidand apath— withmanagedWorktree: null, so the launch refused a workspace whose id it had already resolved.A folder workspace survived this only because the resolver fabricates a worktree row for it (
folderWorkspaceToResolvedWorktree, used in 8 places). So the design already accepted that a launch target need not be a real worktree — it just said so by faking one.The fix
The launch asks for the scope, which is the answer that is real for all three workspace kinds. A new
showTerminalWorkspaceLaunchScopeexposes what the resolver already computed.showManagedTerminalWorkspaceis unchanged. Callers that genuinely need the git record still get it, and still get the refusal — only whatagent.launchasks for changed.With floating now able to reach the mode decision, the host has to know which kind of workspace it resolved. That kind is derived from the id the host resolved itself, never accepted from a caller — a caller-supplied kind is a caller that can route around the decision. The route module's existing
floatingblocker and its reason mapping then do the rest; both already existed and were simply unreachable because nothing supplied the kind.workspaceKindForWorktreeIdmoved from the renderer tosrc/shared/workspace-launch-kind.tsand is re-exported from its old home, so both sides of the launch ask the same question of the same function rather than keeping two copies.Deliberate behaviour change
A floating-workspace
agent.launchused to fail withselector_not_foundand now succeeds as a terminal agent.This is the point of the change — it is what lets the floating titlebar agent button move onto the shared launch command instead of driving tab startup itself — but it is a real product change and is called out rather than left to be discovered. A floating workspace can never resolve structured: it has nowhere to keep a session, and the receipt says so.
No wire change.
AgentLaunchTargetis untouched; no new target arm, no new field.Verification
pnpm tc→ exit 0.pnpm test src/main/agent-launch src/main/runtime/rpc/methods→Test Files 196 passed (196),Tests 1970 passed (1970).pnpm test src/renderer/src/lib src/shared/...launch-route.test.ts→Test Files 570 passed (570),Tests 5538 passed | 1 skipped.oxlinton all changed files → exit 0. Gates re-run after commit, because the pre-commit hook runsoxfmt --writeand a reflow can break a lint directive.pnpm-lock.yamlverified byte-identical toorigin/mainand absent from the commit (tooling rewrote it three times during test runs; restored each time).Ablation — the floating test was proven to pin the change, not merely accompany it. Removing
workspaceKindfrom the executor's placement (substitution asserted to match exactly once, so it could not silently no-op) produced:Restored and re-proved green at the final head. The folder and git-worktree tests pass in both arms by design — they are non-regression guards, and a regression in either would have shown up in the ablated arm too.
Not done here
queueTabStartupCommanddirectly; this only removes the reason it could not stop.agent.launchcaller and this widens which selectors the RPC accepts. I did not establish whether mobile can address the floating sentinel. Worth a look before this is relied on.