Skip to content

fix(terminal): open WSL file links on Windows - #8215

Merged
nwparker merged 1 commit into
stablyai:mainfrom
rodboev:pr/open-wsl-file-links-on-windows
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
rodboev:pr/open-wsl-file-links-on-windows

Conversation

@rodboev

@rodboev rodboev commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

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) in terminal-file-open-routing.ts that rewrites a POSIX absolute path to //wsl.localhost/<distro><path> when the worktree parses as a WSL UNC path (both modern \\wsl.localhost and legacy \\wsl$ forms). Every file-open call site — hit-testing, path-exists caching, stat, authorizeExternalPath, openFile, tooltip, and pendingEditorReveal — 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.

  • Rebase: clean onto origin/main (base 7ab601487c, head 9227939c8b).
  • Test file: terminal-link-handlers.test.ts — passes on branch, fails when the fix is reverted (proven regression guard).
  • Lint: oxlint clean on all 3 changed source files (no warnings/errors).
On branch:                Test Files 1 passed | Tests 89 passed (89)
Fix reverted (test kept): Test Files 1 failed | Tests 8 failed | 81 passed
  - "maps POSIX OSC file links for a WSL worktree before opening them"
    expected authorizeExternalPath({targetPath: //wsl.localhost/Ubuntu/root/...})
  - "preserves existing UNC and native paths": mapTerminalFilePath is not a function
  - "does not map POSIX paths for a native Windows worktree": mapTerminalFilePath is not a function

Trade-offs

None — pure fix.

Regression risk

Zero-regression by construction: mapTerminalFilePath is a pure, tightly-guarded transform. Non-WSL worktrees hit the identity path (parseWslUncPath returns null), 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.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it does not follow the required template sections or testing checklist format. Reformat the PR description to the repo template and add Screenshots, Testing, AI Review Report, Security Audit, and Notes sections with the required details.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests map WSL POSIX terminal paths to UNC while preserving native and UNC behavior, matching #8156.
Out of Scope Changes check ✅ Passed Changes stay within terminal file-link routing and tests, with no unrelated feature work visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise and matches the main change: making WSL terminal file links open correctly on Windows.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@michaeljune0

Copy link
Copy Markdown

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 // guard also preserves the UNC forms that already worked in my format-matrix test, so all the cases from the report should be covered. Looking forward to the release!

@nwparker
nwparker force-pushed the pr/open-wsl-file-links-on-windows branch from 9227939 to 392fa9c Compare July 23, 2026 11:48
@nwparker
nwparker merged commit c63ab96 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @rodboev — open WSL file links on Windows. Reviewed, rebased on latest main, and merged. Really appreciate the contribution! 🙏

OrcaWin pushed a commit that referenced this pull request Aug 8, 2026
… 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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants