Repository navigation
feat(mobile): reuse existing worktrees - #8568
CasperEngl wants to merge 2 commits into
Conversation
|
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e023cde. Configure here.
| const switchRef = useAtomCommand(vcsEnvironment.switchRef, { reportFailure: false }); | ||
| const switchRef = useAtomCommand(vcsEnvironment.switchRef, { | ||
| reportFailure: false, | ||
| }); |
There was a problem hiding this comment.
Detached worktree lost in branch picker
Medium Severity
Selecting a detached existing worktree stores branch: null with a worktreePath, which is correct. The branch picker still treats a null branch as “no choice” and highlights the main checkout’s current or default branch. Confirming that row calls selectBranch, which replaces the worktree path with that branch’s tree and can switchRef in the project cwd, dropping the detached worktree the user just picked.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e023cde. Configure here.
| fileSystem.stat(worktree.path).pipe( | ||
| Effect.as(worktree.path !== currentWorktreePath), | ||
| Effect.orElseSucceed(() => false), | ||
| ), |
There was a problem hiding this comment.
Current checkout can appear in worktrees
Medium Severity
listWorktrees excludes the current checkout by comparing realPath(cwd) to path.resolve of git’s listed paths. Those forms often differ when cwd is a logical path (macOS /var vs /private/var) or git stored the unresolved path. The current tree then shows up as a reusable worktree. Picking it stores a worktreePath for the main checkout and locks the thread into worktree mode.
Reviewed by Cursor Bugbot for commit e023cde. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a cross-cutting worktree-reuse capability across Git services, RPC contracts, web UI, and mobile thread creation, including changes to workspace selection behavior and authorization wiring. The unresolved comments identify concrete risks around detached worktrees and current-checkout filtering, so the runtime impact merits human review. You can add or adjust custom eligibility rules. Learn more. |
|
Note: GPT-5 on behalf of shivam (@shivamhwp). Thanks for the contribution. We're closing #8517 and #8568 because we're keeping the existing selection flow. Users can already reuse worktrees through the branch selector, and web/desktop also provides a Previous worktree shortcut. The dedicated picker adds another UI path for largely the same workflow. We recognize that it also exposes detached worktrees, but don't see enough benefit to add a separate picker across clients right now. |


What Changed
Why
Stack
e023cdeefor the mobile-only change.UI Changes
Checklist
Implemented with GPT-5.6 Sol through the Codex harness in T3 Code.
Note
Medium Risk
Touches VCS listing and thread-creation workspace/branch resolution, which determine where new agent work runs; changes are gated to draft flows with new tests for detached worktrees.
Overview
Adds
vcs.listWorktreesend-to-end (contracts, server git driver/workflow, WS RPC, client-runtime query) so clients can show other checkouts in the repo, excluding the current cwd (with symlink-safe matching).On mobile, the new-task draft replaces the local/worktree toggle with a
NewTaskWorkspacepicker: current checkout, new worktree, and a Worktrees section fed by the new API.selectWorktreepersists local mode with path/branch in the draft, and thread creation passesselectedWorktreePathintoresolveProjectThreadCreationBranchso detached worktrees do not inherit the main checkout’s branch label.On web, the composer workspace control drops the thread-based “Previous worktree” shortcut and instead offers an Existing worktrees submenu from the same listing.
ExistingWorktreesMenuSubapplies the chosen tree to the draft context.User docs note that workspace can reuse an existing worktree directory.
Reviewed by Cursor Bugbot for commit e023cde. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
vcsListWorktreesAPI and mobile/web UI to reuse worktreesvcsListWorktreesRPC andGitVcsDriverCore.listWorktreesto enumerate git worktrees by parsinggit worktree list --porcelain -zoutputVcsWorktreeschema to expose{ path, branch, head }wherebranchisnullfor detached worktrees; creation results now useVcsCreatedWorktreeNewTaskWorkspacePickerRouteScreento let users select the current checkout, create a new worktree, or pick an existing oneExistingWorktreesMenuSub, which lists all available worktrees in the toolbar menuVcsWorktreeschema changed from{ path, refName }to{ path, branch, head }in git.ts; any callers referencingrefNameonVcsWorktreewill break. RemovedresolvePreviousWorktreeSeedandresolvePreviousWorktreeLabelexports in BranchToolbar.logic.ts.📊 Macroscope summarized e023cde. 17 files reviewed, 1 issue evaluated, 1 issue filtered, 0 comments posted
🗂️ Filtered Issues
apps/server/src/vcs/GitVcsDriverCore.ts — 0 comments posted, 1 evaluated, 1 filtered
listWorktreesresolvesinput.cwditself and compares it to each worktree root. When the RPC is called from a subdirectory of the current checkout, that real path differs from the root emitted bygit worktree list, so the current worktree is returned as an "existing" selectable worktree. Resolve the current worktree root (for example withgit rev-parse --show-toplevel) before filtering. [ Out of scope (post-validation triage) ]