Skip to content

fix(cli): start agents through agent.launch so they follow the Chat UI setting - #27638

Closed
brennanb2025 wants to merge 7 commits into
mainfrom
brennanb2025/agent-launch-follows-chat-setting
Closed

brennanb2025 wants to merge 7 commits into
mainfrom
brennanb2025/agent-launch-follows-chat-setting

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by two focused PRs

This combined PR has been split into #27794: launch an agent in an existing workspace and #27796: make worktree create --agent follow the Chat UI setting. Both have passed CI. Review and merge #27794 first; #27796 is based on it and can then be retargeted to main. This PR is kept for its review history and visual proof.

Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1365 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1318
Prod 41 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​887 $\color{#cf222e}{\Huge{\mathbf{−}}}$​202 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​685

ELI5

Starting an agent through the Orca CLI opened a terminal even when the user's setting said new agents should open as chats. This happened during a custom-model worktree handoff because the documented CLI path launched a terminal command directly. The CLI now starts agents through the same host launch route used by the app, so Chat UI on opens a chat when supported; Chat UI off opens a terminal.

What Changed

  • orca worktree create --agent ... now follows the user's new-agent setting. New orca agent launch --agent ... does the same in an existing worktree or folder workspace. Both accept --model and --effort where the chosen agent supports them.
  • A first prompt is delivered through the host launch route. The CLI checks host capabilities before creating anything, refuses unsupported combinations clearly, and preserves the previous terminal startup behavior with older hosts.
  • Launches have a replay ID. If the connection drops after the host may have accepted a launch, the CLI prints a recovery command using --retry-launch so the same operation can be checked without starting another agent. An explicitly empty retry ID is rejected.
  • The orca-cli and orchestration guides describe the setting-aware commands. orca terminal create remains an explicit terminal command.

Why

The original worktree-create API promises a terminal handle, so changing that API would break older clients. The host already owns the chat-versus-terminal decision in agent.launch. Routing CLI starts through it also keeps prompt delivery, remote execution, and model selection in one launch path. The CLI uses the existing terminal-only create path only when talking to an older host, and it refuses options that older path cannot honor.

The separate timeout observed while creating a terminal in the original handoff remains outside this change and needs its own trace.

Linked Issue

Linear STA-10160 (custom-model handoffs bypass the Chat UI preference).

Visual Proof

Chat UI on: Codex Chat tab and model badge · Chat UI off: additional terminal tab. Both screenshots are attached to this PR. They show the rendered tab and sidebar state; the first-prompt result was checked through the compiled CLI and host response.

Testing

  • On an isolated macOS arm64 host, rebuilt the Electron app and CLI, then used Playwright through Chrome DevTools Protocol on a hidden renderer. With Chat UI on, the compiled CLI reported a structured launch and a journaled first prompt; with it off, it reported a terminal launch and a prompt handed to that terminal. The matching tabs rendered. No visible window or desktop input was used.

  • After removing duplicate test cases, the four changed suites passed: 41 tests. The earlier full review run passed 1,435 tests with one skipped; remote QA targeted suites passed 55. Review-specific tests cover replay after lost replies, prompts, setup refusal, folder selection, background/focus presentation, and older-host behavior.

  • GitHub CI passed, including static analysis and typecheck, all five Node test shards, changed end-to-end tests, cross-version wire compatibility, native smoke on macOS/Ubuntu/Windows, and macOS/Windows packages.

  • Local orca-ci-checks: 25/26 passed, including typechecks. Its native code-quality audit rejected five import-cycle warnings in mobile files that are byte-identical to the merged main revision; this PR does not change those files. GitHub static analysis passed.

  • New-worktree launch was not exercised in rendered UI because the remote QA worktree could not safely create a nested checkout. Rendered focus/background feedback and a valid retry after a lost reply were not separately exercised in the app; targeted host/CLI tests cover them. Linux, Windows, and SSH UI flows were not manually run.

  • I manually tested these changes in a hidden macOS Electron renderer

  • Automated tests added/updated

Review

Five initial PR defects, five defects introduced by review fixes, and one final retry-ID defect were fixed and independently re-reviewed. The final architecture check kept the shared host launch route, and the readiness review found no remaining proven P0–P2 issue. The PR is ready for maintainer review.

Agent skill upstream boundary

  • Not applicable; this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mixed-version behavior uses optional host capabilities. Older hosts retain the terminal-only worktree-create contract; the new existing-worktree command requires the newer host route.
  • The host chooses chat or terminal for SSH and paired workspaces. Folder workspaces are supported for existing-workspace launch. No platform-specific shortcut or path parsing was added.
  • Parent-inference warnings are not returned by the new launch result. The parent relationship is still reported. This is a temporary output gap; an optional launch-result field can carry the warnings in a follow-up if needed.

Checklist

  • This PR is focused on setting-aware CLI agent launches
  • The user-facing before/after, mechanism, and alternative are explained
  • Visual proof is attached
  • Correctness, security, performance, cross-platform, SSH, and compatibility were reviewed
  • GitHub CI passed; local gate discrepancy and manual QA limits are recorded above

…I setting

worktree create --agent now goes through the host's shared agent launch
instead of the terminal-only worktree.create startup agent, and a new
agent launch command starts an agent in an existing worktree. Both take
--model/--effort, checked by the rule worker-start already uses, now in
shared. Older hosts keep the startup-terminal path. Skill guides name
these as the way to start an agent.
@OrcaWin

OrcaWin commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Before: starting an agent from the CLI opened a terminal even when Chat UI was enabled.

After: hidden-renderer QA shows the same CLI launch opening a Codex Chat tab with Chat UI enabled, and a terminal tab with Chat UI disabled. The launch used gpt-5.5 with high effort; the first prompt was accepted on each route.

Visual proof:

Chat UI enabled: CLI launch appears as a Codex Chat tab with gpt-5.5.

Chat UI disabled: CLI launch appears as a second terminal tab.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Starting an agent through the Orca CLI could open a terminal even when the user's new-agent setting called for Chat UI. The custom-model handoff guide led the caller through terminal create, and worktree create --agent also used a terminal-only host route.

User-facing result: orca worktree create --agent now follows the setting, and orca agent launch provides the same behavior for an existing worktree or folder workspace. Supported models and effort levels can be selected on either command. Chat UI on opens a chat when the host supports it; Chat UI off opens a terminal. The first prompt follows the launch.

Review status: The loop fixed the original prompt, retry, presentation, setup, and folder-selection defects, then fixed the regressions those changes exposed. A final empty --retry-launch case that could duplicate an agent was also fixed. Independent review of that last change and the final readiness pass found no remaining proven P0–P2 issue. The shared host launch design was retained after two architecture challenges. The PR is still draft.

Verified: The final post-merge focused run passed 1,435 tests (one skipped), and GitHub CI passed static analysis/typecheck, all five Node test shards, changed end-to-end tests, wire compatibility, native smoke on macOS/Ubuntu/Windows, and macOS/Windows packages. On an isolated macOS arm64 host, hidden Electron/CDP QA of the compiled CLI observed a structured launch with its first prompt journaled when Chat UI was on, then a terminal launch with its prompt handed to the terminal when it was off. Attached screenshots show the rendered tabs and sidebar state.

Limits and follow-up: The remote QA run did not render-test new-worktree creation, focus/background feedback, or a valid retry after a lost reply; targeted CLI/host tests cover those paths. Linux, Windows, and SSH UI flows were not manually exercised. Local orca-ci-checks passed 25/26 checks; its native audit rejected five import-cycle warnings in unchanged mobile files inherited from the merged main, while GitHub static analysis passed. The separate terminal-create timeout from the original handoff still needs its own trace. Parent-inference warnings are absent from the new launch result; the parent relationship is still shown, and an optional result field can restore those warnings if needed.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 12, 2026 03:02
@coderabbitai

coderabbitai Bot commented Oct 12, 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: 39d4e18d-ea21-43f4-a387-ca51d04ee408



📥 Commits

Reviewing files that changed from the base of the PR and between 866f396 and 2b3205e.




📒 Files selected for processing (4)
  • src/cli/index-agent-launch.test.ts
  • src/cli/index-worktree-create-agent.test.ts
  • tests/e2e/agent-launch-cli.unit.test.ts
  • tests/e2e/agent-launch-setup-choice.unit.test.ts



💤 Files with no reviewable changes (1)
  • tests/e2e/agent-launch-setup-choice.unit.test.ts



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





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds an agent launch CLI command and routes agent startup during worktree creation through agent-launch operations. It adds shared model and effort validation, replay recovery, setup-choice refusal handling, and long-poll classification. Terminal presentation options now flow from the runtime to the renderer, which applies viewer-specific tab and worktree presentation. CLI guides, help text, and tests are updated.





Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 2b320

Agent launch is mergeable with follow-up, but the CLI test may fail during cleanup on Windows, and one help example may lead users to bypass the Chat UI setting.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 48 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the primary change: routing CLI agent starts through agent.launch so they follow the Chat UI setting.
Description check Passed The description is mostly complete. It includes the required explanation, change details, rationale, linked issue, visual proof, testing results, review notes, compatibility considerations, and checkl…

  • Fix all pre-merge checks with AI
✨ 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.

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54327208-1574-439c-bc66-a1553a46b20f
📥 Commits

Reviewing files that changed from the base of the PR and between 7e0e832 and 866f396.

📒 Files selected for processing (52)
  • config/scripts/vitest-sqlite-runtime-files.mjs
  • skill-guides/orca-cli.md
  • skill-guides/orchestration.md
  • skill-guides/orchestration/references/low-level-topology.md
  • src/cli/agent-launch-recovery.ts
  • src/cli/agent-launch-request.ts
  • src/cli/agent-launch-test-fixtures.ts
  • src/cli/agent-workspace-selector.ts
  • src/cli/bundled-skill-guides.ts
  • src/cli/handler-group-manifest.ts
  • src/cli/handlers/agent-launch.ts
  • src/cli/handlers/worktree-create-agent-launch.ts
  • src/cli/handlers/worktree-lineage-summary.ts
  • src/cli/handlers/worktree-setup-decision-recovery.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index-agent-launch.test.ts
  • src/cli/index-worktree-create-agent.test.ts
  • src/cli/index.test.ts
  • src/cli/index.ts
  • src/cli/root-help-text-primary.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/specs/agent-launch.ts
  • src/cli/specs/core.ts
  • src/cli/specs/index.ts
  • src/main/runtime/orca-runtime-create-terminal-dependencies.ts
  • src/main/runtime/orca-runtime-create-terminal.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-12.spec.ts
  • src/main/runtime/rpc/methods/agent-launch-caller-selection.test.ts
  • src/main/runtime/rpc/methods/agent-launch-failure-code.ts
  • src/main/runtime/rpc/methods/agent-launch-instant-tab.test.ts
  • src/main/runtime/rpc/methods/agent-launch-surfaces.ts
  • src/main/runtime/rpc/methods/agent-launch-tab-publication.ts
  • src/main/runtime/rpc/methods/agent-launch.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts
  • src/main/runtime/runtime-local-worktree-create.test.ts
  • src/main/runtime/runtime-local-worktree-create.ts
  • src/main/runtime/runtime-notifier-contract.ts
  • src/main/runtime/runtime-rpc-long-poll-transport.test.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts
  • src/main/runtime/runtime-terminal-contracts.ts
  • src/main/runtime/worktree-create-setup-choice-refusal.ts
  • src/main/window/runtime-window-lifecycle.ts
  • src/preload/api/ui-bridge-terminal-and-session-tabs.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts
  • src/renderer/src/lib/agent-launch-tab-presentation.ts
  • src/renderer/src/lib/agent-launch-tab-publication.ts
  • src/renderer/src/lib/worktree-creation-backend-startup-focus.test.ts
  • src/shared/agent-launch-model-preferences.ts
  • src/shared/agent-launch-runtime-capability.ts
  • tests/e2e/agent-launch-cli.unit.test.ts
  • tests/e2e/agent-launch-setup-choice.unit.test.ts

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

Comment on lines +119 to +121
' Start agents with `worktree create --agent` (new checkout) or `agent launch` (existing',
' worktree). Both open a chat or a terminal per your Chat UI setting, and take --model/--effort.',
' orca agent launch --agent codex --model gpt-6-astra --effort high',

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the remaining terminal create --command "codex" example.

The new guidance at Lines 119-121 tells users to start agents with agent launch or worktree create --agent. The unchanged example at Line 174 still shows orca terminal create --worktree active --command "codex". That example contradicts the new guidance and bypasses the Chat UI setting. src/cli/specs/core.ts already changed its terminal create examples to pnpm dev. Make this example consistent.

Proposed fix (Line 174)
-  '  $ orca terminal create --worktree active --command "codex"',
+  '  $ orca agent launch --agent codex --worktree active',

Comment on lines +27 to +31
examples: [
'orca agent launch --agent codex --json',
'orca agent launch --agent codex --model gpt-6-astra --effort high --prompt "Write the design doc" --json',
'orca agent launch --agent claude --worktree path:/projects/myapp --focus'
]

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Check whether gpt-6-astra and the 'high' effort are known to the Codex launch catalog.
rg -n "gpt-6-astra" --type=ts -g '!**/*.test.ts' | head -20
rg -nP "unknownModelOptions" --type=ts -C5 src/shared | head -80

Repository: stablyai/orca

Length of output: 40876


Use a model and effort pair accepted by CLI validation.

gpt-6-astra is not listed in the Codex launch catalog. Unknown Codex models use unknownModelOptions, which provides only the ultra effort. Therefore, this documented command can fail with does not support effort high.

Update the example to use a catalog-supported model and effort, or add gpt-6-astra with high support to the Codex catalog.

Comment on lines +41 to +45
afterEach(async () => {
setAgentLaunchRecordStore(null)
vi.restoreAllMocks()
await rm(directory, { recursive: true, force: true })
})

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Close the journal database before removing the test directory.

beforeEach opens a SQLite-backed store through openTestAgentSessionRecordStore(directory). afterEach never calls closeTestJournalHostDatabase(directory). As a result, every test leaves an open database handle, and the directory is removed while that handle is still open. On Windows, rm of a directory with an open SQLite file fails, so this hook can make the suite flaky. The sibling tests/e2e/agent-launch-setup-choice.unit.test.ts already closes the database in its afterEach.

Proposed fix
+import { closeTestJournalHostDatabase } from '../../src/main/native-chat/agent-session-journal/journal-host-database-test-support'
 ...
 afterEach(async () => {
   setAgentLaunchRecordStore(null)
+  closeTestJournalHostDatabase(directory)
   vi.restoreAllMocks()
   await rm(directory, { recursive: true, force: true })
 })

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.

2 participants