Repository navigation
fix(worktrees): a finished create no longer pulls you off the workspace you switched to - #23974
Conversation
…ce you switched to Show a ready toast with an Open action instead (#9944).
…om the host For a composer create on a local repo that starts a terminal agent, main spawned the agent terminal with `activate: true`. The renderer turned that into a workspace switch before `createWorktree` resolved, which cleared the creation panel pointer: a user who had moved to another workspace was still pulled onto the new one, and every such create also showed a redundant "ready" toast and lost its completion focus. The host now adopts the startup and setup terminals silently (`surfaceOwner: false`, no activation), the same way runtime-managed creates do when not asked to activate. The submitting renderer's completion rule is the only thing that decides whether to open the new workspace. Also: the ready toast's Open is a deliberate user open (`navigationIntent: 'user-open'`), and the renderer tests now drive the composer's live entry and reach the post-create cancel check.
…completion - Pin that split-mode setup is split into the startup terminal without surfacing the new workspace. - The watching-user completion test is now a real agent create: activation returns no primary tab, as it does in the app. - New store-backed test drives the host's silent reveals through the real bridge, then the completion's activation and focus queue, and checks focus lands on the host-adopted agent tab rather than the setup tab.
…ting-launching-an-agent-in-worktree-a-st
…without opening it When the host does not start the agent (SSH repos, local repos with project default tabs, VM creates) and the user has moved on, completion seeds the agent/setup/issue terminals without activating them. Nothing mounted those panes, so the agent, draft prompt and setup script waited until the user opened the workspace while the toast already said it was ready. The non-activating branch now asks for a background mount of just the created tabs that still owe startup work, the same request the terminal bridges and sleeping-agent wake already use. Idle tabs and host-started terminals are left unmounted.
Review status (head
|
|
| activateAndRevealWorktree(worktree.id, { | ||
| sidebarRevealBehavior: 'auto', | ||
| navigationIntent: 'user-open' | ||
| }) |
There was a problem hiding this comment.
If an SSH or runtime host has a worktree with the same ID as one on another host, this Open action passes no host identity. The lookup then uses the first matching row, so clicking Open can take the user to a different workspace instead of the one that just finished creating.
Knowledge Base Used: Workspace and worktree lifecycle
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughLocal startup and setup terminals no longer request activation or claim surface ownership. The renderer mounts tabs with pending startup work in the background. Creation completion now considers the current view when deciding whether to activate the new worktree. When creation remains pending and the worktree is not in view, the renderer can show a localized ready notification with an action to open it. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No concrete merge-blocking issue remains identified. The changes preserve the current workspace when creation finishes elsewhere and provide an explicit action to open the result; merge after normal checks pass. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 13 files. (6 skipped: 6 unsupported.) Full details: Description checkExplanation The description thoroughly explains the user impact, implementation, rationale, testing, visual proof, scope, and known limitations. However, the Linked Issue section uses Resolution Replace
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 31fa7d51-57f0-41c3-9a2f-199ac1033f37
📒 Files selected for processing (17)
src/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-local-create-flow.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/worktree-creation-backend-startup-focus.test.tssrc/renderer/src/lib/worktree-creation-background-mount.test.tssrc/renderer/src/lib/worktree-creation-background-mount.tssrc/renderer/src/lib/worktree-creation-flow-dedupe.test.tssrc/renderer/src/lib/worktree-creation-flow-execute.tssrc/renderer/src/lib/worktree-creation-flow-ready-toast.test.tssrc/renderer/src/lib/worktree-creation-flow-stranded-surface.test.tssrc/renderer/src/lib/worktree-creation-flow.test.tssrc/renderer/src/lib/worktree-creation-ready-toast.ts
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: only a user still watching the creation surface is handed the new | ||
| // workspace; anyone who moved on (another workspace or an app view) keeps | ||
| // their place and gets a toast instead (#9944). | ||
| const shouldActivateOnCompletion = isPendingCreationSurfaceVisible(creationId) |
ELI5
If you started creating a new workspace, switched to another workspace while it was still being set up, and kept working, Orca pulled you onto the new workspace the moment it finished, so your typing landed in the wrong place. Now you stay where you are and a toast says "Worktree is ready" with a Go to worktree button (for a folder workspace: "Workspace is ready" with Go to workspace). If you stay on the "creating…" panel, you are still taken to the new workspace as before.
What does NOT change (so you are never left somewhere unexpected):
Scope: workspaces created from the New Workspace dialog (every UI entry point opens it: sidebar/project "+", kanban, command palette, Tasks page, menu shortcut). Covers local, SSH and VM-backed creates, git worktrees and folder workspaces. Not changed: the other reveal paths reported on #9944 —
orca file open --worktree <other>, CLI creates with--activate/--focus, GitHub Project view "start", the PR-checks "Fix" launch, and agent-session fork still open the workspace as before. The agent-launch-in-a-new-tab path is handled separately in #10924.What caused it: two things moved you. (1) For a local create that starts a terminal agent (Claude, Codex, …), the main process opened the agent's terminal with
activate: true, which switched the app to the new workspace as soon as that terminal appeared — before the create had even returned. This came from #4565 (new-workspace shortcut terminal focus). (2) The completion rule added in #8226 also activated the new workspace whenever you were on any other workspace when it finished.What Changed
Before: finishing a create switched you to the new workspace if you were on its creation panel or on any other workspace; for local terminal-agent creates the switch happened even earlier, when the agent terminal spawned. You stayed put (silently) only if you had gone to Tasks or Settings, and in that case some creates did not start their agent or setup script until you later opened the workspace.
After:
Mechanism:
src/main/ipc/worktree-remote.ts: the host now adds the agent startup terminal (and the setup terminal, tab or split) to the new workspace withsurfaceOwner: falseinstead ofactivate: true— it creates the tab without opening, revealing or focusing the workspace. This is how runtime-managed creates already worked. The only caller is the app's ownworktrees:createIPC; renderer and main ship together, so no wire change.src/renderer/src/lib/worktree-creation-flow-execute.ts: the completion decision is now "are you still looking at this create" — its creation panel, or the new workspace itself. If yes, it opens and focuses the workspace (unchanged). If not, it leaves you where you are and shows the ready toast (worktree-creation-ready-toast.tsx), wrapped like the other post-create steps so a toast failure can't strand the create.src/renderer/src/lib/worktree-creation-background-mount.ts: for creates whose agent the host does not start (SSH repos, local repos with project default tabs, VM creates), the tabs that still carry startup work (agent command, setup split, issue-command split) are mounted in the background with the existingrequestBackgroundTerminalWorktreeMount, so they run without opening the workspace. Previously, the yank was what mounted them; tabs with no pending work stay unmounted.Why
The issue asks for exactly this: work that finishes in the background must never change the workspace you are looking at, and should give a non-stealing signal instead (#9944 lists sidebar badge / toast / activity entry). The success toast mirrors the existing failure path in the same file, which already toasts a create error only when you have left the panel.
Undoing #8226's "activate after a workspace switch" is safe: #8226 was a product choice for the Tasks one-click create that did not show the creation panel, and that entry was removed in #13479. Every live entry now shows the creation panel on submit, so anyone who is elsewhere when the create finishes chose to leave.
Making the host stop activating (rather than only changing the renderer rule) is what actually fixes the reported case: the host's activation fired before the renderer's decision and cleared the "watching this panel" marker, so a renderer-only change still yanked you and showed a redundant toast. Now a single place — the window that submitted the create — decides navigation.
Alternatives considered:
Linked Issue
Refs #9944 (fixes the "create finishes after I switched away" case; the CLI /
orca file openreveal paths are separate, so this should not auto-close the issue).Visual Proof
Live Electron QA on a separate macOS machine (dev build, isolated profile, stub agent, a git hook slowing each create to ~17 s so there is time to switch away). "After" screenshots are from the final commit's copy unless noted.
Before (main): start creating A1, switch to workspace B — when A1 finishes you are pulled onto it, no toast.
After — switched to another worktree: you stay on B and get the toast.
After — Go to worktree: lands on the new worktree with the agent tab selected and focused.
After — folder workspace: the toast says "Workspace … is ready" / Go to workspace, and the button opens it.
After — already on the new worktree when it finishes (clicked its sidebar row mid-create): agent tab focused, no toast.
After — stayed on the creating panel: taken to the new worktree with the agent focused, no toast.
After — switched to Tasks: view stays on Tasks and the toast appears (this capture predates the final toast wording).
After — project with default tabs (the agent is not started by the main process): stayed on B; the setup script and agent both ran without opening the workspace (marker files written within ~3 s), and after opening it each had run exactly once.
Testing
I manually tested these changes locally (live Electron QA on macOS, see Visual Proof)
Automated tests added/updated, or explained why not below
worktree-creation-flow-ready-toast.test.ts(new): drives the New Workspace dialog's real entry — switched workspace → no activation, one toast whose Open opens the workspace; Tasks → toast, no activation; still on the panel with a host-started agent → activation + focus, no toast; cancelled mid-create → no toast.worktree-creation-backend-startup-focus.test.ts(new): real store, IPC bridge, activation and focus queue — the host's agent/setup terminals don't activate the workspace, and completion focuses the agent tab, not the setup tab.worktree-creation-background-mount.test.ts(new): SSH-like, setup-split and issue-split creates mount exactly the tabs with pending work; host-started agent tabs are never mounted again.worktrees-local-create-flow.test.ts: pins the host's agent terminal and setup terminal (tab and split) assurfaceOwner: falsewith no activation.Each new test was checked to fail with its fix removed. Web and node typechecks pass; oxlint and the changed-lines code-quality gate are clean; all
verify:localization-*scripts pass; new strings are in all six locale catalogs.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: no new inputs, commands or IPC. Cross-platform: no shortcuts, paths or shells. SSH / VM: renderer decides navigation for all hosts; SSH and VM creates now start their agent/setup in the background — verified by code and unit tests, not in a live SSH session. Remote Orca servers and paired clients use a different create path and are unchanged. Mobile: not touched. Performance: one toast per backgrounded create; background mounts are limited to the new workspace's tabs that carry startup work, under the existing hidden-terminal parking limits.
Known and not changed here (pre-existing): with setup set to "split" on a project where the agent is started by the main process, the setup runs once but does not appear as a split (on main it was not visible at all; now it appears as its own tab); a create cancelled after the git worktree was already being added still finishes in the background and appears in the sidebar.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)