Repository navigation
feat(wsl): default a new Windows-drive project under a WSL default to Git for Windows (D1c-5) - #33122
Conversation
4744e59 to
ae05cd2
Compare
7850743 to
c70135b
Compare
ae05cd2 to
2f43ad5
Compare
c70135b to
dd94f12
Compare
2f43ad5 to
7a5ca94
Compare
dd94f12 to
417b78b
Compare
7a5ca94 to
73563e1
Compare
417b78b to
f19bde1
Compare
73563e1 to
bd03615
Compare
f19bde1 to
9bc7249
Compare
bd03615 to
5f403b6
Compare
9bc7249 to
f077845
Compare
6c14210 to
7166c56
Compare
f077845 to
f7337f6
Compare
7166c56 to
9a2b332
Compare
f7337f6 to
0b3bfd6
Compare
9a2b332 to
244abe6
Compare
0b3bfd6 to
a7136bc
Compare
244abe6 to
b36bf0a
Compare
a7136bc to
f1da001
Compare
b36bf0a to
0e8e459
Compare
f1da001 to
b59c2e9
Compare
0e8e459 to
363e860
Compare
b59c2e9 to
71ac31c
Compare
dce3e79 to
30b18bf
Compare
ab1f214 to
9b42484
Compare
30b18bf to
fa3fa88
Compare
9b42484 to
75aa19f
Compare
fa3fa88 to
4e271a5
Compare
75aa19f to
a58d1f0
Compare
4e271a5 to
17acf4a
Compare
[Medium impact] The change affects setup for eligible new Windows-drive projects. The PR is not ready to merge because all three previously reported failures remain. Findings
SummaryGives eligible Windows-drive projects Windows Git while keeping terminals and agents in the chosen WSL distro.
Reviews (7) · Last reviewed commit: "fix(wsl): judge a new project's worktree..." · Reviewed by Greptile |
| const project = state.projects.find((entry) => entry.sourceRepoIds.includes(repo.id)) | ||
| if (!project || project.localWindowsRuntimePreference) { |
There was a problem hiding this comment.
Existing projects switch Git unexpectedly
Adding another checkout of an existing project can silently switch that project's Git to Windows. addRepo merges checkouts with the same remote into one project before this helper runs. An existing project with no saved runtime choice passes this check, so adding a clean second checkout changes Git for the first checkout too, without checking its WSL-authored worktrees. Those worktrees can become unusable in Orca.
Capture whether the project existed before registration and apply this default only to a genuinely new project.
Knowledge Base Used: Desktop persistence and lifecycle
| return names.flatMap((name) => { | ||
| try { | ||
| return [readFileSync(join(root, name, 'gitdir'), 'utf8').trim()] | ||
| } catch { | ||
| return [] | ||
| } |
There was a problem hiding this comment.
Unread links allow incompatible Git
If reading worktrees or one of its gitdir files fails, this function returns an empty or incomplete list. The caller treats that as safe and saves git: 'windows-host', even when an unread link belongs to WSL Git. Windows Git cannot follow that link, so the linked worktree becomes unusable even after the read error clears.
Return [] only when the worktrees directory is absent. Return null for other directory errors or any failed link read so the project keeps its current behavior.
Knowledge Base Used:
a58d1f0 to
a30bcc8
Compare
17acf4a to
167b601
Compare
4288890 to
6cfca04
Compare
167b601 to
600a856
Compare
6cfca04 to
881d451
Compare
600a856 to
663495b
Compare
881d451 to
17b6f70
Compare
663495b to
a919a01
Compare
| // Pinned like a converted project, so a later global change can't silently switch its Git. | ||
| return { kind: 'wsl', distro: globalDefault.distro, git: 'windows-host' } |
There was a problem hiding this comment.
Missing Windows Git breaks projects
If a Windows user has Git installed only in WSL, they can still add an existing checkout because registration accepts a valid .git marker when Git cannot run. This helper then saves git: 'windows-host' without checking that Windows Git exists. Git actions that previously worked through WSL now fail.
Check that Windows Git can run before saving this default. If it cannot, leave the project inheriting its runtime.
17b6f70 to
1c20978
Compare
a919a01 to
1cb41e1
Compare
… test, so a //wsl.localhost link counts as Windows Git's Co-Authored-By: Claude <noreply@anthropic.com>
1cb41e1 to
549afa7
Compare
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
82401549-a288-4f00-89f5-35dce3d5a835
Files selected for processing: 3-
src/main/persistence/loading-store/repo-lifecycle-operations.tssrc/main/wsl/wsl-drive-project-new-default.test.tssrc/main/wsl/wsl-drive-project-new-default.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
| const project = state.projects.find((entry) => entry.sourceRepoIds.includes(repo.id)) | ||
| if (!project || project.localWindowsRuntimePreference) { |
There was a problem hiding this comment.
Do not change an existing project based on one added repo.
A project can contain multiple sourceRepoIds. If addRepo adds a Windows-drive repo to an existing project with no local preference, this search selects that project and pins Windows Git for all its repos. The selector checks only the newly added repo, so the other repos may not meet the Windows-drive or worktree-link conditions. Apply this default only to a newly created, single-repo project, or validate every repo in the project before writing the project-wide preference. (raw.githubusercontent.com)
| } catch { | ||
| return [] |
There was a problem hiding this comment.
Treat unreadable worktree metadata as unknown.
If listing .git/worktrees fails for a reason other than ENOENT, returning [] tells the selector that there are no links. If one gitdir read fails, flatMap silently removes that link. Either case can hide a WSL-authored link and persist a Windows Git preference that the worktree preflight would reject. Return null for these failures; reserve [] for a missing worktrees directory. (raw.githubusercontent.com)
Also applies to: 100-102
Source: Learnings
ELI5
When someone whose default runtime is WSL adds a project that lives on a Windows drive (
C:\…), Orca runs that project's Git through WSL today. That is about 300 times slower than Git for Windows and misses edits made from Windows. After this PR, such a brand-new project starts out using Git for Windows, and its terminals and agents still run in WSL. It matches what the "Git" setting from #33090 / #33097 switches an existing project to.What Changed
C:\project under a global WSL default inherits WSL for everything, Git included.{ kind: 'wsl', distro: <the global default's distro>, git: 'windows-host' }. Terminals, agents, accounts and hooks still run in that distro. Git, and where new worktrees go, move to Windows.src/main/wsl/wsl-drive-project-new-default.ts, called from the store'saddRepo. Every add path ends there: add, create, clone, nested import, the runtime RPC and paired clients. It writes the default only when all of these hold:.git/worktrees/*/gitdir. A checkout whose.gitis a file (a linked worktree or a submodule) counts as unknown and keeps today's behaviour.Why
addRepoand not each add path. There are about ten add paths. One hook covers all of them, plus future ones. The check it runs is a few small file reads, and only on Windows when the gate is open.Linked Issue
Part of the WSL re-write, step D1c, decision (b) (risk rows R36, R6). Stacked on #33143 (the top of D1c), so that branch holds every D1c PR.
Visual Proof
N/A: no UI change. The project's settings show #33097's existing "Orca runs Git on Windows" row.
Testing
src/main/wsl/wsl-drive-project-new-default.test.tscovers:pnpm test src/main/persistenceandpnpm tc:nodepass locally.Review
Self-reviewed.
Agent skill upstream boundary
Notes
addReponow callsapplyNewWindowsDriveProjectDefault, whose first check returnsfalsewhile the gate is closed (wsl-drive-project-new-default.ts): no filesystem read, no project change, no extra save. Even with the gate open it skips SSH, folder workspaces, macOS and Linux.Status
167b6010b14: rebased onto main64344142fa0, which has feat(wsl): run Git for Windows for a WSL project on a Windows drive (D1c-2) #33090 squash-merged (fix(wsl-host): tell users how to fix a distro Orca can't host (D1c-1) #33085 earlier) and fix(wsl-mover): hold an app update install while a moved project comes back #35357; feat(wsl): offer Git for Windows in a Windows-drive WSL project's settings (D1c-3) #33097 now targets main. Every commit is kept. CI: running on this head.isForeignLink, so a//wsl.localhostlink counts as Windows Git's.pnpm tc,pnpm run typecheck:ci, the PR's tests,check:code-quality:changed, the anti-slop oxlint, repo oxlint and ast-grep (including the no-real-time-sleep test rules) and the e2e typecheck ratchet all pass locally on this head, run one branch at a time.