Repository navigation
fix(desktop): compare sidebar and tab paths across separator styles (#5683) - #5689
Merged
Merged
Conversation
…5683) The sandboxed renderer's `window.path` shim is `pathe`, which always uses `/` (#4244, #4274), while the watcher, the main process and the Electron shell APIs use OS-native separators (`\` on Windows). Comparing those paths with `===` silently missed matches on Windows, which broke folder rename/delete, new-file and tab lookups, and the Delete/F2 key guards. This restores the Windows tree behavior that #728 fixed with the native `path.sep`; the sandbox migration replaced node's `path` with `pathe`, regressing it. - Compare tree paths with `isSamePathSync` so renamed/deleted folders stop lingering in the sidebar. - Use the same comparison for the new-file cache, the current-file highlight, tab switch/save-status and rename bookkeeping. - Make `isPathWithinRoot` separator-insensitive so Delete/F2 reach files. - Convert renderer `/` paths to the native separator at the shell boundary (`shell.trashItem` / `showItemInFolder` / `openPath`), fixing the Windows "Failed to parse path" error. `mt::fs::*` needs no change: fs-extra accepts `/` on Windows.
Jocs
force-pushed
the
fix/5683-sidebar-folder-native-path-separators
branch
from
October 9, 2026 11:47
9535a6e to
ec4084c
Compare
Member
Tkaixiang
approved these changes
Oct 9, 2026
2 of 6 tasks
Jocs
added a commit
that referenced
this pull request
Oct 10, 2026
Follow-up to #5689. Rather than comparing mixed-separator paths, remove the mismatch at its source: the sandboxed preload now supplies a real Windows path module, so the renderer builds native paths exactly like the watcher and the main process. - preload: `@std/path/windows` on Windows (JSR, via npm.jsr.io), `pathe` on POSIX - electron-vite: inline `@jsr/std__path` into the preload bundle - replace the last hardcoded `/` filesystem join (`CREATE_FILE_DIRECTORY`) - drop the #5689 separator patches (`isSamePath` comparisons, `isPathWithinRoot` folding, `toNativePath`) and the specs that encoded the mixed-separator state `platform-path-windows.spec.ts` drives the real stores with a win32 path module and asserts renderer-built paths are byte-identical to the watcher/main paths, so plain `===` matches — the gate for dropping the patches.
Jocs
added a commit
that referenced
this pull request
Oct 10, 2026
…5669) Follow-up to #5689. Rather than comparing mixed-separator paths, remove the mismatch at its source: the renderer and its preload now use a real Windows path module, so every path they build matches the native paths from the watcher, the main process and the OS. - add `createPlatformPath(isWindows)` (`@jsr/std__path` win32 on Windows, `pathe` on POSIX) and use it for the preload's `window.path` - alias the bare `path` specifier in the renderer build to the same platform path, so shared helpers like `common/envPaths` stop producing `/` paths on Windows - title bar breadcrumb: split on the platform separator — fixes #5669, where a native `C:\…` path was split on `/` and only the filename showed - replace the last hardcoded `/` filesystem join (`CREATE_FILE_DIRECTORY`) - drop the #5689 separator patches (`isSamePath` comparisons, `isPathWithinRoot` folding, `toNativePath`) and the specs that encoded the mixed-separator state `platform-path-windows.spec.ts` drives the real stores with a win32 path module and asserts renderer-built paths are byte-identical to the watcher/main paths, so plain `===` matches — the gate for dropping the patches.
3 of 6 tasks
Zane-0x5a
added a commit
to Zane-0x5a/marktext
that referenced
this pull request
Oct 10, 2026
Takes upstream's separator-insensitive isPathWithinRoot from marktext#5689 over the fork's UNC-aware variant: folding every run of separators to '/' already matches a backslash UNC path against '//server/share'. The fork's mixed-separator UNC spec goes with it. Keeps pdfjs-dist on top of the marktext#5687 dependency upgrades, leaves deep-equal out, and regenerates the lockfile from upstream's.
Jocs
added a commit
that referenced
this pull request
Oct 11, 2026
…5669) (#5691) Follow-up to #5689. Rather than comparing mixed-separator paths, remove the mismatch at its source: the renderer and its preload now use a real Windows path module, so every path they build matches the native paths from the watcher, the main process and the OS. - add `createPlatformPath(isWindows)` (`@jsr/std__path` win32 on Windows, `pathe` on POSIX) and use it for the preload's `window.path` - alias the bare `path` specifier in the renderer build to the same platform path, so shared helpers like `common/envPaths` stop producing `/` paths on Windows - title bar breadcrumb: split on the platform separator — fixes #5669, where a native `C:\…` path was split on `/` and only the filename showed - replace the last hardcoded `/` filesystem join (`CREATE_FILE_DIRECTORY`) - drop the #5689 separator patches (`isSamePath` comparisons, `isPathWithinRoot` folding, `toNativePath`) and the specs that encoded the mixed-separator state `platform-path-windows.spec.ts` drives the real stores with a win32 path module and asserts renderer-built paths are byte-identical to the watcher/main paths, so plain `===` matches — the gate for dropping the patches.
Wangqkoe
pushed a commit
to Wangqkoe/marktext
that referenced
this pull request
Oct 24, 2026
…arktext#5683) (marktext#5689) Local changes to the pick: the legacy tab lookup in editor.ts uses isSamePath while the local workspace branch is unchanged; treeFile.vue takes only the isSamePath import (the others belong to unpicked rename and reveal features); the new-file cache spec sends the Folder root identity that local tree events require. (cherry picked from commit 34ea993) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Wangqkoe
pushed a commit
to Wangqkoe/marktext
that referenced
this pull request
Oct 24, 2026
…xt#5683, marktext#5669) (marktext#5691) Local changes to the pick: - pnpm-lock.yaml only gains @jsr/std__path and its @jsr/std__internal dependency; a full install would also have moved the unpinned file-icons tarball and reshuffled eslint peer entries. - Keeps the local @intlify/core-base version. - Drops the marktext#5689 isSamePath comparisons in the local editor.ts workspace fallback and project.ts as upstream does; treeFile.vue needs none of the unpicked rename/row-registry imports. - platform-path-windows.spec.ts sends the Folder root identity local tree events require and the allowEditableTarget field local TrashKeyContext has. (cherry picked from commit 127c5bb) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #5683
Summary
On Windows, renaming or deleting a folder left the old folder row in the sidebar, and deleting a folder failed with
Error invoking remote method 'mt::fs-trash-item': Error: Failed to parse path.The sandboxed renderer's
window.pathshim ispathe, which always uses/, while the watcher, the main process and the Electron shell APIs use OS-native separators (\on Windows). Comparing those paths with===silently missed matches, so the watcher'sunlinkDir/unlinknever removed the renderer-built folder node, and the/path was rejected by Windows'shell.trashItem(SHCreateItemFromParsingName).This restores the Windows tree behavior that #728 fixed; the sandbox migration replaced node's
pathwithpathe(#4244, #4274) and regressed it. The fix:isSamePathSynchelper (separator/case insensitive),isPathWithinRootguard separator-insensitive,/paths to the native separator at the OS shell boundary (shell.trashItem/showItemInFolder/openPath).Type of change
Test plan
sidebar-windows-path-separators.spec.ts— fails before the fix (renamed/deleted folder lingers after a native-separator watcher event)sidebar-new-file-native-separators.spec.ts— new-file cache matched across separatorsnative-path-shell-5683.spec.ts—toNativePathconverts renderer/paths on Windowssidebar-trash-key.spec.ts— mixed-separatorisPathWithinRootcasesissue-5683-sidebar-folder-native-separators.spec.ts(e2e) — real app: injecting the native-separatorunlinkDirthe watcher sends on Windows removes the folder rowtrash-item-confirm.spec.tsupdated to assert the native-normalized path so it holds on thewindows-latestunit jobvitest run1076 passed; sidebar e2e suite passes;pnpm run typecheckandpnpm run lintcleanmacOS only (no Windows host available). The Windows shape was reproduced by feeding native-separator watcher events — both at the module level with the real
treeCtrl, and end-to-end in the running app (out/built from this branch). The new unit specs also run for real onwindows-latestin CI (fix(tests): Windows paths + CI + timeout fix #5323).Notes for reviewers [optional]
How Windows paths were handled before (the fix follows these conventions rather than adding a new one):
node:path, soPATH_SEPARATOR = path.sepwas native; Fix Windows path separator in tree view #728 built tree paths with the platform separator. Tree nodes and watcher events both used\and matched.node:pathfrom the renderer — a sandboxed preload can onlyrequireelectron/events/timers/url— and FIx: switch path-browserify to Pathe + image pasting on windows + cleanup console.logs #4274 switched the shim topathe, which always emits/(itswin32is/too). That is the regression./, tests must stubwindow.pathwithpathe, and native paths are normalized/compared tolerantly (isSamePathSync; dual-separator regexes inresolveLinkHref/resolveImageSrc/localPathToFileUrl).mt::fs::*needs no change: main hands the renderer's/paths straight tofs-extra, which accepts/on Windows. Only the OS shell APIs need the native separator.Known limitations / decisions:
/and file nodes with the watcher's native separator; this PR makes the comparisons separator-insensitive rather than forcing one style, becausepathecan't emit Windows separators and the sandboxed preload can't loadnode:path.toNativePathkeepspath.win32.normalizebehind an injectablesepso the Windows branch is unit-testable on any runner.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.