fix(desktop): give the renderer a platform-native path bridge (#5683, #5669) by Jocs · Pull Request #5691 · marktext/marktext · GitHub
Skip to content

fix(desktop): give the renderer a platform-native path bridge (#5683, #5669) - #5691

Merged
Jocs merged 1 commit into
developfrom
poc/std-path-windows
Oct 11, 2026
Merged

Jocs merged 1 commit into
developfrom
poc/std-path-windows

Conversation

@Jocs

@Jocs Jocs commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Closes #5669

Follow-up to #5689 (issue #5683, closed there).

Summary

#5689 made the sidebar/tab path lookups tolerant of mixed separators. This PR removes the mismatch at its source instead: 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 — and plain === matches. The #5689 patches (isSamePath comparisons, isPathWithinRoot folding, toNativePath) are then redundant and are removed here.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added (or explain why not needed)
    • platform-path-windows.spec.ts drives the real stores (treeCtrl, project, editor, trashKey) with a win32 path module and asserts renderer-built paths are byte-identical to the watcher/main paths — the gate for dropping the patches — plus createPlatformPath for both branches
    • title-bar-path-breadcrumb.spec.ts covers the [Bug] The title bar only displays the file name, but not the file path. #5669 breadcrumb split on \ and /
    • full desktop unit suite 1082 passing; sidebar + title bar e2e passing; pnpm run typecheck and pnpm run lint clean
  • Manually tested on:
    POSIX verified locally (macOS) and by the e2e job. Not yet on Windows. CI's windows-latest unit job stubs window.path and e2e only runs on Linux, so CI cannot validate the preload/alias change on a real Windows renderer. This needs a Windows e2e job or a manual Windows pass before merge.

Notes for reviewers [optional]

  • New dependency/registry: @jsr/std__path from JSR (@jsr:registry=https://npm.jsr.io in .npmrc). If that is undesirable, the alternatives are path-win32 (npm, older) or vendoring the win32 subset.
  • The renderer build now aliases path to src/renderer/src/node/platformPath.ts (was pathe), which is the module-level counterpart of the preload's window.path.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

@Jocs
Jocs force-pushed the poc/std-path-windows branch 3 times, most recently from 4f0884b to 9c4377f Compare October 10, 2026 04:19
@Jocs Jocs changed the title chore(poc): back renderer window.path with a real win32 path fix(desktop): give the renderer a platform-native path bridge (#5683) Oct 10, 2026
@Jocs
Jocs marked this pull request as ready for review October 10, 2026 04:19
…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.
@Jocs
Jocs force-pushed the poc/std-path-windows branch from 9c4377f to e12100a Compare October 10, 2026 04:25
@Jocs Jocs changed the title fix(desktop): give the renderer a platform-native path bridge (#5683) fix(desktop): give the renderer a platform-native path bridge (#5683, #5669) Oct 10, 2026
@Jocs
Jocs requested a review from Tkaixiang October 10, 2026 04:35
@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5691:

Run: https://github.com/marktext/marktext/actions/runs/38024006665

Artifact Size Link
marktext-windows-arm64 288.6 MB Download
marktext-linux 661.1 MB Download
marktext-macos-x64 311.1 MB Download
marktext-macos-arm64 297.8 MB Download
marktext-windows-x64 296.7 MB Download

Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 10, 2026
Takes the open PR's head (e12100a) ahead of its upstream merge: the
renderer and preload get a win32 path module on Windows, so the paths they
build match the watcher's and plain comparisons work again. Its full unit
suite and the desktop e2e suite pass on Windows 11, apart from the
failures develop already has on this machine.

Two fork specs still encoded the mixed-separator tree: the marktext#528 reveal
spec matches folder rows by their native path, and the rename spec checks
a Windows root with a Windows separator.

@Tkaixiang Tkaixiang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, tested reading, saving, tab switching + external file edits etc, all works fine

@Jocs
Jocs merged commit 127c5bb into develop Oct 11, 2026
19 of 20 checks passed
Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 15, 2026
Upstream reworked the old print path (marktext#5722 makes MarkdownPrint wait for
the notation fonts; marktext#5716 resolves URL-encoded Windows image paths). The
fork replaced that path with the paged preview, so printService and its
two specs keep the fork's side. Both fixes still reach the preview: the
image fix lives in resolveLocalImageSrc, which exportHtml uses, and the
notation fonts arrive through the muya export styles, the export themes
and getCssForOptions. Main already waits for fonts.ready under print
media before printToPDF.

marktext#5746 drops the Info tab and explains that a table of contents needs a
[TOC] line. The HTML export dialog takes both changes. The print preview
panel shows the same explanation under its contents settings.

The preload keeps the fork's visual zoom limit next to upstream's
platform path import, and the editor store keeps isSameList.

marktext#5691 was merged earlier from its PR head; upstream's squash differs from
it only by commits that came in alongside it.

Verified on Windows 11: typecheck, desktop and muya lint, and the desktop
unit suite pass. In the muya unit suite, only the tableChessboard
entrypoint import timed out, and only on cold runs (it passes alone). The
print, export, sidebar, theme and title bar e2e specs plus upstream's new
3510, 5394, 5683 and 5710 specs pass in background windows, except 5394's
exact `toBe(400)` width check. At this machine's 1.75 device pixel ratio
the restored width reads 400.0000305, with or without the camera
transform; with `toBeCloseTo(400, 3)` all three scenarios pass.
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] The title bar only displays the file name, but not the file path.

2 participants