Skip to content

fix(terminal): open WSL UNC links with Windows path form - #13692

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/13349-wsl-unc-forward-slash-stale
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/13349-wsl-unc-forward-slash-stale

Conversation

@bbingz

@bbingz bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Terminal links like //wsl.localhost/Ubuntu/... opened files under a different path string than the Files sidebar (\\wsl.localhost\Ubuntu\...).
  • File-change watchers and open-tab identity use the stored path, so the forward-slash form stayed stale after edits.
  • Canonicalize WSL UNC (both // and \\ inputs) to the Windows backslash form when mapping terminal paths so open + watch match the sidebar.

Test plan

  • terminal-link-handlers tests (98)
  • Manual on Windows: click //wsl.localhost/... terminal link, edit file in WSL, editor should refresh

Fixes #13349

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c350c6b2-bc41-4838-87f9-4e30027e2f2b

📥 Commits

Reviewing files that changed from the base of the PR and between 4c69e45 and b361a68.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts

📝 Walkthrough

Walkthrough

The change standardizes WSL path handling in terminal file routing. Existing WSL UNC paths are normalized to Windows backslash UNC format. Absolute POSIX paths are converted through toWindowsWslPath when a WSL distro is available. Tests now use canonical backslash UNC paths for routing, cache keys, file opening, editor reveals, statistics, and path-existence checks. Additional coverage verifies normalization of both slash-form and backslash-form WSL UNC inputs.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug and test plan but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections and document cross-platform review, security checks, platform-specific risks, and the no-visual-change status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the fix for opening WSL UNC terminal links using the Windows path form.
Linked Issues check ✅ Passed The implementation and tests address issue #13349 by canonicalizing both WSL UNC forms to one Windows path identity.
Out of Scope Changes check ✅ Passed The changes are limited to WSL path mapping and related terminal-link tests, which match issue #13349.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04a3b0c1-8368-4950-bd5d-4208aedb4368

📥 Commits

Reviewing files that changed from the base of the PR and between a70291a and 170601f35a2d797c3151ca536ae50644dbecc125.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts

Comment on lines 67 to +73
const distro = wslDistro?.trim() || parseWslUncPath(worktreePath)?.distro
if (!distro || !filePath.startsWith('/') || filePath.startsWith('//')) {
if (!distro || !filePath.startsWith('/')) {
return filePath
}
// Why: /mnt/<drive> is a Windows drive mounted into WSL — reach it directly
// instead of routing a native file back through the 9P share.
if (/^\/mnt\/[a-z](\/|$)/.test(filePath)) {
return toWindowsWslPath(filePath, distro)
}
return `//wsl.localhost/${distro}${filePath}`
return toWindowsWslPath(filePath, distro)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve non-WSL // UNC paths.

If filePath is //server/share/file.md, parseWslUncPath returns null, but this branch converts it through toWindowsWslPath when distro exists. The result becomes \\wsl.localhost\Ubuntu\\server\share\file.md instead of preserving the network-share path. Keep the // exclusion for non-WSL UNC inputs. WSL UNC inputs already return from the preceding branch.

Proposed fix
-  if (!distro || !filePath.startsWith('/')) {
+  if (!distro || !filePath.startsWith('/') || filePath.startsWith('//')) {
     return filePath
   }

Add a regression test for //server/share/file.md.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const distro = wslDistro?.trim() || parseWslUncPath(worktreePath)?.distro
if (!distro || !filePath.startsWith('/') || filePath.startsWith('//')) {
if (!distro || !filePath.startsWith('/')) {
return filePath
}
// Why: /mnt/<drive> is a Windows drive mounted into WSL — reach it directly
// instead of routing a native file back through the 9P share.
if (/^\/mnt\/[a-z](\/|$)/.test(filePath)) {
return toWindowsWslPath(filePath, distro)
}
return `//wsl.localhost/${distro}${filePath}`
return toWindowsWslPath(filePath, distro)
const distro = wslDistro?.trim() || parseWslUncPath(worktreePath)?.distro
if (!distro || !filePath.startsWith('/') || filePath.startsWith('//')) {
return filePath
}
// Why: /mnt/<drive> is a Windows drive mounted into WSL — reach it directly
// instead of routing a native file back through the 9P share.
return toWindowsWslPath(filePath, distro)

@bbingz

bbingz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Ready for review (contributor priority pack)

  • Rebased / checked against current main where needed
  • Scoped bugfix; summary + test plan in the description
  • Community PR: please Approve and run workflows when convenient (fork CI stays off)
  • No maintainer merge expected from us — happy to iterate on review comments

Part of a short priority list for maintainers: P0 #13609 #13566 · hot #13710 #13692 #13691 #13536 #13572 #8072 #13237 · easy #13570 #13561 #13255.

Forward-slash //wsl.localhost links opened as a different path string than
the Files sidebar's backslash UNC, so file watchers did not refresh the
editor. Canonicalize WSL UNC to \\wsl.localhost\... at map time.

Fixes stablyai#13349
@bbingz
bbingz force-pushed the fix/13349-wsl-unc-forward-slash-stale branch from 170601f to b361a68 Compare August 11, 2026 19:26
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@OrcaWin

OrcaWin commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #13798, which preserves the contributed work while combining terminal-open canonicalization with guarded legacy watcher and tab alias handling. #13798 has now merged. Thank you for the implementation and diagnosis that informed the final fix.

@OrcaWin OrcaWin closed this Aug 11, 2026
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.

[Bug]: WSL file opened from forward-slash UNC terminal link stays stale after edits

3 participants