Skip to content

fix(agent-launch): resolve a launch scope, not a git worktree record - #21193

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/agent-launch-host-workspace-kind
Sep 17, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/agent-launch-host-workspace-kind

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72

What was wrong

agent.launch asked the runtime for a managed worktree record and then read exactly one field off it — .id:

const workspace = await runtime.showManagedTerminalWorkspace(params.target.worktree)
return { kind: 'existing', worktree: workspace.id }

showManagedTerminalWorkspace throws selector_not_found when 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 — an id and a path — with managedWorktree: 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 showTerminalWorkspaceLaunchScope exposes what the resolver already computed.

showManagedTerminalWorkspace is unchanged. Callers that genuinely need the git record still get it, and still get the refusal — only what agent.launch asks 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 floating blocker and its reason mapping then do the rest; both already existed and were simply unreachable because nothing supplied the kind.

workspaceKindForWorktreeId moved from the renderer to src/shared/workspace-launch-kind.ts and 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.launch used to fail with selector_not_found and 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. AgentLaunchTarget is 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.
  • oxlint on all changed files → exit 0. Gates re-run after commit, because the pre-commit hook runs oxfmt --write and a reflow can break a lint directive.
  • pnpm-lock.yaml verified byte-identical to origin/main and 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 workspaceKind from the executor's placement (substitution asserted to match exactly once, so it could not silently no-op) produced:

× runs the floating workspace as a terminal, never a structured session
Tests  1 failed | 15 passed (16)

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

  • No call site is migrated. The floating titlebar button still drives queueTabStartupCommand directly; this only removes the reason it could not stop.
  • The mobile reachability question is UNVERIFIED: mobile is a live agent.launch caller 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.

`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.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cdeb5e44-8b24-41c7-9a8e-a418f53f94b9

📥 Commits

Reviewing files that changed from the base of the PR and between 5804651 and 901f0df.

📒 Files selected for processing (1)
  • src/main/runtime/rpc/methods/agent-launch-floating-workspace.test.ts

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


📝 Walkthrough

Walkthrough

The 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 901f0

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 exp… Add a valid issue reference under Linked Issue, such as Fixes #123``. Add Visual Proof with N/A and explain why no visual or interaction change requires evidence, or attach the required before-and-after evidence. Complete the required che…
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: resolving a launch scope instead of requiring a managed git worktree record.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description 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 Fixes #123``. Add Visual Proof with N/A and explain why no visual or interaction change requires evidence, or attach the required before-and-after evidence. Complete the required checklist sections and explicitly address AI Disclosure, Review, Agent skill upstream boundary, Notes, and the testing checkboxes.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Resolve a scope, not a worktree record — agent.launch now resolves an existing workspace through the new showTerminalWorkspaceLaunchScope instead of showManagedTerminalWorkspace, so the floating sentinel resolves to an id/path scope rather than throwing selector_not_found. Only .id was 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 — executeAgentLaunch derives workspaceKind from the resolved id via the shared workspaceKindForWorktreeId and forwards it through decideAgentLaunchMode into resolveStructuredNativeChatSupport, making the pre-existing floating-workspace blocker reachable on the host.
  • Shared helper — workspaceKindForWorktreeId moved from the renderer to src/shared/workspace-launch-kind.ts and is re-exported from its old home; WorkspaceLaunchKind replaces the duplicated inline unions in agent-launch-routing.ts and structured-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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No 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.ts constructs a real OrcaRuntimeService and asserts showManagedTerminalWorkspace still rejects selector_not_found for both the bare and id:-prefixed floating sentinel, while showTerminalWorkspaceLaunchScope resolves 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.launch settles on a terminal (structured_unsupported_on_host / user_default), never calls getStructuredAgentSessionCreateSupport or ensureStructuredAgentSessionHost, and creates the terminal for id:global-floating-terminal.

Verified locally: the new file runs 6/6 green and oxlint reports no findings.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron/SSH validation at 901f0df24092:

  • Real agent.launch succeeds for the floating workspace. With structured chat preferred, it returns a terminal with structured_unsupported_on_host; the actual CLI renders in the floating pane.
  • A non-Git folder also launches a terminal successfully.
  • A disposable Linux ARM64 SSH target running the demo repository successfully launches Claude through the real RPC and relay. The remote process tree and /proc working directory confirm execution in /work/demo-project; the repository stays clean. The rendered screen below is the CLI's initial setup screen, not a completed agent task.

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:

Floating agent terminal

SSH terminal:

Agent terminal in disposable Linux SSH repository

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status at 901f0df24092: no remaining in-scope code findings; not yet an all-green merge recommendation.

  • Correctness: The fix removes the actual failure: a valid floating terminal scope was rejected because launch unnecessarily demanded a managed Git worktree record. Git and folder selection retain their existing validation.
  • Architecture: Retain this approach. The execution host resolves the workspace and derives its kind, then reuses the existing surface policy. No extra cache, retry loop, stored state, or parallel guard is introduced. Floating remains the existing terminal-only sentinel in the executing host's home directory; this does not add persistent projectless workspaces or structured chat there.
  • Review change: Pushed 901f0df24092, adding six tests through the real runtime resolver and RPC. Restoring the old lookup makes four cases fail with selector_not_found; the final version passes all six. No additional production rewrite or scope expansion was justified.
  • Validation: 105 focused existing tests plus six new cases passed; node typecheck, changed-file lint, changed-lines quality checks, and relay build passed. Real hidden Electron floating/folder launches and a disposable Linux SSH launch passed; screenshots and cleanup details are in the QA comment.
  • Independent review: Same-model/thinking review and final eight-section readiness audit returned clean, with no proven correctness, security, compatibility, or performance findings. The separately dispatched beginning-readiness worker stalled on provider reconnects and did not return a completed report; the final audit examined the production baseline and final test-only commit. Grok QA was unavailable due to weekly quota.

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.

@brennanb2025
brennanb2025 merged commit b66ef2e into main Sep 17, 2026
28 of 30 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant