Repository navigation
fix(terminal): open WSL file links on Windows - #8215
Conversation
📝 WalkthroughWalkthroughAdds WSL-aware terminal file path mapping that converts eligible POSIX paths under WSL worktrees to UNC paths. The mapped paths are used for existence checks, authorization, runtime statistics, shell and editor opening, HTML handling, hover text, cache keys, and pending reveals. Terminal link tests cover OSC links, file URLs, direct clicks, modern and legacy WSL formats, relative paths, and native path preservation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
|
Thank you for picking this up so quickly! I'm the reporter of #8156. I read through the diff and it matches the root cause I hit exactly: mapping resolved POSIX paths through the worktree's WSL distro before the existence probe (the spot that prevented links from ever being created), plus the same mapping on the direct-click fallback and OSC routing. The |
9227939 to
392fa9c
Compare
|
Thanks so much for this, @rodboev — open WSL file links on Windows. Reviewed, rebased on latest |
… the worktree path (#12465) `mapTerminalFilePath` derived the WSL distro only from the *shape* of `worktreePath`. A worktree on a native Windows drive whose project runs under the WSL runtime gets a shell whose paths are POSIX, so no distro was found, the path went verbatim to a Win32 stat probe, and the candidate was dropped — no underline, no tooltip, inert Ctrl+click. Resolve the pane's distro from the execution runtime, falling back to the old worktree-shape derivation so existing behaviour is unchanged. Note the half of #8156 covered by merged #8215 (worktree on the WSL filesystem) was already fixed; this closes the remaining gap. Fixes #8156 Co-authored-by: Orca <[email protected]>
… the worktree path (stablyai#12465) `mapTerminalFilePath` derived the WSL distro only from the *shape* of `worktreePath`. A worktree on a native Windows drive whose project runs under the WSL runtime gets a shell whose paths are POSIX, so no distro was found, the path went verbatim to a Win32 stat probe, and the candidate was dropped — no underline, no tooltip, inert Ctrl+click. Resolve the pane's distro from the execution runtime, falling back to the old worktree-shape derivation so existing behaviour is unchanged. Note the half of stablyai#8156 covered by merged stablyai#8215 (worktree on the WSL filesystem) was already fixed; this closes the remaining gap. Fixes stablyai#8156 Co-authored-by: Orca <[email protected]>
Summary
Makes POSIX file paths printed by terminals running inside a WSL distro clickable and openable from a Windows-hosted WSL worktree.
ELI5
When you run a terminal inside WSL on Windows, file links show up as Linux-style paths like
/root/workspace/README.md. Windows can't open those directly, so clicking did nothing. This teaches Orca to translate them into a Windows-visible location so the file opens.Root cause & fix
Terminals running in a WSL distro emit POSIX absolute paths, but the Windows host cannot resolve them. The fix adds a pure
mapTerminalFilePath(filePath, worktreePath)interminal-file-open-routing.tsthat rewrites a POSIX absolute path to//wsl.localhost/<distro><path>when the worktree parses as a WSL UNC path (both modern\\wsl.localhostand legacy\\wsl$forms). Every file-open call site — hit-testing, path-exists caching,stat,authorizeExternalPath,openFile, tooltip, andpendingEditorReveal— now routes through the mapped path. The guard returns the original path unchanged for non-WSL worktrees and for native Windows (C:\), existing UNC (//), or relative inputs, so no other platform behavior changes.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
origin/main(base7ab601487c, head9227939c8b).terminal-link-handlers.test.ts— passes on branch, fails when the fix is reverted (proven regression guard).oxlintclean on all 3 changed source files (no warnings/errors).Trade-offs
None — pure fix.
Regression risk
Zero-regression by construction:
mapTerminalFilePathis a pure, tightly-guarded transform. Non-WSL worktrees hit the identity path (parseWslUncPathreturnsnull), and native Windows / UNC / relative inputs are returned byte-identical — both covered by passing tests. Only the WSL branch changes behavior.Credit to original author @rodboev. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.