Repository navigation
fix(native-chat): keep worktree active during chat creation - #19753
Conversation
|
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 (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughStructured chat worktree creation now remains on the pending surface during completion. When no activation exists, the structured session launcher activates the worktree before selecting the chat. It records the returned primary tab ID, including Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Structured Chat worktree creation now keeps its pending surface until the session is ready, then activates the worktree before selecting Chat. The updated wiring test aligns with this behavior, with no remaining current-head merge risk identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, fix, and validation, but it omits most required template sections, including the linked issue, visual proof or an explicit N/A reason, testing details and checklist, AI disclosure, review, compatibility notes, and repository checklists. Resolution Update the description to include the required template sections. Add the issue reference after
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.
ℹ️ No critical issues — two minor suggestions inline.
Reviewed changes
- Defer structured-launch activation —
executeWorktreeCreationno longer activates the worktree up front forstructured-native-chatwhen the user is still on the pending surface; it now routes that case through the background-seed branch instead. - Activate immediately before chat selection —
launchStructuredWorktreeSessionactivates the newly created worktree (providesInitialSurface: true) right beforeactivateStructuredAgentSessionById, once the session receipt is ready. - Coverage — a new test in
worktree-creation-structured-session.test.tspins the activation-before-tab-selection ordering and the exact activation arguments.
The fix is sound: deferring activation until the session is ready keeps the pending surface from being cleared mid-create, and the terminal/setup seeding contract is preserved (explicit terminal work still seeds via ensureWorktreeHasInitialTerminal with callerProvidesSurface: true, while providesInitialSurface: true correctly leave the workspace empty otherwise). The targeted tests pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| // The user moved on. Seed the worktree's terminal + setup in the background | ||
| // (setActiveTab only writes global focus for the active worktree, so this is | ||
| // safe) without yanking them back to it. | ||
| // Keep chat creation on its pending surface until the session is ready. |
There was a problem hiding this comment.
This comment now describes only the structured-launch case, but this else branch still handles the user-moved-on path (non-structured launches seeded in the background — see the issue-command/backend-terminal tests below). The removed 3-line explanation covered that rationale; consider keeping both so the ensureWorktreeHasInitialTerminal call below isn't left unexplained.
| if (args.shouldActivateOnCompletion) { | ||
| // Chat selection requires its workspace to be active. | ||
| if (!activation) { | ||
| activation = activateAndRevealWorktree(args.worktreeId, { providesInitialSurface: true }) |
There was a problem hiding this comment.
The previous structured-launch activation passed sidebarRevealBehavior: 'auto'; this deferred call drops it, so revealWorktreeInSidebar now falls back to the default smooth scroll. Likely benign, but confirm the switch away from an instant reveal for a just-created worktree is intentional.
|
CI failure was a stale activation-caller census expectation after moving the opt-out into the structured Chat activation seam. Updated the census; focused tests and typecheck remain green. |
* fix(native-chat): activate worktree before chat session * test: update native chat activation census (cherry picked from commit 7dd183d)

Problem
Creating a worktree with the native Chat UI could leave the app on the landing screen while the Chat session was still being created.
Fix
Defer activation for structured Chat launches and activate the worktree immediately before selecting the ready Chat session. This prevents the transient setup surface from clearing the newly created workspace selection.
Validation
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/renderer/src/lib/worktree-creation-structured-session.test.ts src/renderer/src/lib/worktree-creation-chat-setup.test.ts src/renderer/src/lib/worktree-creation-flow.test.tspnpm tc:node