Skip to content

fix(agent.launch): avoid blank shells when launching new workspaces - #28451

Merged
brennanb2025 merged 11 commits into
mainfrom
brennanb2025/agent-first-surface-no-blank-shell
Oct 15, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennanb2025/agent-first-surface-no-blank-shell

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​440 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​406
Prod 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​480 $\color{#cf222e}{\Huge{\mathbf{−}}}$​215 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​265

ELI5

With Chat UI enabled, an agent-created workspace could show an unused “Terminal 1” beside Setup and the requested chat. It happened again from the phone: creating a workspace from the phone with Claude and Chat UI on, in a repo with a setup script, opened three tabs: “Terminal 1” (a plain shell nobody asked for), “Setup”, and the Claude chat. Setup provisioning assumed it needed a shell, and foreground opening could independently add another shell before the launch published its chat. The launch now supplies that workspace’s first surface; successful chat launches do not acquire an incidental primary shell. After this change the same phone create opens just Setup and the chat.

What Changed

agent.launch create-worktree requests carry the promised chat through the existing workspace/setup provisioning path. The executing launch registers its live intent when workspace metadata is created, before the workspace can open. Tab inventory reads that intent together with the current tabs, so foreground opening waits for the launch’s surface instead of filling the temporary empty workspace with a shell. The intent ends when the surface is published or the launch exits; nothing persists a second workspace-open model.

Setup timing, configured terminal commands, split anchors, foreground/background selection, and terminal-agent startup handoff remain intact. If a new workspace’s chat start fails, the launch attempts one plain recovery shell and preserves the original failure; it does not start another agent. Ordinary workspace opens and the non-launch empty-workspace watcher keep their existing policy. Desktop new-workspace/+tab migration code has no change in this PR; its existing lane owns that work. Every caller of agent.launch gets the same first-surface behavior, including the phone, whose new-workspace create goes through agent.launch with a create-worktree target.

Why

The launch knows which surface it is creating and how long that work is live. Giving its existing consumers that fact removes the guessing that produced the redundant shell, without a global renderer latch or permanent shell-suppression flag.

Linked Issue

STA-10160; related #27796.

Visual Proof

See the final review status comment for full-window before/after screenshots of the reported setup case, no-setup/no-default case and ordinary creation on final head7db4.

Testing

  • Rendered Electron checks on M4Air using hidden CDP and ORCA_BACKGROUND_LAUNCH=1.
  • Automated flow and cross-process contract tests added/updated.

Current head e5868a5eb95 (current main merged in once, at the end of review). New: the first-surface flow test now also drives the real runtime through the agent.launch handler as a paired phone (Claude, Chat UI on, setup script in its own tab) and checks the workspace ends up with exactly one terminal, Setup, plus the chat. It fails on the extra spawn when the launch stops passing the promised chat to workspace creation. The focused launch, inventory, provisioning, startup, worker, renderer-gate and setup-choice tests pass on the merged head.

Earlier rounds (head 7db4cd36f58, before the main sync): all 22 orca-ci-checks gates and the CI anti-slop lint passed. On M4Air, rebuilt main and PR builds passed 12 agent-create cells per build across setup wait/immediate, default tabs, horizontal/vertical splits and no-setup, plus six post-relaunch background reveals per build. Ordinary non-agent raw CLI QA passed all four foreground/background setup creates: Terminal 1 then Setup, Terminal 1 first and active, zero agents, prior selection kept, one setup run each. That QA predates the main sync; the merge had one conflict, two adjacent import lines in workspace-creation.ts (both kept); main's other edits to these files merged cleanly in separate hunks. Added lines: tests 440, production 480.

AI Disclosure

Review

Four review rounds total. The approved narrower design panel preceded the changed-design fourth round; bounded final integration checks followed. The final changed-design round covered correctness, readiness and performance. Tests added remain below production lines.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Notes

Split setup deliberately retains its terminal anchor; each configured default command still runs once. Before chat publication, a newly selected no-setup workspace can briefly show its existing empty view. Both the updated host and renderer reader are needed for this repair; the optional inventory field is safe for older peers to ignore, and those peers retain their prior behavior.

Deferred: a failed orchestration-worker receipt can omit the recovery-shell effect even though the durable shell is usable and listed, and a successful terminal-start fallback can retain the preceding failure warning. If chat creation and the recovery-shell spawn both fail, no usable shell can be guaranteed; the launch releases its intent and returns the failure.

The phone entry point is covered by the host-side flow test above but was not exercised on a real paired phone. Rendered automation/worker entrypoints, Windows/Linux/WSL/SSH flows, old-peer replay, native focus, and injected rendered publication/PTY failures were not exercised. Failure contracts have source/unit coverage. The naturally pending no-setup frame was too short to capture without artificial delay.

Checklist

  • Focused on agent.launch workspace first-surface ownership.
  • Explained the problem, user-facing result, mechanism and alternatives.
  • Before/after screenshots attached in the final status comment.
  • Reviewed correctness, security and performance.
  • Cross-platform, remote-host and folder-workspace effects considered.
  • Full PR CI green on e5868a5eb95 (PR checks passed). The first attempt failed one unrelated browser popup Electron test on a hidden-frame capture timeout; the rerun passed.

Kept draft; not merged.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/agent-first-surface-no-blank-shell branch from 442560e to 31b07ea Compare October 14, 2026 01:08
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agent-first-surface-no-blank-shell branch from 31b07ea to dddc3dc Compare October 14, 2026 07:25
@brennanb2025

brennanb2025 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Update, delta review at c922b81560b: This round checks the two main merges and the new phone-path test after four previous review rounds. Both merge resolutions retain the launch ownership callbacks and the query-only inventory signal; the phone test invokes the real paired-device agent.launch handler and proves Setup starts once without an extra shell. Independent correctness and final readiness/performance reviews found no new proven issue; this completes four prior rounds plus delta round 5. The test mocks chat publication and does not exercise the current replay-required phone request, so it is not a complete rendered phone test.

CI is now green for this exact commit: PR Checks, including the aggregate PR checks passed gate, static analysis/typecheck, five Node shards, wire compatibility, packaging and selected rendered/layout checks. This supersedes the earlier main-side CI blocker. Added test lines440 remain below production479 (plus one registration line).

Retained desktop comparison screenshots show Terminal1/Setup/Chat becoming Setup/Chat. The coordinator's later M4Air phone/CLI/desktop-dialog QA reports the extra shell removed; no shared simulator was attached in this round. A phone-created workspace still opening on Setup on desktop belongs to the separate landing-tab work and is outside this PR.

Deferred: recovery-shell effect omission in failed-worker receipts and the stale warning after successful terminal-start fallback. Not newly exercised: Windows/Linux/WSL/SSH runtime behavior, old-peer replay, native focus, injected rendered publication/PTY faults and the naturally pending no-setup frame. No new source fix or scope expansion was needed.


With Chat UI enabled, a workspace created through agent.launch could show an unused Terminal 1 beside Setup and the requested chat. Setup provisioning assumed it needed a primary shell, and foreground opening could add one before the chat was published. The launch now owns that workspace’s first surface.

Successful chat launches have no incidental primary shell, including the no-setup/no-default case. Setup timing, each configured default command, split anchors and foreground/background selection retain their policy. A failed new-workspace start attempts one usable plain recovery shell and never starts a second agent; main’s failed terminal-start handoff is preserved. Ordinary workspace opens retain their policy, and desktop new-workspace/+tab migration code stays in its separate lane.

Status: final head 7db4cd36f5882101385882bfc3d2a6bf6a148013; draft, unmerged. Four review rounds completed, including correctness, readiness and performance, after the three-model panel reconverged on the narrower launch-only design. The broader renderer repair and rejected latch were dropped. Final bounded checks restored main’s ordinary creation behavior when no terminal host is available and corrected existing failed-agent recovery assertions.

Verified: all 22 local orca-ci-checks gates, exact CI lint, 1,376 affected flow tests (one skipped) and the overlapping 156-test launch suite passed. Added test lines: 381; production lines: 479, plus one registration line. M4Air hidden-CDP comparison covered setup wait/immediate, defaults, horizontal/vertical splits, and no-setup in foreground/background: 12 creates per ref on main 9c0420fa and e7944597, plus six accurately labelled post-relaunch background reveals per ref. This agent proof is retained after final 7db4’s ordinary workspace correction. Final-head ordinary non-agent raw CLI QA also passed all four main9c/final7db foreground/background setup creates: Terminal1 then Setup, first/active Terminal1, zero agents, prior selection retained, and one setup start/completion per retained readback. Final background reveal was in the same profile/session; baseline reveal is honestly labelled post-relaunch. Completion status is inferred from the set-e runner and successful final command/prompt, rather than an exited interactive terminal.

CI is blocked by main-side failures. The one final-head watch stopped on seven static errors when GitHub merged this head with newer main eb1ee8f9; none of these six files is in this PR’s diff. Owning main changes, verified against exact source and path history:

Failure Main commit / PR
Two broad object parameters, mobile/src/tasks/use-mobile-jira-connection-state.test.ts:16,34 cacce1790d17, #28616
Max-lines: src/renderer/src/components/JiraIssueWorkspace.optimistic-edit.test.tsx (803 counted lines) eb1ee8f908d2, #28588
Max-lines: src/renderer/src/components/JiraIssueWorkspace.tsx (414) eb1ee8f908d2, #28588
Max-lines: src/renderer/src/store/slices/pull-request-generation.ts (325) d194712952ab, #28596
Max-lines: src/shared/protocol-version.ts (301) Latest eb1ee8f908d2, #28588; prior contributions 702777e2fefe #28623, d7315af456e5 #28600
Max-lines: src/main/ipc/jira.ts (301) Latest eb1ee8f908d2, #28588; prior contribution 702777e2fefe #28623

Earlier CI also exposed two main-side openMobileFile arity assertions: #28240 (b428def8f171) added a fourth parameter, while #27582 (663cab34d6af) expected three. Those assertions were not reached on this final head because static analysis stopped downstream tests. A CI rerun is needed once main is green. No further main sync, unrelated repair or workflow rerun was made here.

Deferred: failed-worker receipts can omit the usable recovery shell from their effect list; a successful terminal-start fallback can retain its preceding warning. Both updated host and reader are needed for the complete repair; older peers retain their previous behavior. If both chat and recovery-shell spawning fail, the launch releases its intent and returns the original failure.

Not verified: rendered phone/automation/worker entrypoints, Windows/Linux/WSL/SSH flows, old-peer replay, native focus, injected rendered publication/PTY failures, and the naturally pending no-setup frame (too short without artificial delay). Failure contracts have source/unit coverage. QA apps were stopped by recorded owned PIDs; evidence and the QA checkout were retained.

The following agent screenshots compare rebuilt main 9c0420fa with e7944597; final 7db4 preserves that agent behavior and restores ordinary workspace policy.

Reported setup case, before:

Setup before

Reported setup case, after:

Setup after

No setup or defaults, before:

No setup before

No setup or defaults, after:

No setup after

Ordinary workspace creation remains unchanged, baseline main9c:

Ordinary setup before

Ordinary workspace creation on final7db:

Ordinary setup after

@brennanb2025 brennanb2025 changed the title fix(worktree): don't add a blank shell beside a new workspace's agent chat fix(agent.launch): avoid blank shells when launching new workspaces Oct 14, 2026
@brennanb2025
brennanb2025 marked this pull request as ready for review October 15, 2026 05:26
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Worktree creation and terminal provisioning now use a shared predicate to decide when to seed a primary terminal. Structured agent launches register active launch metadata and can create a recovery shell when a new workspace has no published surface after failure. Session-tab results can expose active launch state to the renderer, which blocks activation while that launch remains active. Activation notifications also carry an optional flag indicating that the caller provides the initial surface.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to c922b

No actionable merge-blocking issue is established by the reviewed changes; normal checks can proceed.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 44 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 clearly identifies the main change: preventing blank shells during agent.launch workspace creation.
Description check Passed The description is detailed and covers the required explanation, changes, rationale, issue reference, visual proof, testing, review notes, scope boundaries, and checklist. The linked issue is identifi…
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.

…rst-surface-no-blank-shell

# Conflicts:
#	src/main/runtime/session-tabs/session-tabs-change-publication.ts

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

🔇 Additional comments: 2
src/main/runtime/workspaces/workspace-host-notifications.ts: 1

198-257: LGTM!

src/main/runtime/session-tabs/session-tabs-change-publication.ts: 1

81-97: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Extract the duplicated launch-attachment logic.

The no-snapshot path and the snapshot path both contain the same lookup and spread. A small local helper would keep the two paths consistent. This is optional.

The behavior is otherwise correct. readCreatedWorkspaceLaunch returns undefined when no launch exists, so initialSurfaceLaunch is added only when a live launch is present. The spread keeps the existing result shape unchanged.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b1463a05-b46b-4d68-a90c-827620a37e0c
📥 Commits

Reviewing files that changed from the base of the PR and between e5868a5 and c922b81.

📒 Files selected for processing: 2
  • src/main/runtime/session-tabs/session-tabs-change-publication.ts
  • src/main/runtime/workspaces/workspace-host-notifications.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@brennanb2025
brennanb2025 merged commit 635d385 into main Oct 15, 2026
44 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/agent-first-surface-no-blank-shell branch October 15, 2026 08:21
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