Skip to content

fix(web): respect case in POSIX file links - #9309

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
Michel-Liao:fix/posix-file-link-case
Sep 5, 2026
Merged

fix(web): respect case in POSIX file links#9309
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
Michel-Liao:fix/posix-file-link-case

Conversation

@Michel-Liao

@Michel-Liao Michel-Liao commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

On case-sensitive filesystems, an absolute path in a case-distinct sibling directory was treated as workspace-relative. Clicking the link could preview a different file than the message targets.

Compare POSIX workspace paths with their original case. Keep Windows drive and backslash UNC comparisons case-insensitive using the existing shared path classifier. The active shared markdown resolver now applies the same rule as the web display formatter, so web, desktop, and mobile resolve workspace membership consistently.

Fixes #4804. Preserves Michel Liao's original fix and review follow-ups, rebased onto current main. The shared-resolver regression cases requested from #4805 cover /, C:/, UNC share roots, and a percent-encoded final space. These cases are separate from case-sensitivity policy.

Verification against September 4, 2026 main:

  • Before the shared fix, three POSIX containment cases fail. The case-distinct sibling returns probe.txt instead of null; the exact-case control passes.
  • vp test run packages/client-runtime/src/markdownLinks.test.ts apps/web/src/markdown-links.test.ts apps/web/src/filePathDisplay.test.ts --maxWorkers=2: 154 tests pass.
  • Targeted lint, client-runtime typecheck, and web typecheck pass.

The root reviewer reproduced the wrong-file preview in the actual web client on September 5, 2026 at main 4d3907f6. With this exact patch integrated into main caf4981e, the lowercase sibling link opens the correct absolute host file read-only. The exact-case workspace link still opens its workspace file. Current-head CI and reviews pass.

Browser evidence

Before, the lowercase sibling link opens the uppercase workspace file:

Before: link to lowercase project incorrectly shows the uppercase Project file

After, the same link opens the correct lowercase sibling file:

After: link to lowercase project shows the correct sibling file read-only

GPT 6 Astra via Codex in T3 Code.


Note

Medium Risk
Changes core path containment logic for markdown file links and previews; wrong classification could still misroute opens, though behavior is narrowed to fix POSIX false positives while preserving Windows semantics.

Overview
Fixes incorrect workspace-relative classification on case-sensitive filesystems: POSIX paths were compared with .toLowerCase(), so a link under a case-distinct sibling (e.g. .../project/... vs workspace .../Project) could be treated as in-workspace and open the wrong preview.

Workspace containment now uses case-sensitive prefix checks when the workspace root is not a Windows absolute path (drives and backslash UNC roots still compare case-insensitively via isWindowsAbsolutePath). The shared workspaceRelativeFilePath resolver and web formatWorkspaceRelativePath formatter apply the same rule so link metadata, display paths, and previews stay aligned across clients.

Tests cover POSIX siblings, double-slash POSIX paths, Windows/UNC/drive-root roots, and regression cases for /, C:/, UNC shares, and percent-encoded trailing spaces.

Reviewed by Cursor Bugbot for commit b9228e1. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix case-insensitive path matching to apply only to Windows roots in formatWorkspaceRelativePath

  • Previously formatWorkspaceRelativePath and workspaceRelativeFilePath case-folded all paths unconditionally, incorrectly treating POSIX paths with differing directory casing as workspace-relative.
  • Now case-folding is conditional: Windows drive and UNC roots still match case-insensitively, while POSIX roots (including double-slash paths) compare case-sensitively.
  • The relative suffix is sliced from the original normalized path so display casing is preserved.
  • Added regression and table-driven tests across apps/web and packages/client-runtime covering POSIX, Windows drive, UNC, drive-root workspaces, and encoded trailing spaces.
  • Risk: POSIX file links whose directory casing differs from the workspace root casing will no longer be classified as workspace-relative; existing displays relying on the old case-insensitive behavior may show absolute paths instead.

Macroscope summarized b9228e1.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 3, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 09782ee. Configure here.

Comment thread apps/web/src/filePathDisplay.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b9228e1

Macroscope's review found this PR approvable — This is a narrowly scoped path-matching bug fix: POSIX workspace checks become case-sensitive while Windows drive and UNC behavior remains case-insensitive. The shared resolver and web formatter are covered by focused regression tests, with no applicable default or static-analysis policy changes.

You can add or adjust custom eligibility rules. Learn more.

Comment thread apps/web/src/filePathDisplay.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 3, 2026
@t3dotgg

t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-6 Astra (preview) responding on behalf of Theo

This note is part of an automated cleanup pass.

Preserve the focused edge cases from #4805 at dce9bffc36 when updating the shared markdown resolver: workspace roots / and C:/, a UNC share root, and /tmp/repo/file.ts%20 retaining the final space in its target path. Keep these separate from the case policy. A double-slash POSIX path must not become case-insensitive solely because it resembles UNC. The active containment code is now packages/client-runtime/src/markdownLinks.ts. This records the cases for review and does not claim they were ported or run.

@juliusmarminge
juliusmarminge force-pushed the fix/posix-file-link-case branch from 6cb7f3f to b9228e1 Compare September 4, 2026 23:39
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 4, 2026 23:39

Dismissing prior approval to re-evaluate b9228e1

@juliusmarminge
juliusmarminge merged commit 8faf031 into pingdotgg:main Sep 5, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Case-distinct POSIX Markdown file link opens the wrong workspace file

3 participants