fix(web): keep the current worktree on the new-local-thread shortcut - #11015
maria-rcks wants to merge 1 commit into
Conversation
Cmd/Ctrl+Shift+N routed through the generic startNewThreadFromContext, which deliberately inherits only the project, so a quick parallel chat landed on the project's configured defaults instead of the branch and worktree the user was looking at. The chat.newLocal shortcut now goes through its own startNewLocalThreadFromContext, which passes the active thread or draft's branch, worktreePath, and env mode to handleNewThread — the same options the thread menu's "New thread on <branch>" already uses. Other new-thread entry points are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| // in its own worktree or the local checkout. | ||
| envMode: (thread ? undefined : draft?.envMode) ?? (worktreePath ? "worktree" : "local"), | ||
| // Reusing an existing checkout must never re-bootstrap it from origin. | ||
| startFromOrigin: false, |
There was a problem hiding this comment.
🟠 High lib/chatThreadActions.ts:143
startNewLocalThreadFromContext always passes startFromOrigin: false, so a draft with envMode: "worktree", no worktreePath, and startFromOrigin: true creates its worktree from the stale local branch instead of origin. Preserve the draft's setting when no existing checkout is being reused, while keeping false for real threads or drafts with an existing worktreePath.
| startFromOrigin: false, | |
| startFromOrigin: thread || worktreePath ? false : draft?.startFromOrigin, |
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/lib/chatThreadActions.ts around line 143:
`startNewLocalThreadFromContext` always passes `startFromOrigin: false`, so a draft with `envMode: "worktree"`, no `worktreePath`, and `startFromOrigin: true` creates its worktree from the stale local branch instead of `origin`. Preserve the draft's setting when no existing checkout is being reused, while keeping `false` for real threads or drafts with an existing `worktreePath`.
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — This is a localized shortcut bug fix with focused production changes and regression tests, preserving the active branch/worktree without altering generic thread creation or product defaults. An unresolved High-severity edge case remains for origin-based worktree drafts without an existing worktree path. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds a context-aware local thread action. It preserves the active branch and worktree, derives the environment mode, disables origin starts, and connects this behavior to the ChangesLocal thread context
Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Cmd/Ctrl+Shift+N now creates local chats in the active branch and worktree while regular new-chat behavior remains unchanged. Current merge-readiness risk is minimal. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Note Written by Converting to draft pending a maintainer call. Two independent reviews of this head found the same problem: If a shortcut for "New thread on " is wanted, the cleaner route is a new keybinding rather than changing this one. Happy to rework it that way if a maintainer confirms. |
|
Note: GPT-6 on behalf of shivam (@shivamhwp). Preserve an origin-based draft's The product-decision hold remains appropriate. Before #4411, |
Cmd/Ctrl+Shift+N (
chat.newLocal) routed through the genericstartNewThreadFromContext, which inherits only the project by design, so a quick parallel chat started from a feature-branch thread silently landed on the project's configured new-thread defaults instead of the branch and worktree the user was looking at.The shortcut now goes through its own
startNewLocalThreadFromContext, which reads the active thread or draft'sbranch,worktreePath, and env mode and passes them tohandleNewThread— the same explicit options the thread menu's "New thread on " already uses, withstartFromOrigin: falseso reusing a checkout never re-bootstraps it. Every other new-thread entry point (Cmd+N, the sidebar button, the command palette) keeps the #4411 project-defaults behavior.Verified:
vp run --filter @t3tools/web typecheckexit 0, no errors.vitest run apps/web/src/lib/chatThreadActions.test.ts --pool=forks12 passed, including two new cases covering worktree inheritance and the branch-only local case (vp test runfails to boot its default thread pool in my environment, on unmodifiedorigin/mainfiles too, so I ran the same runner with--pool=forks).vp linton the three changed files exit 0.Out of scope: the sidebar's "new thread" button advertises the
chat.newLocalshortcut label as the keyboard twin of shift+click in single-project setups. Shift+click still uses project defaults, so that tooltip pairing is now slightly loose; changing it would touch a second entry point's behavior, which this fix deliberately leaves alone.Fixes #9656
UI evidence
Compared parent
b7b3ef1e6fand headd40a3b4using the same real sandbox repository and existingfeature/worktree-shortcutworktree. Selected that worktree in the branch picker, entered an unsent draft, then pressed Cmd+Shift+N. The parent resets the new draft tomain; this change retains the selected branch and worktree. This verifies the client draft flow; provider execution was not tested.Evidence captured with gpt-6-astra (low reasoning) in Codex.
Done by Claude Opus 5 (1M context) in Claude Code.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes