Fix WSL workspace root detection

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H 2026-05-30 09:40:58 -07:00 committed by Neil
parent f5bf30ac57
commit 7f1c680597
2 changed files with 17 additions and 1 deletions

View File

@ -48,4 +48,19 @@ describe('computeWorktreePath WSL layout', () => {
})
).toBe(win32.join('C:\\workspaces', 'feature'))
})
it('uses an explicit WSL UNC workspace root without remapping it', () => {
parseWslPathMock.mockReturnValue({
distro: 'Ubuntu',
linuxPath: '/home/jin/src/repo'
})
getWslHomeMock.mockReturnValue('\\\\wsl.localhost\\Ubuntu\\home\\jin')
expect(
computeWorktreePath('feature', '\\\\wsl.localhost\\Ubuntu\\home\\jin\\src\\repo', {
nestWorkspaces: false,
workspaceDir: '\\\\wsl.localhost\\Ubuntu\\home\\jin\\custom-worktrees'
})
).toBe('\\\\wsl.localhost\\Ubuntu\\home\\jin\\custom-worktrees\\feature')
})
})

View File

@ -8,6 +8,7 @@ import type {
WorktreeMeta
} from '../../shared/types'
import { resolveRuntimePath } from '../../shared/cross-platform-path'
import { isWslUncPath } from '../../shared/wsl-paths'
import { splitWorktreeId } from '../../shared/worktree-id'
import { DEFAULT_WORKSPACE_STATUS_ID } from '../../shared/workspace-statuses'
import { getWslHome, parseWslPath } from '../wsl'
@ -234,7 +235,7 @@ function shouldMirrorWorkspaceDirInsideWsl(repoPath: string, workspaceDir: strin
if (isWorkspaceDirRelativeToRepo(repoPath, workspaceDir)) {
return false
}
return !parseWslPath(workspaceDir)
return !isWslUncPath(workspaceDir)
}
/**