Make worktree placement configurable#4439
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:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Needs human review New feature adding configurable worktree placement with a path template system. Changes runtime worktree creation behavior and modifies workspace boundary validation logic, which has security implications. The cross-cutting nature and new user-facing capability warrant human review. You can customize Macroscope's approvability policy. Learn more. |
5f92245 to
0ff572e
Compare
366d6e0 to
ea5b4d2
Compare
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 ea5b4d2. Configure here.
dce0c11 to
72afbca
Compare

What Changed
worktreePathTemplateserver setting.{worktreesDir},{repoRoot},{repoName}, and{branch}when creating worktrees.{worktreesDir}/{repoName}/{branch}as the default, preserving the existing centralized layout.Why
Some users keep worktrees alongside each repository, while others prefer T3 Code's centralized worktree directory. A configurable template supports both layouts without changing existing behavior.
For example,
{repoRoot}/.worktrees/{branch}creates repository-local worktrees.UI Changes
The General settings panel now exposes the worktree path template and documents its available variables. Browser verification covered the default value, persisting a repository-local template, and resetting to the default.
These current screenshots were recaptured from PR head
366d6e021814242392c778d49fd195397a8cbf11in the combined package0.0.29-patched-main-20260724(integration4dd4cef4039303179929a1dbdbf0c9b358c076f9).Checklist
pnpm exec vp test run packages/contracts/src/settings.test.ts apps/server/src/serverSettings.test.ts apps/server/src/vcs/GitVcsDriverCore.test.ts apps/server/src/server.test.ts -t 'bootstraps first-send worktree turns|ServerSettings worktree path template|ServerSettingsPatch string normalization|server settings|uses the configured repository-local worktree path template|keeps the centralized worktree path as the default'(21 passed)pnpm exec vp test run apps/server/src/review/ReviewService.test.ts apps/server/src/vcs/GitVcsDriverCore.test.ts(40 passed)vp checkfor the final review-fix files (no warnings)pnpm exec vp check(passes with 12 pre-existing warnings in untouched files)pnpm --filter t3 typecheckpnpm --filter @t3tools/contracts typecheckpnpm exec vp run typecheck(workspace baseline fails in untouched web/mobile files: existing implicit-anyandunknown AtomRegistryerrors; the affected server and contracts package checks pass)Note
Medium Risk
Changes where new worktrees are created and tightens review path validation; default template preserves existing layout, but custom templates and symlinked repo roots affect filesystem layout and security boundaries.
Overview
Adds a persisted
worktreePathTemplatesetting (default{worktreesDir}/{repoName}/{branch}) in contracts and a Worktree path control in General settings.Worktree creation now expands
{worktreesDir},{repoRoot},{repoName}, and{branch}via newworktreePathTemplatehelpers instead of a fixed centralized path. The template is read from server settings and passed through bootstrap, VCScreateWorktree, and PR worktree flows inws/GitManager.Review diff preview accepts optional
repositoryRoots, loads active project workspace roots through a new lightweightgetActiveProjectWorkspaceRootsprojection query (avoiding full shell snapshots), and allowscwdwhen it matches the configured template for those roots—not only the main workspace and legacy worktrees dir.Reviewed by Cursor Bugbot for commit 72afbca. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Make worktree placement configurable via a path template setting
worktreePathTemplatefield (default{worktreesDir}/{repoName}/{branch}) toServerSettingsandServerSettingsPatchin settings.ts, with a UI input in the General settings panel.resolveWorktreePathTemplateandmatchesWorktreePathTemplateutilities in worktreePathTemplate.ts to expand and validate template placeholders.createWorktreein GitVcsDriverCore.ts now resolves the worktree path via the configured template instead of the hardcoded{worktreesDir}/{repoName}/{sanitizedBranch}scheme.ReviewService.getDiffPreviewin ReviewService.ts now accepts optionalrepositoryRootsand validates candidatecwdvalues against the configured template in addition to existing workspace root checks.ProjectionSnapshotQuerygainsgetActiveProjectWorkspaceRoots()to supply repository roots to the diff-preview path without hydrating full shell snapshots.createWorktreewill differ from the previous fixed scheme for any server using a custom or migrated template.Macroscope summarized 72afbca.