Skip to content

fix(native-chat): keep worktree active during chat creation - #19753

Merged
Jinwoo-H merged 2 commits into
stablyai:mainfrom
Jinwoo-H:blocking-fix
Sep 9, 2026
Merged

Jinwoo-H merged 2 commits into
stablyai:mainfrom
Jinwoo-H:blocking-fix

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.ts
  • pnpm tc:node

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: e296d4ff-7909-446c-b4bf-f8ad112e3648

📥 Commits

Reviewing files that changed from the base of the PR and between 87f826b and 975dead.

📒 Files selected for processing (1)
  • src/renderer/src/lib/worktree-activation-surface-caller-wiring.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Structured 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 null when activation fails. Tests verify the shared activation mock, activation arguments, call order, and failure result.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 975de

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 checkli… Update the description to include the required template sections. Add the issue reference after Fixes #, provide before-and-after visual proof or write N/A with a reason, document manual and automated testing with tested platforms, comp…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the native Chat worktree activation fix and matches the primary change.
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.
Full details: Description check

Explanation

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 Fixes #, provide before-and-after visual proof or write N/A with a reason, document manual and automated testing with tested platforms, complete the relevant checklists, and address AI disclosure, review, compatibility, security, performance, and agent skill boundary requirements.

  • Fix all pre-merge checks with AI

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.

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

ℹ️ No critical issues — two minor suggestions inline.

Reviewed changes

  • Defer structured-launch activation — executeWorktreeCreation no longer activates the worktree up front for structured-native-chat when the user is still on the pending surface; it now routes that case through the background-seed branch instead.
  • Activate immediately before chat selection — launchStructuredWorktreeSession activates the newly created worktree (providesInitialSurface: true) right before activateStructuredAgentSessionById, once the session receipt is ready.
  • Coverage — a new test in worktree-creation-structured-session.test.ts pins 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.

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.

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 })

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.

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.

@Jinwoo-H

Jinwoo-H commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

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.

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