Skip to content

A launch can name chat or terminal: agent.launch gets a surface pick and the CLI gets --surface chat|terminal - #31191

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/agent-launch-surface
Oct 20, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/agent-launch-surface

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​270 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​245
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279 $\color{#cf222e}{\Huge{\mathbf{−}}}$​111 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​168

ELI5

Starting an agent from the CLI always followed your Chat UI setting. You can now choose chat or terminal for one launch: orca agent launch --agent claude --surface terminal, or orca worktree create --agent claude --surface chat. Omitting the option keeps the current behavior.

What Changed

The shared agent.launch request carries an optional surface: 'chat' | 'terminal'. The execution host honors it ahead of the relayed default and its own setting. The choice is part of the operation's retry identity, so replay cannot silently change which surface launches.

  • An explicit terminal pick runs the agent's CLI in a terminal.
  • An explicit chat pick opens a chat when feasible. If the host can prove it is impossible before anything is created, the command fails with a message naming the agent and suggesting a terminal. This includes existing SSH/WSL workspaces and a known start directory outside the workspace root. Retrying the same operation returns the same refusal without launching again.
  • A new workspace's actual root may only be known after creation. The host then checks the requested directory against that root: a root directory stays chat-eligible; a subfolder retains the created workspace and starts a terminal in the exact requested directory. A later chat refusal also retains the existing terminal fallback, with “You asked for…” wording in the receipt. If the host's support check is unavailable rather than conclusively negative, the existing fallback remains.
  • The CLI rejects empty, missing and invalid surface values, or a surface without an agent, before sending a launch or create request. Hosts must advertise agent.launch.surface.v1; otherwise the CLI says to update the execution host or omit the option. The check also covers the older workspace-create path.

The host derives directory eligibility from root, custom and unresolved facts. Final refusal versus fallback also depends on whether this operation has already created its workspace. This prevents missing placement facts from becoming a false refusal, and prevents an existing workspace's definite refusal from silently launching the wrong surface.

Why

One optional field on the existing launch request lets each caller express the same per-launch choice without changing a saved setting or introducing another launch operation. That follows the common pattern. A separate field preserves the distinction between the user's default preference and an explicit choice that belongs in retry identity.

Linked Issue

Internal maintainer request. Companion desktop picker tracked in #31189; this CLI/host change is useful independently.

Visual Proof

N/A: no desktop screen changes. Actual CLI subprocess and transport coverage verifies the changed command behavior.

Testing

Full review path: shared request, cross-version capability checks, retry identity and launch selection.

  • Real CLI subprocesses execute the source CLI entry point with the pinned Bun runtime over a real Unix socket or Windows named-pipe transport. Automated host replies verify both commands, chat/terminal propagation, invalid input with no requests, and both older-host capability cases with no mutation. There is no artifact-dependent skip.

  • Host/executor tests cover root and subfolder create requests for worktree and folder workspaces, opposite defaults, late fallback retaining cwd, existing-workspace refusals and replay, and failure accounting after materialization.

  • Fingerprint and worker-launch tests cover omitted-surface compatibility and setting-driven workers.

  • The readiness check ran seven named suites (152 tests); affected CLI-process and executor suites passed again (64 tests) after the CI test typing repair. CI supplies lint, typechecking and platform checks. This is automated CLI QA (qa=tests); no rendered app or real-agent run is claimed.

  • I manually tested these changes locally

  • Automated tests added/updated

Review

Full review loop: two rounds, independent architecture challenge, a three-model design ruling and readiness checklist. The final status comment records fixes, verification and limits.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer implementation is copied or translated.

Notes

  • Intended, inherited from main: terminal and chat creates provision default tabs and setup differently. Terminal creation puts the agent in the first configured tab's slot, uses its title/color and skips that tab's configured command. Chat creation provisions all default tabs and their commands, then setup and chat, with the existing bounded setup wait. A late fallback retains the already-created layout. This PR preserves that behavior; new-workspace first-surface changes are tracked in fix(agent.launch): the creation operation owns a new workspace's first surface #29095.
  • Intended: worker-start keeps following settings; it has no new surface option.
  • Mixed versions: older clients omit the field and keep their behavior. New clients require the capability for an explicit pick. Old paired servers keep their existing launch path; there is no minimum version.
  • Temporary: desktop workspace creation still uses its existing renderer route. The launch-convergence follow-up for desktop worktree and folder creation removes this route; its prerequisites are tracked in fix(agent.launch): the creation operation owns a new workspace's first surface #29095 and fix(session-tabs): open a new workspace on its agent for every viewer that has not picked a tab #29204.
  • Folder workspaces use their host-resolved path. Execution hosts retain authority over chat support; cwd comparison reuses the existing cross-platform path rules.

Checklist

  • One focused launch-choice feature
  • User-facing before/after, mechanism and alternatives explained
  • Visual proof is N/A with reason
  • Cross-platform, SSH/remote and mixed-version impact considered
  • Final review and exact-head CI complete

…ets --surface chat|terminal

agent.launch gains an optional `surface` field, read by hosts advertising
agent.launch.surface.v1. `terminal` always runs the agent's CLI; `chat` runs a
chat even when the user's default is a terminal, and one the host can prove it
cannot open is refused with a typed no-effects error before anything is
created, so a retry answers with the same refusal. The pick is part of the
replay fingerprint. `orca agent launch` and `orca worktree create --agent`
accept --surface chat|terminal and refuse it on a host that would drop it,
including the legacy worktree.create fallback.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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: e5e89234-b406-49cd-a0d0-f53abf5918e6
📥 Commits

Reviewing files that changed from the base of the PR and between 997d34b and cfbcf3a.

📒 Files selected for processing: 28
  • skill-guides/orca-cli.md
  • src/cli/agent-launch-process.test.ts
  • src/cli/agent-launch-request.ts
  • src/cli/bundled-skill-guides.ts
  • src/cli/flag-help-text.ts
  • src/cli/handlers/worktree-create-agent-launch.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index-agent-launch.test.ts
  • src/cli/specs/agent-launch.ts
  • src/cli/specs/core.ts
  • src/main/agent-launch/agent-launch-executor.test.ts
  • src/main/agent-launch/agent-launch-executor.ts
  • src/main/agent-launch/agent-launch-mode.ts
  • src/main/agent-launch/agent-launch-surface-factories.ts
  • src/main/agent-launch/agent-launch-surface-refusal.ts
  • src/main/runtime/rpc/errors.ts
  • src/main/runtime/rpc/methods/agent-launch-failure-code.ts
  • src/main/runtime/rpc/methods/agent-launch-folder-workspace-creation.ts
  • src/main/runtime/rpc/methods/agent-launch-intent-resolution.ts
  • src/main/runtime/rpc/methods/agent-launch-prestart-failure.test.ts
  • src/main/runtime/rpc/methods/agent-launch-tab-publication.ts
  • src/main/runtime/rpc/methods/agent-launch-worktree-creation.ts
  • src/shared/agent-launch-intent.ts
  • src/shared/agent-launch-operation.test.ts
  • src/shared/agent-launch-operation.ts
  • src/shared/agent-launch-runtime-capability.ts
  • src/shared/agent-launch-surface.ts
  • src/shared/rpc-contract/agent-launch-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The CLI and agent.launch contract now support explicit chat and terminal surface selection. Launch-mode logic checks chat feasibility and can refuse unsupported explicit chat requests before launch effects. When a launch falls back to a terminal after workspace creation, the runtime carries the resolved workspace path and launch inputs. Tests cover CLI validation, mode selection, runtime refusal, and replay behavior.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to cfbcf

The surface-selection changes are mergeable after normal checks; no unresolved behavior issue was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 26.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 26 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: per-launch chat or terminal selection through agent.launch and the CLI --surface option.
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.
Description check Passed The pull request description is complete and clearly explains the user impact, implementation, compatibility behavior, testing, scope, and checklist status. The Linked Issue section does not identify …
Full details: Description check

Explanation

The pull request description is complete and clearly explains the user impact, implementation, compatibility behavior, testing, scope, and checklist status. The Linked Issue section does not identify an issue fixed by this PR; it references companion issue #31189 instead, but the rest of the required content is present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 26.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 26 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Agent launches previously followed the saved Chat UI setting, so a CLI caller could not choose chat or terminal for one launch. This PR adds --surface chat|terminal to both agent launch and worktree create --agent, carried by the shared host request. Omitting it preserves current behavior.

The full review completed two rounds, an architecture challenge, a three-model design ruling and the readiness checklist. Fixes removed false chat refusals caused by an unresolved new-workspace root, made conclusive existing-host refusals fail before effects, rejected empty surface values, corrected the guide's fallback promise, added real CLI process/transport coverage and removed lockfile churn. No unresolved findings caused by this PR remain.

An explicit chat that is conclusively impossible before effects fails and replays the same refusal. Unknown support can retain terminal fallback. If chat becomes unavailable after workspace creation, the workspace, setup and default tabs remain and a terminal opens. The CLI rejects an explicit pick before mutation when an older host lacks the capability; callers without a pick retain their existing path. Workers remain setting-driven.

Intended inherited behavior: terminal creation replaces the first configured tab's command with the agent; chat creation runs all configured default tabs before chat. A late fallback retains that provisioned layout. Changing this belongs to #29095. Also deferred outside this PR: an existing recovered launch can retain a stale startup warning even when its agent starts successfully.

Verification: automated CLI QA (qa=tests) runs the real CLI entry point in subprocesses over the real local transport, covering both commands, both surfaces, invalid input and old-host capability gates. Host refusal, replay, root resolution, folder workspaces, early tabs and worker parity passed targeted tests (seven suites / 152 tests at the reviewed implementation; affected suites passed again after the test typing correction). Host replies in the process test are fixtures. No rendered app, real-agent, old-binary or remote-platform run is claimed. Exact-head PR Checks passed, including the aggregate gate, static analysis/typecheck, all selected tests, packages and cross-version checks. One unchanged daemon socket backpressure test failed once, with identical-source passing Linux evidence from two prior runs; its single authorized retry passed. Other selected platform workflows are green. The final main merge was independently checked and introduced no changes to these 28 PR files.

For the lane owner’s review

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