Skip to content

fix(desktop): resolve preview paths on macOS and Linux - #59

Merged
arifintahu merged 1 commit into
mainfrom
fix/preview-paths-on-macos
Nov 23, 2026
Merged

arifintahu merged 1 commit into
mainfrom
fix/preview-paths-on-macos

Conversation

@arifintahu

Copy link
Copy Markdown
Member

What and why

CI on main failed on the Markdown preview merge: Rust (macos-latest), test preview_path::tests::pwsh_paths (left d:/users/runner/n.md, right /users/runner/n.md). Windows and the frontend passed.

The test was a symptom of a real bug: the preview's path resolution assumed a Windows computer. On macOS a path such as /Users/me/api/README.md was run through the Windows mapping (Git Bash /d/x, drive letters), so Ctrl+click on a Markdown file would have failed with "outside the Windows drives", and relative links and images in a document resolved to Users\me\api\docs\a.md, a relative path with Windows separators that the backend refuses.

  • Rust (preview_path.rs): resolution now takes the host as an explicit Host (Windows or Unix). On Unix a path stays a POSIX path: joined to the pane's folder, .. clamped at /, ~ expanded, no drive letters, and //host/share still refused because terminal output can forge it. resolve_preview_path picks the host with cfg!(windows). The home folder is now passed in instead of read inside the function, which also removes the host-dependent test input that failed on the runner.
  • Frontend (links.ts): resolveRelative keeps / separators and the leading / for a POSIX document path.
  • Small fix on the way: a relative path with no reported folder yet now says "working folder unknown" instead of resolving against the root (a review note on the original PR).

How you checked it

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test: clean, 139 passed. The Windows-host tests now pin Host::Windows with a fixed home folder, and six new tests pin Host::Unix (relative and absolute paths, ~, .. at the root, no drives or network paths, no WSL, missing folder), so both hosts are tested on any machine.
  • pnpm turbo check test build: pass, 357 Vitest tests (four new for POSIX resolveRelative, written first and failing with Users\me\api\docs\setup.md).
  • pnpm version:check: pass.
  • Not run on macOS. I have no Mac here. The macOS CI job runs after the merge and is the check that closes this; the failing test is the one it should now pass.

Known gaps

  • The preview has only been exercised by hand on Windows (Git Bash). macOS needs one manual pass: Ctrl+click a .md name, a relative link, a local image.

  • zsh is treated like bash for the shell hook; nothing here changes that.

  • cargo fmt --check, cargo clippy -- -D warnings and cargo test pass

  • pnpm turbo check test build and pnpm version:check pass

  • Bug fixes have a test that failed before the fix

  • No secrets, personal paths or machine names in the diff

  • Docs and CHANGELOG.md updated if behaviour changed (the preview is unreleased, so no new entry)

The resolver assumed a Windows computer, so on macOS a POSIX path went through the Git Bash and drive-letter mapping and failed, and relative links and images got Windows separators. Resolution now takes the host explicitly: on Unix a path stays a POSIX path, still refusing network paths. main CI failed on this in preview_path::tests::pwsh_paths on the macOS runner.
@arifintahu arifintahu added the bug Something isn't working label Nov 23, 2026
@arifintahu
arifintahu merged commit 88cb072 into main Nov 23, 2026
4 checks passed
@arifintahu
arifintahu deleted the fix/preview-paths-on-macos branch November 23, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant