Repository navigation
Feat/per project worktree location - #6427
MrSimmmons wants to merge 10 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 |
| export function sanitizeWorktreeBranch(branch: string): string { | ||
| return branch.replace(/\//g, "-"); | ||
| } |
There was a problem hiding this comment.
🟠 High git/worktreeLocation.ts:18
joinWorktreePath maps distinct valid branches such as feature/login and feature-login to the same <root>/feature-login directory, so creating the second worktree targets an occupied path and git worktree add fails. Escape the separator and the escape character (or append a stable hash) so sanitizeWorktreeBranch remains injective.
| export function sanitizeWorktreeBranch(branch: string): string { | |
| return branch.replace(/\//g, "-"); | |
| } | |
| export function sanitizeWorktreeBranch(branch: string): string { | |
| return branch.replace(/%/g, "%25").replace(/\//g, "%2F"); | |
| } |
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/git/worktreeLocation.ts around lines 18-20:
`joinWorktreePath` maps distinct valid branches such as `feature/login` and `feature-login` to the same `<root>/feature-login` directory, so creating the second worktree targets an occupied path and `git worktree add` fails. Escape the separator and the escape character (or append a stable hash) so `sanitizeWorktreeBranch` remains injective.
There was a problem hiding this comment.
I don't actually agree here. Other applications which create work trees such as VSCode handle sanitization this way https://github.com/microsoft/vscode/blob/main/extensions/git/src/repository.ts#L1953 . This feels like a pointless fix
There was a problem hiding this comment.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a cross-cutting per-project worktree-location capability that changes production worktree and review-path behavior across several components. An unresolved branch-name collision concern in the new path sanitization also warrants human review. You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
Two findings on the new "Worktree location" row in apps/web/src/components/settings/ProjectSettingsPanel.tsx: the invalid state never reaches the Input primitive, and a rejected value leaves a stale error under a field that no longer shows the offending text.
Posted via Macroscope — UI Consistency
…rktree-location # Conflicts: # apps/web/src/components/settings/ProjectSettingsPanel.logic.test.ts # apps/web/src/components/settings/ProjectSettingsPanel.logic.ts # apps/web/src/components/settings/ProjectSettingsPanel.tsx
9969d46 to
afe635a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit afe635a. Configure here.
| return null; | ||
| } | ||
| return resolveConfiguredWorktreeRoot(configured); | ||
| } |
There was a problem hiding this comment.
Worktree override lookup misses path variants
Medium Severity
lookupWorktreeRoot indexes worktreeDirectoryOverrides with a trimmed cwd only. It never normalizes trailing slashes, Windows drive casing, or separators the way normalizeProjectPathForComparison does elsewhere. Settings are written under selectedCheckout.workspaceRoot, then resolved from RPC cwd. If those strings differ, the override is treated as unset and new worktrees silently land in the default T3 home layout.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit afe635a. Configure here.
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. This adds a per-project worktree location setting across server, contracts, web, and mobile. We are not adding this new worktree configuration path through the current backlog. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. |


What Changed
Added the ability to set a per-project worktree location to enable usecases where directory position matters, either for developer tooling (direnv, nix, mise, other monorepo tools) or personal preference
Why
Fixes #6413 which contains the full description, and also enables a pathway for #1878 and #523
TLDR;
<repo>.worktreeslocation)UI Changes
Before:

After:

Checklist
Note
Medium Risk
Changes where git worktrees are created and expands review cwd allowlisting; misconfiguration could block worktree/PR threads, though invalid roots fail loudly rather than silently.
Overview
Adds per-checkout worktree roots via a new
worktreeDirectoryOverridesserver setting (workspace root → absolute path,~allowed). Clearing an override removes the key because patches replace the whole map.Worktree creation now consults that setting when no explicit path is passed:
GitWorkflowService.createWorktreeand PR worktree setup inGitManager.preparePullRequestThreadresolve<root>/<sanitized-branch>through sharedworktreeLocationhelpers. Invalid configured roots fail early instead of falling back to the default layout; an explicitpathstill wins.Review treats paths under any valid configured worktree root as in-bounds for diff preview/file contents (invalid roots are skipped for that check).
Settings UI adds a “Worktree location” field per checkout with client-side absolute-path validation aligned with the server.
Reviewed by Cursor Bugbot for commit afe635a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add per-project worktree location configuration to checkout flow and settings UI
worktreeDirectoryOverridesinServerSettingsas a map of absolute workspace root to absolute worktree root, with whole-map replacement inServerSettingsPatchandapplyServerSettingsPatchworktreeLocation.tsutilities (sanitizeWorktreeBranch,resolveConfiguredWorktreeRoot,lookupWorktreeRoot,joinWorktreePath) and wires them intoGitWorkflowService.createWorktreeandGitManager.preparePullRequestThreadso PR and manual worktree creation use the configured root when no explicit path is givenReviewService.assertWorkspaceBoundCwdto treat CWDs under a project's configured worktree root as in-bounds forgetDiffPreview/getDiffFileContents, skipping invalid rootsisAbsoluteWorktreeLocationclient-side validation and aDraftInput-based field inProjectSettingsPanelto set or clear the override per checkoutcreateWorktreeandpreparePullRequestThreadnow fail early withGitCommandError/GitManagerErrorwhen a configured worktree root is invalid (non-absolute or empty), instead of silently falling back;GitVcsDriverCore.createWorktreebranch sanitization is consolidated into the sharedsanitizeWorktreeBranchutilityMacroscope summarized afe635a.