Skip to content

refactor(automations): main creates an automation workspace's setup and default tabs - #28130

Merged
Jinwoo-H merged 5 commits into
mainfrom
feat/automation-terminals-from-main
Oct 13, 2026
Merged

Jinwoo-H merged 5 commits into
mainfrom
feat/automation-terminals-from-main

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​181 $\color{#cf222e}{\Huge{\mathbf{−}}}$​535 $\color{#cf222e}{\Huge{\mathbf{−}}}$​354
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 $\color{#cf222e}{\Huge{\mathbf{−}}}$​423 $\color{#cf222e}{\Huge{\mathbf{−}}}$​390

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:

  • English "Setup" title for non-English users. The automation's "Setup" tab now shows the English word "Setup" in every language, the same as command-line and app-window creates already do. Before, only automations showed a translated title (for example 設定 in Japanese). Main has no translator it can use here: its translator loads Electron, which the headless runtime must not load.
  • No split-mode pane title. In split setup mode, the setup pane no longer gets its own "Setup" pane title. The split looks the same as a command-line create's, which never set one.

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 uses provisionWorktreeTerminals, the same function the command-line create uses. The create result no longer includes setup or defaultTabs, so nothing else starts them a second time.
  • orca-runtime-activate-managed-worktree.ts: provisionManagedWorktreeTerminals is now public so that create path can call it.
  • createLocalWorktree now 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.ts no longer starts terminals after the create.
  • Deleted from the window:
    • launch-worktree-background-terminals.ts (310 lines) and its test;
    • background-pane-exit-output.ts (46 lines). Its only importer was the file above:
      $ rg -l "background-pane-exit-output" src tests
      src/renderer/src/lib/launch-worktree-background-terminals.ts
      
    • the now-unused Setup title string, from all six locale files.

The tab layout is the same as before:

  • the repo's default tabs, in order;
  • for split setup mode, a split of the first default tab (or of a new shell when there are none);
  • for new-tab mode, a "Setup" tab after them.

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; see docs/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:

  • Moving all default and setup tab creation to main, including creates from the app window. That cannot land on its own yet. In those creates the window starts the agent itself, and the agent's tab is both the pane setup splits from and the first default tab. It waits until main also starts that agent.

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.ts checks that:

    • an automation create provisions once in main and returns no setup or defaultTabs;
    • a Windows runner path picks the Windows command and a POSIX path picks POSIX;
    • a create from the app window still hands setup to the window.
    • Three of the four tests fail without the change.
  • The src/main/ipc, src/main/runtime, src/main/automations and src/renderer/src/hooks suites 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

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

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 9ea2abac-ae3e-4392-b83a-04836e60a616
📥 Commits

Reviewing files that changed from the base of the PR and between 0f0614b and eae041c.

📒 Files selected for processing (1)
  • src/main/ipc/worktree-remote.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

The main process now provisions terminals for automation-created worktrees and omits terminal launch data from those responses. Non-automation worktree creation retains its existing response behavior. The renderer-side terminal launcher, its tests, and background-pane helper are removed. Related dispatch tests, translations, and tracking entries are updated.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to eae04

Automation workspace setup can run twice, or fail to launch with no renderer fallback. These workflow-affecting issues should be fixed before merge.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. 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 is concise, specific, and accurately identifies the main change: moving automation workspace setup and default-tab creation into main.
Description check Passed The description is detailed and mostly complete. It explains the user-visible behavior, implementation, rationale, testing, compatibility impact, and visual-proof exception. It also documents automate…
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.
  • 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f59a60d7-aa64-42a8-b483-d2e01c9ac9b2
📥 Commits

Reviewing files that changed from the base of the PR and between 92a520c and 9a718da.

📒 Files selected for processing (16)
  • config/focus-setting-read-baseline.txt
  • config/scripts/ci-shard-timings.json
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees-automation-create-terminals.test.ts
  • src/main/runtime/orca-runtime-activate-managed-worktree.ts
  • src/renderer/src/hooks/automation-dispatch-workspace.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/background-pane-exit-output.ts
  • src/renderer/src/lib/launch-worktree-background-terminals.test.ts
  • src/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.

Comment thread src/main/ipc/worktree-remote.ts Outdated
Comment on lines +1697 to +1699
args.automationProvenance && (setup || defaultTabs?.tabs.length) ? runtime : undefined
if (hostProvisioner) {
void hostProvisioner.provisionManagedWorktreeTerminals(

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 | 🟠 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. ()

Comment thread src/main/ipc/worktree-remote.ts Outdated
Comment on lines +1725 to +1726
...(hostProvisioner
? {}

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 | 🟠 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.

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

E2E at 9a718da (base 845b723):

  • Targeted run of the three layout-oracle specs and the three automation specs: 38328901299, passed.
  • Full suite on this PR: 38328903416, 19 failing tests.
  • Full suite on main at the same base: 38328905503, 28 failing tests.
  • 17 of this PR's 19 failures also fail on main. The other two, each re-run once on both:
    • ssh-orcad-terminal-root-owner passed on this PR in 38331624204.
    • terminal-inline-tui-reveal-convergence failed on this PR in that run, in a different test, at the fixture's own premise check ("fixture stopped streaming while hidden"). A second targeted run passed on both: 38333004019 on this PR and 38333006810 on main. This PR does not touch terminal reveal.

Jinwoo-H and others added 2 commits October 12, 2026 21:49
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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 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 win

Do not provision setup again after staged startup already spawned it.

If an automation create supplies startup and setup without default tabs, spawnLocalStartupAndSetupTerminals spawns setup and sets stagedStartup.didSpawnSetup. This branch does not check that flag. It then calls provisionManagedWorktreeTerminals with the same setup, so the setup script runs twice. The same applies to the startup terminal: hasStartupTerminal is always false here, even when stagedStartup.startupTerminal exists.

Gate the setup handoff on the staged result. Pass hasStartupTerminal from stagedStartup.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
📥 Commits

Reviewing files that changed from the base of the PR and between 16baf3d and 085f261.

📒 Files selected for processing (9)
  • src/main/ipc/worktree-remote.ts
  • src/main/runtime/runtime-worktree-terminal-provisioning.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/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(

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 | 🟠 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.
@Jinwoo-H
Jinwoo-H merged commit ef890ae into main Oct 13, 2026
30 checks passed
yoelfme added a commit to yoelfme/orca that referenced this pull request Oct 14, 2026
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]>
frbarbre added a commit to frbarbre/orca that referenced this pull request Oct 15, 2026
…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.
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