Skip to content

fix(editor): match WSL UNC paths across forward-slash and backslash forms - #13423

Closed
Pr1p wants to merge 2 commits into
stablyai:mainfrom
Pr1p:fix/wsl-unc-path-stale-reload
Closed

Pr1p wants to merge 2 commits into
stablyai:mainfrom
Pr1p:fix/wsl-unc-path-stale-reload

Conversation

@Pr1p

@Pr1p Pr1p commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

WSL files opened from terminal links use the forward-slash UNC form (//wsl.localhost/Ubuntu/...), but file watcher events emit the backslash form (\\wsl.localhost\Ubuntu\...). The raw string equality in getOpenFilesForExternalFileChange never matched, so the editor tab stayed stale after external edits. This PR folds both sides through normalizeRuntimePathForComparison, which already handles separator style, the wsl.localhost/wsl$ alias, and distro case folding.

Closes #13349.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Added a regression test in editor-autosave.test.ts that matches a forward-slash UNC tab (//wsl.localhost/Ubuntu/...) against a backslash watcher path (\\wsl.localhost\Ubuntu\...) and asserts the tab is included in the reload set.

AI Review Report

The change adds one import and replaces a raw === comparison with a call to an existing, well-tested normalization function. The main risk reviewed was non-idempotency of normalizeRuntimePathForComparison for WSL UNC paths — the function is documented as not safe to re-normalize an already-normalized value. The fix calls it on both raw values independently (never on an already-normalized value), so this trap does not apply.

Cross-platform compatibility was checked for macOS, Linux, and Windows: normalizeRuntimePathForComparison only folds separators and lowercases for Windows drive letters and WSL UNC aliases; POSIX paths are returned with NFC normalization and forward-slash folding only, so macOS/Linux behavior is unchanged.

Security Audit

No new command execution, IPC, network access, authentication, secrets, or filesystem path handling beyond passing existing strings through an existing pure comparison-normalization function. No dependency changes.

Notes

The non-idempotency caveat in cross-platform-path.ts applies to storing canonical forms; this PR only compares, so it is not affected.

@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: 9db0c73d-d8a8-4f0c-b92f-f785543904c0

📥 Commits

Reviewing files that changed from the base of the PR and between 476f06a and ec0f0bc.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/editor-autosave.test.ts
  • src/renderer/src/components/editor/editor-autosave.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/editor/editor-autosave.ts
  • src/renderer/src/components/editor/editor-autosave.test.ts

📝 Walkthrough

Walkthrough

The autosave matcher now normalizes runtime paths before comparing external file-change paths with edit and markdown-preview tabs. The change supports equivalent forward-slash and backslash WSL UNC paths. A test verifies matching between a WSL terminal-link tab and an external watcher event.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the WSL UNC path matching fix.
Description check ✅ Passed The description includes the required sections, user-visible impact, regression test, review report, security audit, and notes.
Linked Issues check ✅ Passed The changes directly fix issue #13349 by matching forward-slash and backslash WSL UNC paths during editor reload detection.
Out of Scope Changes check ✅ Passed The changes are limited to path comparison normalization and regression coverage for the linked WSL reload issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

🧹 Nitpick comments (1)
src/renderer/src/components/editor/editor-autosave.test.ts (1)

262-277: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for markdown-preview mode.

getOpenFilesForExternalFileChange applies normalization to both edit and markdown-preview, but this test only uses the default edit mode. Parameterize the case or add a markdown-preview fixture to protect both modes.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ad05c0ab-2963-4832-a436-2b2eb5f543d2

📥 Commits

Reviewing files that changed from the base of the PR and between ced2719 and 1f58ee58b1f604b71d364733063ca424c6ef67f4.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/editor-autosave.test.ts
  • src/renderer/src/components/editor/editor-autosave.ts

@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

4 participants