Skip to content

feat(mobile): reuse existing worktrees - #8568

Closed
CasperEngl wants to merge 2 commits into
pingdotgg:mainfrom
CasperEngl:feat/existing-worktrees-mobile
Closed

CasperEngl wants to merge 2 commits into
pingdotgg:mainfrom
CasperEngl:feat/existing-worktrees-mobile

Conversation

@CasperEngl

@CasperEngl CasperEngl commented Aug 28, 2026 •

Copy link
Copy Markdown

What Changed

  • Add an existing-worktree picker to the native mobile new-task flow.
  • Preserve detached-worktree branch state when creating a thread.
  • Add focused coverage for workspace selection validation.

Why

  • Mobile needs the same existing-worktree workflow introduced by the parent web/shared PR.

Stack

UI Changes

  • No new screenshots were captured for this split. The code is unchanged from the previously reviewed combined PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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.listWorktrees end-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 NewTaskWorkspace picker: current checkout, new worktree, and a Worktrees section fed by the new API. selectWorktree persists local mode with path/branch in the draft, and thread creation passes selectedWorktreePath into resolveProjectThreadCreationBranch so 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. ExistingWorktreesMenuSub applies 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 vcsListWorktrees API and mobile/web UI to reuse worktrees

  • Adds vcsListWorktrees RPC and GitVcsDriverCore.listWorktrees to enumerate git worktrees by parsing git worktree list --porcelain -z output
  • Updates VcsWorktree schema to expose { path, branch, head } where branch is null for detached worktrees; creation results now use VcsCreatedWorktree
  • Adds mobile NewTaskWorkspacePickerRouteScreen to let users select the current checkout, create a new worktree, or pick an existing one
  • Replaces web 'previous worktree' logic with ExistingWorktreesMenuSub, which lists all available worktrees in the toolbar menu
  • Risk: VcsWorktree schema changed from { path, refName } to { path, branch, head } in git.ts; any callers referencing refName on VcsWorktree will break. Removed resolvePreviousWorktreeSeed and resolvePreviousWorktreeLabel exports 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
  • line 2885: listWorktrees resolves input.cwd itself 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 by git worktree list, so the current worktree is returned as an "existing" selectable worktree. Resolve the current worktree root (for example with git rev-parse --show-toplevel) before filtering. [ Out of scope (post-validation triage) ]

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cfc8cb36-db51-4fb5-84a7-842522809e3a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@CasperEngl CasperEngl mentioned this pull request Aug 28, 2026
3 of 4 tasks
@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Aug 28, 2026
@github-actions github-actions Bot added the size:XL 500-999 changed lines (additions + deletions). label Aug 28, 2026

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ 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,
});

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.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e023cde. Configure here.

fileSystem.stat(worktree.path).pipe(
Effect.as(worktree.path !== currentWorktreePath),
Effect.orElseSucceed(() => false),
),

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.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e023cde. Configure here.

@macroscopeapp

macroscopeapp Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@shivamhwp

Copy link
Copy Markdown
Collaborator

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.

@shivamhwp shivamhwp closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants