Repository navigation
fix(agent.launch): the creation operation owns a new workspace's first surface - #29095
brennanb2025 wants to merge 12 commits into
Conversation
…t surface A workspace that agent.launch creates gets its first surface (chat, agent terminal or folder agent) from the running launch. That fact now lives in one place, the launch's live registration, which dies with the launch. - Host provisioning reads the live launch instead of a threaded promisedAgentChat flag, for terminal agents and folders as well as chats. - A failed first agent start stays with the launch, which builds the agent next; the window is no longer also handed the start (two agents). - The activation event's providesInitialSurface field is gone; the window asks the host's tab inventory when a host-retried Setup arrives. - A recovery shell is added only when the surface is definitely missing, never after the host reported an unknown chat outcome.
Main now always runs Setup in its own tab (#29819) and lets background agent creates leave the first surface to the caller (#29810). Keep both: the creation owner still suppresses the starter shell, and background attribution-only creates follow main's narrower rule. With no split Setup mode left, owned navigation queues Setup directly and the "Setup could not run" fallback is gone.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
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:
a6cb30fa-e033-4fb3-85c5-310c94056814
📒 Files selected for processing: 53
mobile/src/session/mobile-existing-agent-launch.tsmobile/src/tasks/agent-launch-mobile-replay.test.tsmobile/src/tasks/mobile-agent-launch-architecture.test.tsmobile/src/tasks/worktree-create-launch-operation.test.tsmobile/src/tasks/worktree-create-retry.tssrc/main/agent-launch/agent-launch-created-workspace.tssrc/main/agent-launch/agent-launch-execution.tssrc/main/agent-launch/agent-launch-executor.test.tssrc/main/agent-launch/agent-launch-executor.tssrc/main/agent-launch/agent-launch-not-started.tssrc/main/agent-launch/agent-launch-surface-factories.tssrc/main/agent-launch/agent-launch-token.tssrc/main/native-chat/agent-session-wire/structured-agent-session-attach-orchestration.tssrc/main/native-chat/agent-session-wire/structured-agent-session-failed-create-sink-release.test.tssrc/main/runtime/orca-runtime-tests/repository-project-operations-part-02.spec.tssrc/main/runtime/rpc/methods/agent-launch-floating-workspace.test.tssrc/main/runtime/rpc/methods/agent-launch-instant-tab.test.tssrc/main/runtime/rpc/methods/agent-launch-pane-reservation.test.tssrc/main/runtime/rpc/methods/agent-launch-surfaces.tssrc/main/runtime/rpc/methods/agent-launch-worktree-creation.tssrc/main/runtime/rpc/methods/agent-launch.test.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-start-agent-placement.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-start-launch-executor-parity.test.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.tssrc/main/runtime/rpc/methods/structured-agent-session-create.tssrc/main/runtime/rpc/methods/structured-agent-session-wire-contracts.test.tssrc/main/runtime/rpc/methods/structured-agent-session.test.tssrc/main/runtime/runtime-folder-worktree-create.test.tssrc/main/runtime/runtime-folder-worktree-create.tssrc/main/runtime/runtime-local-worktree-create.tssrc/main/runtime/runtime-local-worktree-terminal-startup.test.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/main/runtime/runtime-managed-worktree-create-types.tssrc/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-worktree-terminal-provisioning.test.tssrc/main/runtime/runtime-worktree-terminal-provisioning.tssrc/main/runtime/runtime-worktree-terminal-startup-attempt.tssrc/main/runtime/terminal/launch/terminal-create.tssrc/main/runtime/workspaces/workspace-activation.tssrc/main/runtime/workspaces/workspace-creation.tssrc/main/runtime/workspaces/workspace-host-notifications.tssrc/main/runtime/worktree-agent-first-surface.test.tssrc/renderer/src/hooks/ipc-events/worktree-event-runtime-activation.test.tssrc/renderer/src/hooks/ipc-events/worktree-event-runtime.tssrc/renderer/src/lib/worktree-activation-gated-empty-reseed.tssrc/renderer/src/lib/worktree-activation-structured-chat-surface.test.tssrc/renderer/src/lib/worktree-activation-surface-selection.tssrc/renderer/src/lib/worktree-activation.tssrc/renderer/src/lib/worktree-agent-activation-gate.test.tssrc/renderer/src/lib/worktree-agent-activation-gate.tssrc/renderer/src/lib/worktree-agent-activation-seam.test.tssrc/renderer/src/lib/worktree-owned-navigation.tssrc/shared/worktree-first-surface.ts
💤 Files with no reviewable changes: 2
- src/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.ts
- src/main/runtime/runtime-folder-worktree-create.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Mark pane acquisition as unverifiable before the abort check. · terminal-create.ts:67-74
src/main/runtime/terminal/launch/terminal-create.ts:67-74
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMark pane acquisition as unverifiable before the abort check.
When an unhinted startup has an aborted signal,
terminal-create.tsthrowsclient_disconnectedbefore it callsonPaneAcquisition('unverifiable'). The startup remains absence-eligible andruntime-worktree-terminal-startup-attemptinvokes recovery creation. BecauseadoptStablePanehas not run, recovery has not proved that no stable pane exists. It can therefore create a competing initial surface.Suggested fix
try { // A pane moved from another host reopens where it last was, until a spawn commits. cwd = (await restoreHint.peekCwd(launchOpts.cwd)) ?? cwd + launchOpts.onPaneAcquisition?.('unverifiable') if (launchOpts.signal?.aborted) { throw new Error('client_disconnected') } - launchOpts.onPaneAcquisition?.('unverifiable') const adoptedBeforeLaunch = await this.ptyController.adoptStablePane?.({
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4af6f155-e52c-4ad5-8ca0-9cbe3d5f5bdf
📒 Files selected for processing: 2
src/main/runtime/rpc/methods/structured-agent-session-wire-contracts.test.tssrc/main/runtime/runtime-terminal-contracts.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
|
Not ready: native phone comparison finished, but both the phone and later desktop navigation open Project Checks instead of the requested agent chat. GitHub also reports merge conflicts. Creating a workspace with an agent could leave an extra plain “Terminal 1” beside Setup and the agent. A failed terminal-agent start could also trigger a retry from both the host and desktop. Host provisioning and agent launch were independently deciding who should create the first tab. The running creation operation now owns the first agent surface and its bounded retry/recovery. Phone, CLI and worker creates keep Setup, configured tabs and the requested agent without an incidental shell; ordinary desktop creation and explicit New Terminal keep their existing paths. Recovery requires evidence that no agent surface was created. An uncertain result leaves the workspace available to inspect instead of creating another shell. The final integration preserves main’s #29810 background attribution-only behavior and #29819 separate Setup tab. Independent source review agrees on f329417, including all three final-main conflict resolutions. No new source-proven defect introduced by the PR remains; the requested landing acceptance below fails on both tested heads. The source fixes cover duplicate retries, uncertain acquisition, Setup retry without a split anchor, folder creation, and delayed desktop activation. Deferred historical concerns about inventory event ordering and folder publication timing remain unconfirmed; this pass found no new evidence to reopen them. Verification: seven named suites passed 156 tests and the normal pre-commit checks passed. Exact-head full PR workflow 39243124036 passed, including static analysis/typecheck, five node shards, relay tests, wire compatibility, packaging, rendered checks and its aggregate gate; Mobile Checks, node-server and WSL workflows also passed. Desktop comparisons on M4Air passed for Claude Chat creation, terminal-agent creation, no-agent creation and a controlled explicit New Terminal check, using the same committed Setup/default-tab fixture on main and this head. Native phone comparison completed on the pinned main baseline 41fdd7e and this head f329417. Each used normal native pairing from an unpaired state, an exact-source mobile-web bundle, and a real Claude reply through the team's load balancer under an isolated QA home. Both created Project Checks, Setup and Claude Chat, with no extra plain “Terminal 1”; Setup completed with exit status 0 and the desktop stayed on its previous workspace. Both failed the requested Chat landing: the phone initially selected Project Checks, and later ordinary desktop workspace navigation also selected Project Checks before any tab click. Selecting Chat manually allowed a real reply, but does not satisfy automatic landing. The baseline's first agent start was stopped by a QA launcher environment guard; the corrected isolated launcher then produced the baseline reply and was used from the outset on the target. This was a rig correction, with no product source changes. All owned apps, agents, drivers, Metro servers and simulator helpers were stopped; the owned simulator and temporary homes were removed and ticket 635 was released. The original immediate New Terminal input attempt had different timing on main and target; one bounded ready-prompt/terminal-click recheck passed both, and no source regression was established. Live app, agent and driver environment checks were recorded for the phone run. Other observations were retained without attributing them to this PR: the baseline startup-error banner remained after its successful retry; both Setup-source badges read ORCA.YAML despite Local only settings, and configured default-tab readiness output was absent; the target desktop showed a phone-size Restore notice. The run did not diagnose those causes. Source review checked SSH/execution-host routing, folders, old paired-server fallbacks and platform-aware Setup commands. Live Windows/WSL/SSH failures and runtime performance were not exercised in this pass; no minimum server version, new saved field or new wire operation is introduced. For Brennan’s review
Native phone screenshots below distinguish the initial landing from the manually selected chat reply. The same landing failure exists on the tested main baseline; this run does not establish that the PR introduced it. The requested landing acceptance failed, so the review does not certify this head. GitHub reports mergeStateStatus DIRTY / CONFLICTING on the unchanged head; no merge or source change was attempted.
|
|
Closing: main already stops the extra terminal when a workspace is created with an agent (#28451, then #29810 and #29819); phone QA showed main and this branch behave the same. What remained here only changed failure-path handling. The follow-up that opens a new workspace on its agent's chat (#29204) is being rebuilt directly on main as a new PR. |
















ELI5
Creating a workspace with an agent could leave an extra plain “Terminal 1” beside Setup and the agent, or start the agent twice after a failed first attempt. Workspace setup and the agent launch both acted as if they owned the first tab. The running creation operation now owns that first surface until it succeeds or fails.
What Changed
Phone, CLI and worker agent creates keep Setup and the requested agent without an incidental shell. If a terminal agent fails before it starts, its launch retries once; the desktop does not also start another copy. When Orca cannot confirm whether an agent started, it leaves the workspace available to inspect instead of adding a shell beside a potentially running agent. A definite failure can still produce a recovery terminal.
The creation operation registers ownership when the workspace is created, and host provisioning reads that live registration for worktrees and folder workspaces. This replaces the chat-only
promisedAgentChatplumbing. The existing optional activation hint remains temporarily so delayed desktop navigation cannot seed another primary terminal; the planned creation-path convergence removes that adapter. No new saved field or wire operation is introduced.The integration preserves main’s #29810 behavior: background creates that merely attribute a workspace to an agent leave the first surface to their caller, while activated creates retain their normal startup path. It also adopts #29819: Setup always opens in its own tab, including a retry after failure, and no longer requires a terminal split anchor. The removed setting and obsolete failure notice stay removed. Desktop New Workspace, explicit New Terminal and older paired servers retain their existing launch paths.
Why
A single running operation should create the first surface and own its failure handling. That follows the common pattern and prevents independent provisioning and activation paths from launching competing surfaces. Recovery requires evidence that no surface was created; an uncertain outcome cannot safely authorize another one.
Intended differences from the common pattern: Orca also provisions terminal agents, Setup and configured tabs across folders, execution hosts and multiple viewers. Temporary difference: the existing optional activation hint carries ownership through delayed desktop navigation until the planned creation-path convergence removes it.
Linked Issue
Maintainer follow-up to #28451; row 1 of the workspace-creation convergence plan.
Visual Proof
M4Air desktop comparisons passed on main merge parent
41fdd7e6d8301ff1faa956e8ecc6a8ef86cff10fand final headf329417f808474f5098cc73ae11a1228aa874c93, using the same committed fixture with Setup and one configured Project Checks tab. Native phone QA remains queued, so the full review is incomplete. Desktop behavior is intentionally unchanged.New Terminal added exactly one functioning shell on both commits after its shell prompt was visible and the terminal element was focused. One earlier automated target attempt sent partial input without proving that readiness/focus; its cause remains unproven, and the bounded same-input recheck passed on both commits.
Testing
The final integration is independently source-reviewed at f329417. Seven named suites passed 156 focused tests, and the normal pre-commit checks passed with serial scheduling. The full PR workflow passed on this final head, including static analysis/typecheck, all five node shards, relay tests, cross-version wire compatibility, packaging, rendered checks and its aggregate gate. Mobile Checks, node-server tests and the WSL workflow also passed. Earlier exact-head checks passed before this final main merge, and existing regression coverage checks failed first starts, uncertain outcomes, folder creation, provisioning and renderer activation. Final-head desktop rendered QA passed all three create flows and the bounded New Terminal recheck. Native phone QA is queued separately; the earlier M4Air phone run does not certify this head.
AI Disclosure
Review
Independent source review agrees with the final main integration, including background attribution-only creates and Setup in its own tab. Exact-head CI and desktop rendered QA passed. Fresh native phone QA must finish before the status comment is marked complete.
Agent skill upstream boundary
Notes
Author: @BrennanKB5
Checklist