Repository navigation
refactor(automations): main creates an automation workspace's setup and default tabs - #28130
Conversation
…p and default tabs An automation's create handed setup and default tabs back to the window, which launched them through its own background-terminal code. Main now provisions them through the same provisionWorktreeTerminals the CLI create uses, and returns neither, so setup runs once and the window's copy is deleted.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f59a60d7-aa64-42a8-b483-d2e01c9ac9b2
📒 Files selected for processing (16)
config/focus-setting-read-baseline.txtconfig/scripts/ci-shard-timings.jsonsrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-automation-create-terminals.test.tssrc/main/runtime/orca-runtime-activate-managed-worktree.tssrc/renderer/src/hooks/automation-dispatch-workspace.tssrc/renderer/src/hooks/useAutomationDispatchEvents.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/background-pane-exit-output.tssrc/renderer/src/lib/launch-worktree-background-terminals.test.tssrc/renderer/src/lib/launch-worktree-background-terminals.ts
💤 Files with no reviewable changes (12)
- src/renderer/src/lib/launch-worktree-background-terminals.test.ts
- config/focus-setting-read-baseline.txt
- src/renderer/src/hooks/automation-dispatch-workspace.ts
- config/scripts/ci-shard-timings.json
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/lib/background-pane-exit-output.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/lib/launch-worktree-background-terminals.ts
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/es.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| args.automationProvenance && (setup || defaultTabs?.tabs.length) ? runtime : undefined | ||
| if (hostProvisioner) { | ||
| void hostProvisioner.provisionManagedWorktreeTerminals( |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not provision setup after staged startup already spawned it.
If an automation create supplies startup and setup without default tabs, spawnLocalStartupAndSetupTerminals spawns setup first. This branch then provisions setup again because it does not check stagedStartup.didSpawnSetup. Gate the setup handoff on the staged result so the script runs once. ()
| ...(hostProvisioner | ||
| ? {} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Retain launch data when host provisioning cannot spawn terminals.
If a runtime exists but its provisioning host reports canSpawn() === false, provisionWorktreeTerminals returns without creating a terminal. hostProvisioner remains truthy, so this branch still removes setup and defaultTabs from the response. A caught provisioning failure has the same handoff problem. Base the omission on a confirmed provisioning outcome, and preserve or report work that did not launch.
|
E2E at 9a718da (base 845b723):
|
Main had no copy of the automation path's translated title, and the window and CLI creates used the English literal. All three now read worktree.setupTabTitle through the existing main and renderer translators. The create path's runtime is required, since every production caller passes it.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Do not provision setup again after staged startup already spawned… · worktree-remote.ts:1695-1711
src/main/ipc/worktree-remote.ts:1695-1711
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDo not provision setup again after staged startup already spawned it.
If an automation create supplies
startupandsetupwithout default tabs,spawnLocalStartupAndSetupTerminalsspawns setup and setsstagedStartup.didSpawnSetup. This branch does not check that flag. It then callsprovisionManagedWorktreeTerminalswith the samesetup, so the setup script runs twice. The same applies to the startup terminal:hasStartupTerminalis alwaysfalsehere, even whenstagedStartup.startupTerminalexists.Gate the setup handoff on the staged result. Pass
hasStartupTerminalfromstagedStartup.startupTerminal.Proposed fix
- if (provisionedByHost && (setup || defaultTabs?.tabs.length)) { + const setupForHost = stagedStartup.didSpawnSetup ? undefined : setup + if (provisionedByHost && (setupForHost || defaultTabs?.tabs.length)) { void runtime.provisionManagedWorktreeTerminals( { worktreeSelector: `id:${worktree.id}`, worktreeId: worktree.id, worktreePath: worktree.path, - ...(setup ? { setup } : {}), + ...(setupForHost ? { setup: setupForHost } : {}),This duplicates the earlier review comment, which is still unresolved.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
37667122-3dc4-446f-ad87-88fabb59d8ac
📒 Files selected for processing (9)
src/main/ipc/worktree-remote.tssrc/main/runtime/runtime-worktree-terminal-provisioning.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/worktree-setup-issue-command-queue.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/es.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| // Why: an automation's terminals start in main, so the window is handed none to launch. | ||
| const provisionedByHost = Boolean(args.automationProvenance) | ||
| if (provisionedByHost && (setup || defaultTabs?.tabs.length)) { | ||
| void runtime.provisionManagedWorktreeTerminals( |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Retain launch data when provisioning does not run.
void discards the promise. provisionWorktreeTerminals returns early when host.canSpawn() is false, and it swallows errors. The response still omits setup and defaultTabs because provisionedByHost depends only on provenance. In those cases no terminal is created and the window has nothing to launch.
Await the result. Omit the launch data only when provisioning actually ran (canSpawn true). Otherwise keep the old fallback fields.
This duplicates the earlier review comment, which is still unresolved.
Also applies to: 1724-1733
…oad main's translator main-i18n imports Electron, which orcad and the runtime must not load. The title stays the English literal the window and CLI creates already use.
Upstream moved worktree background terminals into main (stablyai#28130), so the renderer launcher and its capture-dims change are dropped. Imports follow upstream's moves of isRemoteRuntimePtyId and the eager-buffer exports. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…working on upstream's new layout Restore the background terminal launcher upstream deleted (stablyai#28130) as a fork copy for review workspaces, point the PR comment scope at the moved git identity helper, and record in FORK.md that upstream's own --line/--column (stablyai#28240) retired the fork's.
ELI5
When an automation creates a new workspace, Orca also opens that repo's default terminal tabs and runs its setup script. Until now the app window did that work after main finished creating the workspace. Now main does it, the same way it already does for workspaces created from the command line, and the window's separate copy of that code is deleted.
What Changed
Before and after, as the user sees it: An automation's new workspace still gets its default tabs and its setup script, in the background, without switching to that workspace. The setup script runs once.
Two small visible changes:
Mechanism:
src/main/ipc/worktree-remote.ts: when the create comes from an automation, main now creates the default tabs and runs setup in the background itself. It usesprovisionWorktreeTerminals, the same function the command-line create uses. The create result no longer includessetupordefaultTabs, so nothing else starts them a second time.orca-runtime-activate-managed-worktree.ts:provisionManagedWorktreeTerminalsis now public so that create path can call it.createLocalWorktreenow requires the runtime. Every production caller already passes it, so no path is left that returns setup to a window that would never launch it.automation-dispatch-workspace.tsno longer starts terminals after the create.launch-worktree-background-terminals.ts(310 lines) and its test;background-pane-exit-output.ts(46 lines). Its only importer was the file above:Setuptitle string, from all six locale files.The tab layout is the same as before:
The setup command is built the same way. The runner script's path decides between the Windows (
.cmd) and POSIX command, and a path that is neither falls back to POSIX, as the deleted window code did. So the Windows setup runner and WSL runners are unchanged; seedocs/reference/windows-setup-shell.md.Why
Main already decided who creates these tabs, and for an automation it handed them back to the window to create. That is one decision split across two places, the kind of duplicate that caused the setup-split bug in #28105. Main already does exactly this for command-line and remote creates, so the window's copy can simply go.
Alternatives considered:
Linked Issue
Workspace-layout cleanup, part 2 (follows #28105).
Visual Proof
N/A: the same tabs are created by a different process. The only visible differences are the two Setup title changes described above.
Testing
New
src/main/ipc/worktrees-automation-create-terminals.test.tschecks that:setupordefaultTabs;The
src/main/ipc,src/main/runtime,src/main/automationsandsrc/renderer/src/hookssuites pass (18,169 tests).pnpm tc, the changed-code quality check, and the focus-read, layout-writer and localization checks pass.E2E: the layout-oracle specs and automation specs as a targeted run, plus the full suite compared with main at the same base (runs listed in a comment).
SSH and remote: unchanged. A local create for an SSH repo is refused before this point, and automations on a remote server were already set up by that server; the deleted window code skipped them too. Nothing changes on the wire.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)