Repository navigation
Open Windows file links in rendered Markdown - #4665
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05df29d53e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isWindowsDriveLocalFilePath(payload.destination)) { | ||
| const windowsDestination = payload.destination.replaceAll("\\", "/"); |
There was a problem hiding this comment.
Preserve opening parentheses after Windows separators
Handle a backslash before ( as a Windows path separator while locating the destination end. For a valid path such as [draft](C:\docs\(draft).md), findInlineLinkDestinationEnd treats \( as a Markdown escape, skips the opening parenthesis, and mistakes the filename's ) for the link terminator. Consequently this branch receives a truncated destination and the link remains broken or, when the truncated prefix contains a dot, is rewritten to the wrong file.
Useful? React with 👍 / 👎.
05df29d to
656b43f
Compare
A link to `C:\src\repo\file.ts` rendered as plain text: the drive letter was read as a URL scheme and dropped, and Markdown ate backslashes that precede punctuation. `file:///C:/…` links rendered as external links. - Treat a drive-letter path as a local file path, not a URL, and accept `file:///C:/…` and editor URLs that carry one. - Rewrite Windows link destinations to forward slashes before Markdown parses them. - Render the anchor as a `file:///C:/…` URL. Co-Authored-By: Claude Code <[email protected]>
The destination scanner treated every backslash as a Markdown escape, so 'C:\docs\(draft).md' lost its opening parenthesis and ended at the filename's closing one. A destination that starts with a drive path now reads backslashes as separators. Co-Authored-By: Claude Code <[email protected]>
656b43f to
8c29f9b
Compare
Human comments
What was wrong
File links that an agent prints with a Windows path did not work in rendered Markdown:
[readme](C:\src\repo\README.md)and[readme](C:/src/repo/README.md:12)rendered as plain text. The link parser tested the href against a URI-scheme pattern first, soC:was read as a scheme, the href was not recognised as a local file, and the default URL transform dropped it.C:\src\repo\.config\app.jsonlost its\.before the parser saw it.file:///C:/src/repo/README.mdparsed to the POSIX-looking path/C:/src/repo/README.mdand rendered as an external link.Part of #1206. Stacked on #4659, which adds the Windows-aware path helpers this uses for containment.
What changed
apps/app/src/components/ui/markdown-local-file-link.ts: a drive-letter path (C:\…orC:/…) is a local file path, not a URL.file:and editor URLs whose pathname is/C:/…yieldC:/…. Validation rejects drive roots and directory paths the same way it rejects/and trailing-slash POSIX paths.buildLocalFileAnchorHrefrenders a Windows link asfile:///C:/…with each segment percent-encoded.markdown-local-file-link-normalize.ts: before Markdown parsing, an inline link destination that is a Windows drive path is rewritten to forward slashes inside angle brackets, so no backslash is consumed as an escape and spaces survive. While finding where such a destination ends, a backslash is read as a path separator, not an escape, so[draft](C:\docs\(draft).md)keeps its parentheses and becomes<C:/docs/(draft).md>.POSIX link handling is unchanged; the existing tests pass unmodified.
How you verified
[readme](C:\src\testrepo\README.md),[fwd](C:/src/testrepo/README.md:1), and[uri](file:///C:/src/testrepo/README.md)rendered three anchors with hrefsfile:///C:/src/testrepo/README.md,…README.md#L1, and…README.md. Clickingfwdopened the file preview panel titledC:\src\testrepo\README.mdshowing the file's contents. Before the change the first two were plain text and the third was an external link.turbo run lint typecheck test --filter=@bb/apppasses (6 of 6 tasks). New tests cover drive paths with line suffixes,file:///C:/…URLs, rejected roots and directories, case-insensitive containment in a Windows workspace root, the rendered anchor href, relative links under a Windows root, and the normalization of backslash and space-containing destinations and of a file name in parentheses after a separator. The two link test files also pass on the VM (41 of 41).Not verified: bare Windows paths that are not Markdown links are still plain text (the same is true of bare POSIX paths); editor-scheme URLs (
vscode://file/C:/…) are covered only by the shared parsing path, not by a click on Windows.🤖 Generated with Claude Code