Repository navigation
fix(worktrees): honor absolute Linux worktree base paths for WSL repos (STA-4772) - #15384
Conversation
…s (STA-4772) Project setup accepted /home/... worktree base paths for WSL-backed repos and reported them ready, but the WSL workspace-mirroring heuristic read them as desktop-absolute roots (win32.isAbsolute) and silently replaced them with ~/orca/workspaces at create time. Resolve repo-scoped POSIX-absolute base paths into the repo's own distro UNC form at the resolution boundary, for both creation-path settings and ownership layouts. UNC, drive, relative, native Windows, macOS/Linux, and SSH base paths pass through unchanged.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds WSL-aware resolution for repository-specific worktree base paths. Absolute POSIX paths are normalized and converted to distro-specific WSL UNC paths. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/wsl-paths.ts (1)
61-72: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten this comment.
The comment repeats implementation detail and incident history. Keep the public contract only.
Proposed change
-/** - * Resolve a repo-scoped worktree base path against the repo's own WSL distro. - * - * Why: project setup stores the value verbatim, and for a WSL-backed repo an - * absolute Linux path like /home/user/trees is the natural spelling of a - * location inside that distro. Windows path code reads it as drive-relative, - * so the WSL workspace-mirroring heuristic silently replaced it with - * ~/orca/workspaces (STA-4772). The repo path pins the distro, making the - * value unambiguous — translate it to its UNC form. Non-WSL repos and - * non-POSIX values (UNC, drive, relative) pass through untouched, so native - * Windows, macOS/Linux, and SSH base paths keep their meaning. - */ +/** Resolve an absolute POSIX base path for a WSL repo against its distro. Preserve other values. */As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ab902be9-72fa-46c0-870c-3dfdbecc0b17
📒 Files selected for processing (6)
src/main/ipc/worktree-logic-wsl.test.tssrc/main/ipc/worktree-logic.tssrc/shared/worktree/ownership-worktree-base-path.test.tssrc/shared/worktree/ownership.tssrc/shared/wsl-paths.test.tssrc/shared/wsl-paths.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
…view Review findings from three independent passes: mapping /mnt/<drive> bases to drive letters re-triggered the desktop-mirroring heuristic that discards the configured base, and uncollapsed dot segments made ownership layouts disagree with creation. Resolve every POSIX base of a WSL repo onto the distro UNC view and collapse dot segments in the resolver so both consumers see one spelling.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/wsl-paths.ts (1)
72-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense this rationale comment.
Lines 72-77 use six lines for two invariants. Keep a brief comment that states that drvfs paths must remain UNC paths and dot segments must normalize before ownership comparison.
Proposed change
- * Why not toWindowsWslPath: its /mnt/<drive> branch emits a drive-letter path, - * which the workspace-mirroring heuristic reads as desktop-local and discards — - * the very bug this resolves. drvfs bases stay on the distro UNC view instead. - * Dot segments collapse here because ownership layouts compare paths without - * resolving them, so creation and classification must see the same spelling. + * Keep drvfs paths in the distro UNC view so workspace mirroring preserves them. + * Normalize dot segments so ownership and creation compare the same path.As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 11aa5575-4806-4927-b5db-7678fe451f10
📒 Files selected for processing (3)
src/main/ipc/worktree-logic-wsl.test.tssrc/shared/wsl-paths.test.tssrc/shared/wsl-paths.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Independent review pass (3× GPT-5.6-luna via Codex CLI, distinct lenses)Three read-only reviewers ran against the first commit ( Confirmed and fixed in
Verified and declined, with rationale:
Validation after the fixes: 20 test files / 308 tests pass (wsl-paths, worktree-logic, ownership, trash, root-preparation, retirement, plus the real-WSL oracle incl. an actual |
Round-two review (3x gpt-5.6-luna + Opus): pin the dotted-base collapse on both the creation and ownership sides so a one-sided normalization change cannot silently break classification, and pin the deliberate drive-letter-base mirror into the distro home.
Review round 2 (pre-merge): 3× GPT-5.6-luna + 1× Claude OpusFresh reviewers against the final diff on current main ( Verdicts: luna: APPROVE, APPROVE-WITH-NITS ×2 · Opus: APPROVE-WITH-NITS. No blockers, no majors. Acted on (commit
On record, no change (with rationale):
Opus verification highlights: ran 26 adversarial inputs through the real resolver (all round-trip cleanly through Full validation on the final head: 114 tests across the four touched suites, typecheck clean. |
…rate WSL base-path trade-offs Opus review round: pin the real invariant (creation output classifies) instead of paired hardcoded strings, and record that the /mnt UNC route and the single-leading-slash guard are deliberate so neither gets 'optimized' back into the mirror-discard bug.
Review round 2 — 3× GPT-5.6-luna (Codex CLI) + Claude OpusFresh lenses against the final diff on current Verdicts: luna: APPROVE / APPROVE-WITH-NITS / APPROVE-WITH-NITS. Opus: APPROVE-WITH-NITS. No blockers or majors anywhere; all round-one declines were upheld on re-examination. Acted on (
Verified and declined:
Notable confirmations from Opus: legacy worktrees under Pre-existing bug found in passing (not this PR): |
Opus follow-up: a regressed resolver lands in the ~/orca/workspaces mirror layout, which also classifies 'external', so the ownership assertion alone passed either way. Assert containment in the repo-base layout, which goes red under both one-sided and full reverts.
|
Opus follow-up round: it empirically caught that the new creation/ownership agreement test in 654d3cb was vacuous — a regressed resolver lands in the unconditional ~/orca/workspaces mirror layout, which also classifies |
|
Opus final pass: verified 3b12352 independently (test-only diff, containment assertion discriminates under revert as predicted, 16/16 green by name). Finding 7 closed; no further findings. Final Opus verdict: APPROVE. Deferred nits on record: retirement memo-guard comment (post-refactor follow-up), stopped-distro mkdir latency (pre-existing class), and the separate-ticket first-work-folder-rename bug. |
…s (STA-4772) (stablyai#15384) (cherry picked from commit 2c24025)
Summary
Fixes STA-4772: for a WSL-backed repository, a project-setup worktree base path written as an absolute Linux path (e.g.
/home/user/project/.orca-worktrees) was accepted and reported ready, but worktree create silently ignored it and fell back to the default~/orca/workspacesmirror inside the distro. The equivalent\\wsl.localhost\<distro>\...UNC value worked.Root cause
getWorktreePathSettingsmerges the repo-levelworktreeBasePathintoworkspaceDirbeforecomputeWorkspaceRootruns. For a WSL repo,shouldMirrorWorkspaceDirInsideWsltreats any non-UNC "absolute" value as a desktop-local root that must be mirrored into~/orca/workspaces— andwin32.isAbsolute('/home/…')is true, so an absolute Linux path was classified as a desktop root and silently discarded. No warning is surfaced anywhere on this path.Fix (create-time normalization)
New shared helper
resolveWslRepoWorktreeBasePath(repoPath, basePath)insrc/shared/wsl-paths.ts: when (and only when) the repo itself lives on a WSL UNC path and the configured base path is POSIX-absolute (single leading/), translate the base path onto that repo's distro UNC view (\\wsl.localhost\<distro>\<path>), collapsing dot segments./mnt/<drive>bases deliberately stay on the distro UNC view rather than being remapped to a drive letter — a drive-letter result would re-trigger the desktop-mirroring heuristic that discards the base (found in review). Applied at the two resolution boundaries:src/main/ipc/worktree-logic.tsgetEffectiveWorktreeBasePath— covers worktree create (local + remote), base-directory watch targets, trash sweep roots, name retirement, filesystem allowed roots, root preparation, and folder rename.src/shared/worktree/ownership.tsgetRepoWorktreeBasePath— keepsbuildKnownOrcaWorkspaceLayoutsconsistent with where creation actually places worktrees, so ownership classification matches.Create-time (resolution-time) was chosen over save-time as the authoritative boundary because it also repairs already-persisted values, values arriving over the wire from older clients, and keeps the stored setting verbatim as the user typed it (no schema or wire change; the host that executes creation interprets the value).
Deliberately untouched:
C:\…), macOS/Linux repos, and SSH repos never rewrite: normalization requires the repo path itself to be a WSL UNC path.//-rooted, and relative base values pass through unchanged.workspaceDirsetting is not reinterpreted — only the repo-scoped base path, where the repo pins the distro and makes the value unambiguous.Reproduction evidence (real WSL, Windows 2, Ubuntu-24.04)
Product-level (installed Orca app, disposable repo via orca-cli):
repo addfor\\wsl.localhost\Ubuntu-24.04\home\neil\sta4772-repro\repo, thenproject setup-update --worktree-base-path /home/neil/sta4772-repro/.orca-worktrees→ stored verbatim,setupState: ready, no warning.worktree create→ created at\\wsl.localhost\Ubuntu-24.04\home\neil\orca\workspaces\repo\linux-base-probe,warnings: []— configured base silently ignored. Bug confirmed.…\sta4772-repro\.orca-worktrees\repo\unc-base-probe. UNC control honored.Source-level oracle (uncommitted scratch vitest against real
wsl.exe, incl. a realgit worktree addthrough the resolved path):1b5cc00870(latest main): linux-base cases FAIL (resolve to~/orca/workspaces), UNC/native/POSIX/default PASSTests
src/shared/wsl-paths.test.ts— unit coverage: Linux path → distro UNC (incl. legacy\\wsl$repos),/mnt/<drive>mapping, UNC/drive/relative passthrough, non-WSL repo passthrough (native Windows, POSIX,//server/share).src/main/ipc/worktree-logic-wsl.test.ts— create-path coverage: Linux base honored throughgetWorktreePathSettings, repeated calls stable, no dependence on the distro home lookup (first-fallback:getWslHomereturning null no longer matters for configured bases), relative bases still anchored to the repo.src/shared/worktree/ownership-worktree-base-path.test.ts— ownership layout for a WSL repo with a Linux base path matches created worktree paths.Validation
pnpm run typecheckclean; oxlint clean on changed files.worktree-base-directory-watcher.test.tsfails identically on unmodified main (pre-existing Windows failure).test:e2e:workspace-session-golden): candidate and unmodified-baseline runs produce identical results on this machine (1 pass; the same two specs fail on both, worktree-create-switch with the harness error "seeded e2e worktrees did not load" — a pre-existing fixture seeding issue unrelated to this change, which only alters behavior when the repo path is a WSL UNC path and a POSIX-absolute repo base path is configured).Linear: STA-4772.