Skip to content

feat(cli): launch agents in existing workspaces - #27794

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agent-launch-command-split
Oct 12, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agent-launch-command-split

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

In an existing workspace, the CLI's documented way to start a new agent ran a command in a terminal. That bypassed the user's Chat UI setting, so a user who expected a chat got a terminal. orca agent launch --agent <id> now starts the agent through Orca's normal launch route. It opens a chat when the setting and agent support one, and a terminal otherwise.

What Changed

  • Added orca agent launch for an existing worktree or folder workspace, with an optional first prompt, model, reasoning effort, and --focus.
  • The host chooses the surface and returns the agent handle, what opened, and why. A lost reply can be checked with --retry-launch without starting a second agent.
  • Preserved the chosen background or focus behavior when the execution host and viewing client differ. Help and the bundled orca-cli guide now point existing-workspace starts to this command.

Why

The app already has one launch route that applies the Chat UI setting and delivers the first prompt. The CLI calls that route instead of constructing an agent command for a terminal. #27796 routes orca worktree create --agent through the same path; keeping that change separate makes the new command reviewable on its own.

Linked Issue

Part 1 of Linear STA-10160 (agent handoffs bypass the Chat UI preference). This adds the existing-workspace command; #27796 adds the new-worktree fix.

Visual Proof

Chat UI on: chat tab · Chat UI off: terminal tab. These are from the original combined review of the same launch path.

Testing

  • Focused CLI, host, and renderer suites: 1,446 passed, one skipped.

  • orca-ci-checks: 24/24 passed, including lint, code quality, localization, and typechecks.

  • The original combined review exercised the compiled CLI in a hidden macOS Electron renderer with Chat UI both on and off. Linux, Windows, and SSH UI flows were not manually run for this split branch.

  • GitHub CI passed. One unchanged macOS daemon timing test missed its limit by 1 ms on the first run; that five-test file passed locally and the failed CI job passed on its single rerun.

  • I manually tested this launch path in a hidden macOS Electron renderer during the combined review

  • Automated tests added/updated

Review

This is the command and the host support it needs. The worktree creation behavior is in #27796, based on this branch.

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

The host decides chat versus terminal on local, paired, and SSH workspaces. Older hosts without the required launch capabilities refuse the command before creating anything. The CLI keeps the same replay identity across retries.

Checklist

  • This PR is focused on launching an agent in an existing workspace
  • The user-facing before/after, mechanism, and alternative are explained
  • Visual proof is linked above
  • Correctness, security, performance, cross-platform, SSH, and compatibility were reviewed in the combined PR
  • Local static checks and GitHub CI passed

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The CLI adds orca agent launch for launching an agent in an existing workspace. It validates launch preferences and runtime capabilities, supports operation-ID replay and recovery, and reports launch results. Runtime and renderer changes pass presentation rules through terminal creation and apply them to agent tabs. Help text, guides, and tests cover the command and presentation behavior.





Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 8164b

Retrying a lost launch reply from a different environment could start a second agent. Bind the retry to the original host or avoid generating that command; the risk is otherwise limited to this routing change.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 35 files. (2 skipped:… 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 main change: adding CLI support to launch agents in existing workspaces.
Description check Passed The description is complete and relevant. It covers the user-facing change, implementation, rationale, testing, visual proof, compatibility considerations, and checklist items. The linked issue is ide…

Full details: Docstring Coverage

Explanation

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


  • 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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38142591-e7f4-4fcb-80b0-cc363aec45fb
📥 Commits

Reviewing files that changed from the base of the PR and between ae0ff63 and 8164b3e.

📒 Files selected for processing (38)
  • config/scripts/vitest-sqlite-runtime-files.mjs
  • skill-guides/orca-cli.md
  • skill-guides/orchestration.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/index-agent-launch.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-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-notifier-contract.ts
  • src/main/runtime/runtime-terminal-contracts.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

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

Comment on lines +30 to +46
const args = recovery.rawArgs && recoverableOrchestrationArgs(recovery.rawArgs)
const retryArgs: string[] = []
for (let index = 0; index < (args?.length ?? 0); index++) {
const arg = args?.[index]
if (arg === '--retry-launch') {
index++
} else if (arg && !arg.startsWith('--retry-launch=')) {
retryArgs.push(arg)
}
}
const recoveryCommand =
args && recovery.operationId
? [
resolveOrchestrationCliExecutable(),
...retryArgs,
'--retry-launch',
recovery.operationId

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- recovery helper ---'
nl -ba src/cli/agent-launch-recovery.ts | sed -n '1,180p'
printf '%s\n' '--- references ---'
rg -n -F --glob '*.ts' -- 'withCliAgentLaunchRecovery' src/ || test "$?" -eq 1
rg -n -F --glob '*.ts' -- '--retry-launch' src/cli src/main src/shared || test "$?" -eq 1
printf '%s\n' '--- launch/worktree references ---'
rg -n -F --glob '*.ts' -- 'agent launch' src/cli src/main src/shared || test "$?" -eq 1
rg -n -F --glob '*.ts' -- 'worktreePath' src/cli src/main src/shared || test "$?" -eq 1
printf '%s\n' '--- environment selector references ---'
rg -n -F --glob '*.ts' -- 'ORCA_ENVIRONMENT' src/cli src/main src/shared || test "$?" -eq 1
printf '%s\n' '--- diff summary ---'
git diff --stat ae0ff6315219fa0492bd2e874954f992bc859694 8164b3ea919da937875aa0e7967aeebd2f95e7ad -- src/cli/agent-launch-recovery.ts src/cli

Repository: stablyai/orca

Length of output: 45661


🏁 Script executed:

set -eu
for f in \
  src/cli/agent-launch-request.ts \
  src/cli/handlers/agent-launch.ts \
  src/cli/agent-workspace-selector.ts \
  src/cli/runtime/orchestration-recovery-command.ts \
  src/cli/execution-host-flag.ts \
  src/cli/runtime/client.ts \
  src/cli/index-agent-launch.test.ts
do
  printf '\n--- %s ---\n' "$f"
  nl -ba "$f"
done

Repository: stablyai/orca

Length of output: 42731


Do not emit an unbound retry command for ambient ORCA_ENVIRONMENT.

When a remote agent launch --worktree ... loses its reply, callAgentLaunch passes the operation ID and raw arguments to withCliAgentLaunchRecovery. The helper copies the raw arguments but does not copy an ambient ORCA_ENVIRONMENT value. A retry run under another configured environment can therefore reach a different host, find no journal row for the operation ID, and admit it as a new launch.

Keep the executable recovery command when the original arguments contain an explicit --environment or --host selector. When routing came only from ambient ORCA_ENVIRONMENT, omit that command or bind it to the original non-secret selector.

Suggested fix
     for (let index = 0; index < (args?.length ?? 0); index++) {
       const arg = args?.[index]
       if (arg === '--retry-launch') {
         index++
       } else if (arg && !arg.startsWith('--retry-launch=')) {
         retryArgs.push(arg)
       }
     }
+    const hasExplicitExecutionSelector = retryArgs.some(
+      (arg) =>
+        arg === '--environment' ||
+        arg.startsWith('--environment=') ||
+        arg === '--host' ||
+        arg.startsWith('--host=')
+    )
     const recoveryCommand =
-      args && recovery.operationId
+      args &&
+      recovery.operationId &&
+      (!process.env.ORCA_ENVIRONMENT || hasExplicitExecutionSelector)
         ? [
             resolveOrchestrationCliExecutable(),
             ...retryArgs,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const args = recovery.rawArgs && recoverableOrchestrationArgs(recovery.rawArgs)
const retryArgs: string[] = []
for (let index = 0; index < (args?.length ?? 0); index++) {
const arg = args?.[index]
if (arg === '--retry-launch') {
index++
} else if (arg && !arg.startsWith('--retry-launch=')) {
retryArgs.push(arg)
}
}
const recoveryCommand =
args && recovery.operationId
? [
resolveOrchestrationCliExecutable(),
...retryArgs,
'--retry-launch',
recovery.operationId
const args = recovery.rawArgs && recoverableOrchestrationArgs(recovery.rawArgs)
const retryArgs: string[] = []
for (let index = 0; index < (args?.length ?? 0); index++) {
const arg = args?.[index]
if (arg === '--retry-launch') {
index++
} else if (arg && !arg.startsWith('--retry-launch=')) {
retryArgs.push(arg)
}
}
const hasExplicitExecutionSelector = retryArgs.some(
(arg) =>
arg === '--environment' ||
arg.startsWith('--environment=') ||
arg === '--host' ||
arg.startsWith('--host=')
)
const recoveryCommand =
args &&
recovery.operationId &&
(!process.env.ORCA_ENVIRONMENT || hasExplicitExecutionSelector)
? [
resolveOrchestrationCliExecutable(),
...retryArgs,
'--retry-launch',
recovery.operationId

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Agent launch QA (macOS, PR commit 8164b3e)

Previously, starting another agent in an existing workspace required creating a terminal directly. I tested whether the updated orca-cli guide leads real agents to the new command and whether Orca opens the kind of tab selected by the Chat UI setting.

  • In an isolated, hidden Electron build on M4Air, a real Claude agent read the PR guide and chose orca agent launch to start Codex in the existing workspace. The launch receipt reported a terminal, and the Codex tab appeared in the rendered app.
  • A real Codex agent first reached a different installed Orca CLI that lacked agent launch, so it used that CLI's terminal create fallback. After binding it to this PR's dev CLI, Codex read the same guide and chose agent launch to start Claude. The Claude tab appeared in the rendered app. This was a QA CLI path mismatch, not a failure of the PR command.
  • Direct CLI checks with the PR build returned a structured Codex chat when Chat UI was on and a Claude terminal when it was off. CDP inspection showed both tabs and the delivered prompts; both agents acknowledged their prompts.

The agent prompts named the guide but did not name the launch command. Automatic discovery of the skill stub was not tested. No PR files were changed.

@brennanb2025
brennanb2025 merged commit e3ef95d into main Oct 12, 2026
86 of 88 checks passed
hiphapis added a commit to hiphapis/orca that referenced this pull request Oct 15, 2026
Only src/cli/bundled-skill-guides.ts conflicted; it is generated, so it was
regenerated rather than hand-resolved. Upstream's guidance changes land around
this branch's edits without touching them: the circuit-breaker and retry-release
paragraphs in references/recovery-and-cleanup.md (stablyai#27795), and the orca-cli
launch-flag note in the kernel's role table (stablyai#27794, stablyai#27796).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_011nnNsG3p4Do9eiyfXGr2rB
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