Fix worktrees failing to open on WSL: translate POSIX worktree paths to UNC#63
Open
flix-wg wants to merge 1 commit into
Open
Fix worktrees failing to open on WSL: translate POSIX worktree paths to UNC#63flix-wg wants to merge 1 commit into
flix-wg wants to merge 1 commit into
Conversation
Worktrees on a WSL repo fail to open in Desktop with: The worktree path '\home\user\...\.claude\worktrees\<name>' does not appear to be a valid Git repository. git runs inside the distro and returns POSIX worktree paths. Upstream parseWorktreePorcelainOutput runs each through Path.normalize, which on Windows only flips separators (/home -> \home) without adding a volume, so Windows cannot resolve the path. The repository path itself works because the user enters it via the folder picker (correct UNC); only the git-discovered worktree paths are left untranslated. Fix, entirely inside the WSL fork's own code: - wsl.ts: add linuxPathToWSL (inverse of parseWSLPath) and isRootlessPosixPath (detects a POSIX-rooted path, incl. the backslash-flipped form Path.normalize yields on Windows). - worktree.ts: in listWorktrees (which has the Repository/UNC path, unlike the context-free parser), lift rootless entry paths to \\wsl.localhost\<distro>\... The distro is derived from the parent repo's UNC path, never hardcoded. Native Windows paths pass through untouched. Verified: patches 01-07 apply cleanly with git apply against a pristine desktop/desktop@release-3.6.2 checkout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Still needs testing :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #62.
Problem
Worktrees on a WSL repo fail to open (
\home\...invalid). git returns POSIX worktree paths; upstreamparseWorktreePorcelainOutputruns them throughPath.normalize, which on Windows only flips separators (/home→\home) without adding a volume, leaving a rootless path Windows can't resolve. The repo path works because it comes from the folder picker (correct UNC); only git-discovered worktree paths are left untranslated. Full analysis in #62.Change
New patch
patches/07-worktree-path-translation.patch, following the numberedgit applyconvention. Two hunks, entirely within the fork's own code:app/src/lib/wsl.ts— add two exported helpers:linuxPathToWSL(distro, linuxPath)— inverse ofparseWSLPath; builds\\wsl.localhost\<distro>\....isRootlessPosixPath(p)— true for a POSIX-rooted path, including the backslash-flipped formPath.normalizeyields on Windows (\home\..., a single leading backslash, not a\\UNC path). Drive-letter and UNC paths return false.app/src/lib/git/worktree.ts— inlistWorktrees(not the parser): the parser only receivesstdoutand has no repo context, whereaslistWorktreeshas theRepository→.path→ distro. After parsing, if the repo is a WSL path, lift rootless worktree entry paths to UNC.Design guards
parseWSLPath— never hardcoded (Ubuntu, etc.).isWSLPath) and the entry path is rootless. Native Windows paths pass untouched.Path.normalizeform: on Windows the path is already\home\..., so a naivestartsWith('/')check would miss it —isRootlessPosixPathhandles both/homeand\home..claude/worktrees/). Cross-distro worktrees would get the wrong prefix — documented known edge, not handled.submodule.ts) likely share the bug — flagged as a separate follow-up in Worktrees fail to open: worktree paths not translated POSIX→UNC (\home\... invalid) #62, not touched here.Verification
git applyagainst a pristinedesktop/desktop@release-3.6.2checkout (current latest upstreamrelease-*tag). Hunks use minimal, stable context anchors.git worktree add).Risk
Patch fragility — CI applies patches with strict
git applyagainst each newrelease-*every 6h. Theworktree.tshunk is anchored on the stablelistWorktreesshape; re-diff if upstream restructures it. Re-verify against the live tag at merge time (do not assume 3.6.2 if a newer tag has shipped).🤖 Generated with Claude Code