Skip to content

Worktrees fail to open: worktree paths not translated POSIX→UNC (\home\... invalid) #62

Description

@flix-wg

Symptom

A WSL repository that has git worktrees fails to open them in the app. The worktree is listed in the UI, but clicking it errors:

The worktree path '\home\felix\dev\anomaly-detection\.claude\worktrees\anomaly-detection-tf-migration'
does not appear to be a valid Git repository.

The path \home\... is a POSIX path with /\ flipped but no UNC prefix — Windows cannot resolve it.

Repro

# in WSL, inside a repo already added to the app
git worktree add ../wt-test -b wt-test

Add/open the parent repo → the worktree is listed → click it → error above.

Root cause

git runs inside the distro (via the daemon) and returns POSIX worktree paths (/home/felix/...) from git worktree list --porcelain. That is correct for WSL.

Upstream parseWorktreePorcelainOutput (app/src/lib/git/worktree.ts) runs every path through Path.normalize:

path = Path.normalize(line.substring('worktree '.length))

On Windows, Path.normalize('/home/felix/...') only flips separators → \home\felix\.... The path stays rootless (no drive, no UNC), so Windows cannot resolve it — the exact broken string in the error.

Why the repo itself works but worktrees don't: the repository path is entered by the user via the folder picker, so it is already a correct \\wsl.localhost\<distro>\... UNC path. Worktree paths are discovered from git metadata as raw POSIX and passed straight to Windows without translation.

Scope note

  • Patch 01-wsl-path-detection.patch only has Windows→POSIX converters (toLinuxPath, parseWSLPath, ...). There is no reverse POSIX→UNC helper, and no patch touches worktree.ts — hence the gap.
  • Submodule path parsing (app/src/lib/git/submodule.ts) likely shares the same latent bug; that is out of scope here and worth a separate issue.

Proposed fix

Add the missing reverse helper in wsl.ts and translate worktree paths in listWorktrees (which has the Repository → UNC path, unlike the context-free parser). Distro is derived from the parent repo's UNC path — never hardcoded. Native Windows paths pass through untouched.

PR: adds patches/07-worktree-path-translation.patch following the numbered git apply convention. Verified to apply cleanly on top of patches 01–06 against a pristine desktop/desktop@release-3.6.2 checkout.

Workaround until merged

Add each worktree as its own repo: File → Add Local Repository → paste the UNC path, e.g. \\wsl.localhost\Ubuntu\home\felix\dev\anomaly-detection\.claude\worktrees\<name>. The picker stores the correct UNC form, bypassing the broken auto-discovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions