Skip to content

fix(worktrees): a phone or CLI create puts the agent in the first orca.yaml default tab, as the desktop does - #26106

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/host-create-agent-in-first-default-tab
Oct 7, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/host-create-agent-in-first-default-tab

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​422 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​422
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65

ELI5

A repo can list "default tabs" in its orca.yaml, for example a Dev tab that runs pnpm dev and a Tests tab. When you create a workspace with an agent on the desktop, the agent starts in the first of those tabs: that tab takes the template's title, and the template's own command doesn't run (the agent is running there instead).

When the same kind of workspace was created from the phone or the CLI (through the host), the agent got its own extra untitled tab, and then every default tab was created too, the first one running its command. So the workspace had one tab more than the desktop's, and the first template's command (for example a second pnpm dev) ran next to the agent.

This PR makes the host lay the tabs out the way the desktop does.

What Changed

The problem.

  • On the desktop, the window lays out the default tabs and gives the agent the first one (worktree-default-terminal-tabs.ts): tab 1 holds the agent, takes the template's title (as the tab's own title) and color, and skips the template's command.
  • The host's create (createManagedWorktree) starts the agent's terminal first, then provisionWorktreeTerminals created a terminal for every default-tab template. A phone or CLI create in a repo with default tabs and an agent therefore got:
    • an extra untitled agent tab;
    • the first template's tab as well, running its command beside the agent.

User-facing change.

  • A phone or CLI create (local or SSH) in a repo with orca.yaml default tabs and an agent now puts the agent in the first default tab, titled like that template, as on the desktop. The first template's command no longer runs, and there's no extra tab.
  • On the desktop tab strip the tab keeps the template's title even after the agent sets its own terminal title, as a desktop-created tab does. On the phone the tab shows the template's title until the agent sets its own title, then the agent's title, which is how the phone already labels a desktop-created tab.
  • The agent's working/idle status on the phone is unaffected (it still comes from the agent's own titles and hooks).
  • Messages from an orchestration worker created this way are labelled with the tab's title (for example "Dev"), as a desktop-created tab already is.
  • Without an agent, or without default tabs, nothing changes.

The mechanism.

  • When the create started an agent terminal, default-tab provisioning treats it as the first tab: it gives the agent's tab the first template's title and color, then creates only the remaining templates.
  • Titles are set on the tab, not on the terminal: with a window open the window gets the tab's own title (the same title the desktop rule sets, not recorded as a user action); on a host with no window the title is saved on the tab in the workspace session and shown on the phone. The agent's terminal title is never overwritten, which is what keeps the phone's status working.
  • The host finds the tab from the terminal itself, so every create path (local and SSH) gets the same result without passing tab ids around.
  • Every default tab goes through the same title-and-color step, so on a host with no window the titles of the other default tabs are saved on their tabs too (before, they could be replaced by the shell's terminal title there).
  • A failure to title or color a tab is logged and doesn't affect the create; a failed title doesn't skip the color.

Known gap (unchanged from main)

  • With the desktop window open, tab colors set by the host don't reach the window: there is no host-to-window tab-color message yet. That was already true on main for every default tab the host created, so the agent's tab is uncolored there just as main's host-created "Dev" tab was. When the host has no desktop window open (for example orca serve), the color is applied and the phone shows it. Follow-up: add the tab-color message before desktop creates move onto this host path.

Why

  • Why match the desktop's layout. It's the layout users already get from the desktop, and desktop creates are about to move onto this same host path. Doing it here keeps one layout for every caller.
  • Why title the agent's existing tab rather than start the agent inside a template tab. The agent's terminal starts first so setup can run alongside it; titling and coloring that tab gives the same layout without changing when the agent starts.
  • Why a tab title rather than renaming the terminal. Renaming the terminal makes the title outrank every later title the agent sets, so the phone lost the agent's working/idle status (reproduced in a test before the fix). The desktop rule only sets the tab's title; this does the same.

Linked Issue

Part of the new-workspace launch unification (parity fixes before the desktop composer moves onto agent.launch).

Visual Proof

CLI create with an agent (stub) in a repo whose orca.yaml has Dev (runs echo DEV-RAN) and Tests default tabs, desktop window open, macOS.

main this PR
with agent 3 tabs: untitled agent tab, Dev (printed DEV-RAN), Tests 2 tabs: agent in "Dev" (DEV-RAN printed nowhere), Tests
main with agent PR with agent
without agent Dev + Tests, both commands ran unchanged
main without agent PR without agent

Testing

  • New orca-runtime-default-tab-agent-status.test.ts (real runtime, real terminal creation and phone status projection):

    • The phone keeps the agent's "working" status after its tab is titled "Dev". This test failed before the fix with the earlier terminal-rename approach.
    • On a host with no window the title and color are saved on the tab and survive a rebuild of the phone's tab list.
    • Local and SSH agent tabs both get the title and color.
    • The title still reaches the right tab after the window takes over the terminal.
  • runtime-worktree-terminal-provisioning.test.ts (new): the agent's tab takes the first template, only the rest are created; without an agent every template is created; a failed title still applies the color and creates the remaining tabs.

  • worktree-setup-and-startup-part-03.spec.ts: a full host create with an agent and two default tabs makes exactly two terminals (the agent and pnpm test; pnpm dev never runs) and titles the agent's tab "Dev" without recording a user action.

  • orca-runtime.test.ts (1323 passed, 1 skipped), tc:node, tc:web, oxlint and oxfmt.

  • Manual QA (an automated driver on a macOS dev build, desktop window open, CLI creates against a test repo): main vs this PR, with and without an agent; screenshots above. Not exercised live: phone UI, SSH and Windows hosts, and a host with no window (covered by the tests above).

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Notes

  • Chat-mode creates that start a structured chat session (no agent terminal) are unchanged: they get every default tab plus the chat tab, which is also what the desktop does for that launch.
  • Folder workspaces: no default tabs from orca.yaml, unaffected.

Author: @BrennanKB5

… tab, as the window does

With orca.yaml default tabs, the window's create starts the agent in the first
default tab: that tab takes the template's title and color, and the template's
command does not run beside the agent. The host's create started the agent in
its own untitled tab and then created every default tab, the first one running
its command too, so the workspace had one tab more than the window's create.
Now the agent's tab takes the first template's place.
…keeps the agent's status

The host's create titled the agent's tab by renaming the terminal, which
writes the pane's own title stamped to outrank every title the agent sets
later. On a headless host the phone reads status from those titles, so the
agent tab showed the template title forever and lost its working/idle
status. The window's create only sets the tab's custom title.

The host now titles the tab the same way: the window gets the tab's custom
title (not counted as a user rename), and a headless host saves it on the
tab and shows it on the phone until the agent titles itself. The pane's
title is left to the agent.

The host also finds a terminal's tab itself from its handle, so the create
over SSH, which never passed the tab, colors the agent's tab too. Every
default tab is dressed by the same step, so the other tabs' titles are now
kept on a headless host as well, and a failed title no longer skips the
color.
… window adopts its handle

The host found a provisioned terminal's tab only through the runtime's own
pty record. Once the window's graph sync adopts the handle, that lookup
misses, and the default tab's title and color would be dropped with only a
log line. No create reaches it today (the tab is dressed before the window's
first graph sync), but any wait added before provisioning would. It now falls
back to the window's leaf, as renaming a terminal already does.

Tests: the restart case now saves the title to a real session and rebuilds
the phone's tabs from it; a create through createManagedWorktree with an
agent and default tabs spawns the agent and the second template only and
titles the agent's tab "Dev" without counting it as a user rename.
Use a runtime subclass for the protected launch scope and provisioning host,
a typed store and notifier, and typed mocks in place of casts, so the
changed-code quality gate passes.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary

The problem. In a repo whose orca.yaml defines default tabs, creating a workspace with an agent from the phone or the CLI went through the host's create, which made an extra untitled agent tab and then created every default tab, the first one running its command beside the agent (for example a second pnpm dev). The desktop puts the agent in the first default tab instead: that tab takes the template's title and color and the template's command doesn't run.

The user-facing change. A phone or CLI create (local or SSH) with an agent in such a repo now matches the desktop: the agent is in the first default tab titled like that template, the template's command doesn't run, and there's no extra tab. On the desktop tab strip the title stays after the agent sets its own terminal title; on the phone the tab shows the template's title until the agent sets one, which is how the phone already labels desktop-created tabs. Creates without an agent or without default tabs are unchanged.

Fixed during review.

  • The first version titled the agent's tab by renaming its terminal. That made the template's title outrank every later title the agent sets, so the phone (and any host with no desktop window) lost the agent's working/idle status. A test reproduced it before the fix. The title is now set on the tab only, the way the desktop does it, and the phone's status comes from the agent again.
  • SSH creates didn't pass the agent's tab id, so the agent's tab got the title but not the color. The host now finds the tab from the terminal itself, so no create path needs to pass it.
  • A failed title no longer skips the color, and neither failure affects the create.
  • The automatic title isn't recorded as a user action (a manual orca terminal rename still is).
  • Small scope addition: the other default tabs go through the same title-and-color step, so on a host with no window their titles are saved on the tab instead of being replaced by the shell's terminal title.
  • The tab lookup falls back to the window's view of the terminal, so a title isn't silently dropped once the window takes over the terminal.
  • Added a test through the real host create (two terminals, pnpm dev never runs, the agent's tab titled "Dev"), and made the restart test actually save and rebuild the phone's tab list.

Deferred.

  • With the desktop window open, tab colors set by the host don't reach the window (no host-to-window tab-color message exists). This was already true on main for every host-created default tab. It needs fixing before desktop creates move onto this host path, or desktop users would lose tab colors there.
  • The two host files touched here have type checking turned off (@ts-nocheck, pre-existing), so the typecheck doesn't cover the new tab lookup or the new title field; the runtime tests do.
  • The window-side handling of "not a user action" has no unit test of its own (correct by reading).

Verified.

  • Live: a macOS dev build with the desktop window open, CLI creates against a test repo, main vs this PR (at 2ecbaae; the later commits only add the tab-lookup fallback and tests): main made 3 tabs and ran the Dev command beside the agent, this PR makes 2 with the agent in "Dev" and the Dev command never run, and creates without an agent are the same on both. Screenshots are in the PR body.
  • Tests: the new and updated runtime tests, orca-runtime.test.ts (1323 passed, 1 skipped), tc:node and tc:web, oxlint, oxfmt and the changed-code quality gate; CI on the final head 8eddb9d (the Windows package job's profile-state writer stall test, which this PR doesn't touch, timed out once and passed on rerun).
  • Reviewed in code: parity with the desktop's layout rule (which template, title as the tab's own title, color, skipped command, setup placement, no double layout), the SSH path, chat-mode creates (a structured chat launch has no agent terminal and gets every default tab plus the chat on both the desktop and the host, unchanged), and that the phone's default create uses the agent terminal path this PR changes.

Not verified. The phone UI itself, SSH and Windows hosts, and a host with no window were not exercised live; they are covered by tests only. I couldn't open the uploaded screenshots myself (the links need a GitHub login), so I relied on the QA driver's tab dumps and report.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 7, 2026 08:54
@coderabbitai

coderabbitai Bot commented Oct 7, 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: ac25e1d8-103d-48cb-b3f4-a9ce0cd47bd9
📥 Commits

Reviewing files that changed from the base of the PR and between c8dcffc and 8eddb9d.

📒 Files selected for processing (11)
  • src/main/runtime/orca-runtime-default-tab-agent-status.test.ts
  • src/main/runtime/orca-runtime-get-worktree-terminal-provisioning-host.ts
  • src/main/runtime/orca-runtime-persist-headless-session-tab-props.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.ts
  • src/main/runtime/runtime-notifier-contract.ts
  • src/main/runtime/runtime-worktree-terminal-provisioning.test.ts
  • src/main/runtime/runtime-worktree-terminal-provisioning.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-ui-routing-ipc-bridge.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

Default-tab provisioning can apply the first template’s title and color to an existing startup terminal, skip that template’s command, and create terminals for later templates. The host resolves terminal handles to tabs and persists titles in headless session snapshots. Host-applied title updates are forwarded through the UI rename path without recording a user interaction. Tests cover local and SSH-backed runtimes, provisioning failures, and worktree startup.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8eddb

The agent’s first default tab has no identified merge-blocking issue. Normal checks can proceed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: host-created workspaces place the agent in the first default tab, matching desktop behavior. It is somewhat long but remains specific and readable.
Description check ✅ Passed The description is detailed and covers the user-facing change, implementation, rationale, visual proof, and testing. It does not provide an actual linked issue, as the template requests; the remaining…
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 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@brennanb2025
brennanb2025 merged commit 91d6ed0 into main Oct 7, 2026
81 of 83 checks passed
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