fix(web): open Windows markdown file links - #4545
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Needs human review This PR adds custom markdown parsing logic and modifies URL sanitization behavior for Windows file paths. As a first-time contributor's change to URL transformation logic, human review is recommended to verify edge cases and security considerations. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Why
Codex can emit file links using Windows paths, for example:
React Markdown can sanitize or alter these destinations before the anchor renderer receives them. The result is a blue link that has no href and does nothing when clicked.
This change recovers and validates the original filesystem destination, then routes it through T3 Code's existing file-reference UI.
External URL schemes continue to use the normal URL sanitizer.
UI Changes
Before: sometimes, the filename would appear as an inert blue link.

After: it renders as T3 Code's native file chip and opens the file in the right-side panel.

Verification
vp test run src/markdown-links.test.ts --project unit— 24 tests passedvp run typecheckChecklist
Note
Low Risk
Scoped to chat markdown link parsing and sanitization; external URLs still use the default sanitizer and unsafe schemes are explicitly rejected in tests.
Overview
Fixes inert blue links when chat markdown uses Windows-style file paths (e.g.
C:\Users\...\file.md) that React Markdown sanitizes or mangles before rendering.markdown-linksadds helpers to keep recognized filesystem paths through URL sanitization (preserveMarkdownFileLinkHref), normalize file href keys (normalizeMarkdownFileLinkHref), and re-read the raw destination from the source markdown via AST offsets (extractMarkdownLinkDestinationAtOffsets) when the parsedhrefloses backslashes or encoding.ChatMarkdownwiresurlTransformto preserve validated file paths (still falling back todefaultUrlTransformfor real URLs), resolves file-link metadata from both sanitized and recovered hrefs, and uses the source destination for copy-to-clipboard markdown. File links continue to render as the native file chip and open in the side panel.New unit tests cover Windows paths, spaces, angle-bracket destinations, encoded hrefs, and rejection of unsafe schemes like
javascript:.Reviewed by Cursor Bugbot for commit 165116b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix markdown file link resolution for Windows paths in
ChatMarkdownextractMarkdownLinkDestinationAtOffsetsto markdown-links.ts to recover raw link destinations (including Windows-style paths and space-containing paths) from parsed node offsets.preserveMarkdownFileLinkHrefandnormalizeMarkdownFileLinkHrefto normalize and validate file link hrefs against the workspace or filesystem before React Markdown sanitizes them.Macroscope summarized 165116b.