Skip to content

fix(editor): unify local WSL terminal and watcher paths - #13798

Merged
OrcaWin merged 5 commits into
mainfrom
fix/wsl-path-identity-13349-v2
Aug 11, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
fix/wsl-path-identity-13349-v2

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Live Windows/WSL Electron E2E through the real watcher/editor pipeline The deterministic reproduction drives the real watcher event handler with a restored forward-UNC editor tab, emits the backslash/native Windows watcher event, advances the debounce clock deterministically, and proves the reload notification reaches that tab. It also covers restored /mnt/c tabs receiving native-drive events and negative controls for SSH and POSIX owners.

Live Electron E2E opened //wsl.localhost/Ubuntu-24.04/.../watched.txt in 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/c fixture could not be exercised because Windows rejected UNC access to that mount with EPERM; /mnt/c to 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 explicit local stamps, 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.

bbingz and others added 3 commits August 11, 2026 03:41
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
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

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

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #13349 by unifying forward-slash and backslash WSL paths while preserving required isolation and fail-closed behavior.
Out of Scope Changes check ✅ Passed The code and tests remain focused on local WSL path canonicalization, watcher matching, editor reuse, and related platform safeguards.
Title check ✅ Passed The title clearly summarizes the main change: unifying local WSL paths across terminal and watcher behavior.
Description check ✅ Passed The description covers the required summary, screenshots, testing, AI review, security audit, and platform-specific notes with detailed validation results.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: 28b05ec1-2a2d-4ff5-862f-48807fe326b3

📥 Commits

Reviewing files that changed from the base of the PR and between a0a654c and ed88a67.

📒 Files selected for processing (12)
  • src/renderer/src/components/editor/editor-autosave.test.ts
  • src/renderer/src/components/editor/editor-autosave.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts
  • src/renderer/src/hooks/useEditorExternalWatch-targets.test.ts
  • src/renderer/src/hooks/useEditorExternalWatch-wsl-repro.test.ts
  • src/renderer/src/hooks/useEditorExternalWatch.ts
  • src/renderer/src/lib/desktop-window-chrome.ts
  • src/renderer/src/store/slices/editor.test.ts
  • src/renderer/src/store/slices/editor.ts
  • src/shared/cross-platform-path.test.ts
  • src/shared/cross-platform-path.ts

@OrcaWin

OrcaWin commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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