Fix new-thread draft reuse for worktree defaults#2003
Conversation
- Prefer worktree mode when the server default is worktree - Avoid reusing promoting drafts as the source for new threads - Preserve existing worktree drafts instead of deleting them
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Small bug fix adding guard conditions to prevent incorrect draft thread reuse when worktree defaults are set or when drafts are being promoted. Production changes are minimal (~12 lines) with defensive null/state checks, accompanied by comprehensive test coverage (~114 lines). Low-risk, well-scoped fix. You can customize Macroscope's approvability policy. Learn more. |
Integrates upstream/main (d22c6f5) into the fork while preserving all multi-provider support (codex, claudeAgent, copilot, cursor, opencode, geminiCli, amp, kilo) and fork UI/UX additions. Highlights adopted from upstream: - Nightly release channel + update channel selector (pingdotgg#2012, pingdotgg#2049, pingdotgg#1969) - Filesystem browse API + command palette project picker (pingdotgg#2024) - Launch Args setting for Claude provider (pingdotgg#1971) - Kiro editor support in open picker (pingdotgg#1974) - Claude plan events for TodoWrite during input streaming (pingdotgg#1541) - Lost provider session recovery (pingdotgg#1938) - Cache provider status and gate desktop startup (pingdotgg#1962) - LegendList migration for chat scrolling and branch lists (pingdotgg#1953) - Shell snapshot queries + backfill migration (pingdotgg#1973, pingdotgg#2004) - PATH hydration + fallback detection (pingdotgg#1799) - Warm sidebar thread subscriptions (pingdotgg#2001) - Full thread title tooltip (pingdotgg#1994) - Markdown file link UX (pingdotgg#1956), composer polish (pingdotgg#1944, pingdotgg#1992, pingdotgg#1985) - Worktree/branch state + draft reuse fixes (pingdotgg#2005, pingdotgg#2003, pingdotgg#1995, pingdotgg#1936) - Window controls overlay for Windows/Linux (pingdotgg#1969) - Backend readiness timeout 10s→30s (pingdotgg#1979) - Clear tracked RPCs on reconnect, live stream subscriptions (pingdotgg#2000, pingdotgg#1972) - Various misc fixes (pingdotgg#2051, pingdotgg#2052, pingdotgg#2025, pingdotgg#2027, pingdotgg#2049, pingdotgg#1997, pingdotgg#1975) Fork features preserved and reconciled: - All 8 provider adapters + conformance tests - Extended ProviderKind union across contracts/model/settings/provider - appearance/accentColor/themeConfig/ProviderLogo UI system - customModels + gitTextGeneration + providerModelOptions - Migration IDs 23 (NormalizeLegacyProviderKinds) and 24 (RepairProjectionThreadProposedPlanImplementationColumns) kept; new upstream migrations registered at IDs 25-26 to avoid breaking deployed fork databases - DesktopBridge: log directory channels (LOG_DIR/LIST/READ/OPEN_DIR) retained; getWsUrl replaced by upstream's getAppBranding - PROVIDER_CACHE_IDS extended to all 8 providers
Summary
worktree.Testing
bun fmtbun lintbun typecheckbun run testNote
Medium Risk
Touches new-thread draft creation/reuse logic and draft-store cleanup rules, which can impact routing and draft persistence across projects. Changes are localized and covered by new unit and browser-level tests, reducing regression risk.
Overview
New-thread draft reuse is tightened for worktree defaults and promotion in-flight. When the project default env mode is
worktree, sidebar seed context now forcesenvMode: "worktree"instead of inheriting an active thread’s branch/worktree path, ensuring the next thread starts as a fresh worktree draft.Draft reuse/cleanup is also guarded so promoting draft threads aren’t reused or deleted mid-promotion (
useHandleNewThreadcheckspromotedTo == null;composerDraftStorewon’t evict a prior draft if it’s promoting). Adds regression coverage inChatView.browser.tsxandSidebar.logic.test.ts.Reviewed by Cursor Bugbot for commit 33d6b03. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix new-thread draft reuse when the default environment mode is worktree
useHandleNewThread.ts, draft reuse is now skipped when the active draft has already been promoted (promotedTo != null).composerDraftStore.ts, deletion of a previous logical-project draft is skipped when that draft is in a promoting state.Sidebar.logic.ts,resolveSidebarNewThreadSeedContextreturns{ envMode: 'worktree' }immediately whendefaultEnvModeis'worktree', ignoring any active thread context.Macroscope summarized 33d6b03.