Repository navigation
fix(editor): unify local WSL terminal and watcher paths - #13798
Conversation
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 #13349
📝 WalkthroughWalkthroughThe changes add Windows and WSL path-alias normalization and local Windows desktop detection. Terminal routing now resolves WSL distros and canonicalizes WSL paths. Editor reuse and autosave matching support guarded local aliases. External file watching carries alias support through target creation and reload notifications. Tests cover local Windows, Linux, web, SSH, remote-runtime, and missing-metadata cases. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 28b05ec1-2a2d-4ff5-862f-48807fe326b3
📒 Files selected for processing (12)
src/renderer/src/components/editor/editor-autosave.test.tssrc/renderer/src/components/editor/editor-autosave.tssrc/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/components/terminal-pane/terminal-link-handlers.test.tssrc/renderer/src/hooks/useEditorExternalWatch-targets.test.tssrc/renderer/src/hooks/useEditorExternalWatch-wsl-repro.test.tssrc/renderer/src/hooks/useEditorExternalWatch.tssrc/renderer/src/lib/desktop-window-chrome.tssrc/renderer/src/store/slices/editor.test.tssrc/renderer/src/store/slices/editor.tssrc/shared/cross-platform-path.test.tssrc/shared/cross-platform-path.ts
|
@coderabbitai review |
|
Summary WSL can spell the same local file as
//wsl.localhost/Ubuntu/...,\\wsl.localhost\Ubuntu\..., or (for mounted drives)C:\.... A terminal-opened tab could therefore stop refreshing because the watcher and editor compared different spellings. This PR combines the strongest parts of the related fixes: - canonicalize new local WSL terminal links at open time - retain a guarded watcher fallback for restored forward-UNC tabs - reuse restored local aliases instead of opening duplicate tabs - keep SSH, paired runtimes, POSIX desktops, paired-web clients, and non-WSL UNC paths literal - fail closed while ownership metadata is missing, ambiguous, malformed, or future-versioned Closes #13349. Supersedes #13423, #13692, and #13605; they should not merge independently. Credit: - @bbingz authored the terminal canonicalization; that authored commit is preserved in this branch. - @Pr1p authored the watcher slash-matching fix; that authored commit is preserved in this branch. - @manuaudio contributed the diagnosis and control-case design that shaped the final guarded implementation. ## Screenshots No visual change. ## Testing - [x]pnpm lint(equivalent strict native and type-aware lint commands run with warnings denied) - [x]pnpm typecheck- [x] Focused test suite: 8 files / 380 tests - [x] CI unit-test matrix on Node 24 and Node 26 - [x] CI package checks, including Windows - [x] Added deterministic regression and negative-control tests/mnt/ctabs receiving native-drive events and negative controls for SSH and POSIX owners.Live Electron E2E opened
//wsl.localhost/Ubuntu-24.04/.../watched.txtin a local folder workspace, then changed the same file through\\wsl.localhost\Ubuntu-24.04\...\watched.txt. The rendered editor changed from the before marker to the after marker, the original forward-UNC tab stayed clean and received a new disk signature, and the console reported zero errors.A live
/mnt/cfixture could not be exercised because Windows rejected UNC access to that mount withEPERM;/mnt/cto drive-letter identity remains covered by deterministic integration tests. ## AI Review Report Three independent review agents checked correctness, host ownership/isolation, tests, and performance after iterative fixes. The original broad implementation was rejected because it introduced incomplete parallel host routing; this focused implementation was rebuilt around the terminal-open and watcher boundaries. Final internal review was clean before the CodeRabbit pass. CodeRabbit then identified that missing host stamps were still treated as local. Catalog hydration was traced end-to-end, the guard was changed to require explicitlocalstamps, and missing-worktree/missing-repo regression tests were added. The post-implementation review then found avoidable owner-resolution work, missing folder-workspace coverage, and a /mnt/c delete/recreate tombstone gap. The final delta moves the cheap alias check first, preserves O(1) literal matching, covers local/SSH/missing/duplicate folder ownership, and applies the validated alias capability consistently across update, delete, and recreate handling. A paired runtime + SSH control test prevents dual-owner routing regressions. Cross-platform review explicitly covered Windows, WSL UNC and drive aliases, macOS/Linux literal path semantics, paired web, Electron desktop detection, SSH, runtime ownership, and folder workspaces. No shortcuts, labels, or shell behavior changed. ## Security Audit Path aliasing is opt-in only for explicit local ownership and a local Windows desktop. Missing, blank, malformed, future, SSH, runtime, paired-web, POSIX, and non-WSL UNC cases fail closed. No commands are executed, no auth/secrets/dependencies change, and no IPC or remote-wire payload changes were introduced. Alias parsing is limited to recognized WSL/local-drive forms and cannot redirect SSH or runtime reads/writes. ## Notes - The watcher carries one extra internal snapshot capability bit and performs alias parsing only for opted-in local Windows candidates. - Restored legacy tabs keep their existing persisted ID/path until reopened; compatibility matching remains for them. - Ownership-uncertain tabs intentionally stay literal until catalog hydration proves they are local. - CodeRabbit's generic docstring-coverage warning was not addressed with boilerplate; repository style requires concise, non-obvious comments and the changed code is already documented where the reasoning is not evident.