Repository navigation
fix(cli): keep automated worktree creation in background - #11445
Conversation
Greptile SummaryThis PR fixes two overlapping activation bugs that caused automated worktree creation (
Confidence Score: 5/5Safe to merge; the changes are surgical one-liners in two production files and are fully covered by regression tests across all three affected code paths. Each of the two root-cause sites receives a minimal, targeted fix (removing Boolean(startupAgent) from the activate expression and changing runHooks: setupDecision === 'run' to runHooks: false). The PR explicitly preserves backward-compatible behavior for --run-hooks and explicit --activate. Three independent regression test cases cover CLI, local orchestration, and federated orchestration paths; setup policy coverage (run/skip/inherit) is also verified. No existing tests were weakened — assertions were only tightened or expanded. Files Needing Attention: No files require special attention. The production changes are in worktree.ts, orchestration-worker-topology.ts, and orchestration-federation.ts — all straightforward and consistent with each other.
|
| Filename | Overview |
|---|---|
| src/cli/handlers/worktree.ts | Removes Boolean(startupAgent) from the activate expression; --agent alone no longer focuses the new worktree. Change is minimal and correct. |
| src/main/runtime/rpc/methods/orchestration-worker-topology.ts | Sets runHooks: false so setup is driven solely by setupDecision, eliminating the activation side-effect of the legacy runHooks flag. |
| src/main/runtime/rpc/methods/orchestration-federation.ts | Applies the same runHooks: false fix as the local topology path for the connected-server (federated) worker creation path. |
| src/cli/index.test.ts | Updates CLI regression tests: --agent alone now expects activate: false, and a separate test verifies --activate still produces activate: true. |
| src/main/runtime/rpc/methods/orchestration-workers-new-worktree.test.ts | Updates setup policy test to assert runHooks: false and activate: false for all setup values (run/skip/inherit). |
| src/main/runtime/rpc/methods/orchestration-federation.test.ts | Adds runHooks: false assertion alongside existing activate: false check; also refactors the dispatch_input effects assertion to a type-safe approach. |
| skill-guides/orca-cli.md | Corrects the skill guide bullet to state --agent alone stays in the background; only --activate and --run-hooks reveal the new worktree. |
| src/cli/bundled-skill-guides.ts | Regenerates the bundled ORCA_CLI_MARKDOWN constant to match the updated skill-guides/orca-cli.md. |
| src/main/runtime/rpc/methods/orchestration.test.ts | Updates local orchestration test to expect runHooks: false and activate: false when setup=run is passed to worker-start. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[orca worktree create] --> B{flags passed?}
B -->|--agent only| C[startupAgent set\nactivate = false\nrunHooks = false]
B -->|--activate| D[activate = true\nrunHooks = false]
B -->|--run-hooks| E[activate = true\nrunHooks = true\nlegacy compat]
B -->|neither| F[activate = false\nrunHooks = false\nbackground]
C --> G[worktree.create RPC]
D --> G
E --> G
F --> G
subgraph orchestration["Orchestration worker-start (local + federated)"]
H[worker-start request\nsetup=run/skip/inherit] --> I[setupDecision = params.setup]
I --> J[runHooks = false\nactivate = false\nsetupDecision passed]
J --> K[createManagedWorktree]
K --> L{setupDecision?}
L -->|run| M[Setup hooks run\nno activation]
L -->|skip| N[Setup skipped\nno activation]
L -->|inherit| O[Repo policy\nno activation]
end
G --> P{activate?}
P -->|true| Q[Workspace revealed\nin Orca UI]
P -->|false| R[Stays in background]
Reviews (1): Last reviewed commit: "fix(cli): keep automated worktree creati..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughUpdated worktree creation semantics so agent startup remains backgrounded unless activation is explicit. The CLI handler now derives activation only from 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
Description
orca worktree create --agent ...in the background unless the caller explicitly passes--activate.orchestration worker-startrun setup throughsetupDecisionwithout also setting the legacy focus-coupledrunHooksflag.Root cause and version boundary
There were two overlapping activation paths:
d10d01919a(June 2, before both v1.4.155 and v1.4.159) made--agentimplyactivate: truein the CLI.cd05f2ff93added the composed orchestration worker path. It correctly sentactivate: false, but also sentrunHooks: truefor setup. The runtime treats legacyrunHooksas both “run setup” and “activate,” so the latter overrode the background request. That commit first appears in the v1.4.160-rc.1/v1.4.160 release line.ELI5
Creating an automated worker should be like opening a new browser tab in the background. Orca was also pressing the new tab for you because the old “run setup” switch secretly doubled as a “show this workspace” switch. This separates those jobs: setup still runs, but only an explicit
--activatechanges what the user is looking at.Proof of regression
The tests were changed and run before production code:
activate: false, receivedactivate: truewhen only--agentwas present.runHooks: false, receivedrunHooks: truewithsetupDecision: runandactivate: false.runHooks: trueoverride reproduced on the connected worker server.Proof of fix
pnpm run typecheck:node: passed.pnpm run typecheck:cli: passed.pnpm run check:code-quality:changed: 0 new findings.pnpm run verify:bundled-skill-guides: passed.Proof of no regression
--activatestill sendsactivate: true.--run-hooksstill runs setup and activates, preserving its documented compatibility behavior.setup=run|skip|inheritstill produces truthful setup receipts and agent-first terminal creation.