Render path-like inline code as file chips#3134
Conversation
- Promote unambiguous inline code paths to clickable file chips - Add resolution tests for line-suffixed paths and disambiguation
|
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 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)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Fenced backticks pollute chip labels
- Added a fenced code block stripping step in extractMarkdownInlineCodeValues so backtick-enclosed content inside triple-backtick fences is no longer matched by the inline code regex, preventing phantom paths from polluting the parent-suffix disambiguation map.
Or push these changes by commenting:
@cursor push b8122e3bfe
Preview (b8122e3bfe)
diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx
--- a/apps/web/src/components/ChatMarkdown.tsx
+++ b/apps/web/src/components/ChatMarkdown.tsx
@@ -690,6 +690,7 @@
const MARKDOWN_LINK_HREF_PATTERN = /\[[^\]]*]\(([^)\s]+)(?:\s+["'][^"']*["'])?\)/g;
const MARKDOWN_INLINE_CODE_PATTERN = /(?<!`)(`{1,2})(?!`)([\s\S]*?)(?<!`)\1(?!`)/g;
+const MARKDOWN_FENCED_CODE_BLOCK_PATTERN = /^(`{3,}|~{3,})[^\n]*\n[\s\S]*?^\1\s*$/gm;
const MARKDOWN_FILE_LINK_CLASS_NAME =
"chat-markdown-file-link cursor-pointer transition-colors hover:bg-accent/70";
@@ -764,8 +765,9 @@
}
function extractMarkdownInlineCodeValues(text: string): string[] {
+ const stripped = text.replace(MARKDOWN_FENCED_CODE_BLOCK_PATTERN, "");
const values: string[] = [];
- for (const match of text.matchAll(MARKDOWN_INLINE_CODE_PATTERN)) {
+ for (const match of stripped.matchAll(MARKDOWN_INLINE_CODE_PATTERN)) {
const value = match[2]?.trim();
if (!value) continue;
values.push(value);You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 5350fea. Configure here.
| if (meta) { | ||
| metaByHref.set(normalizedHref, meta); | ||
| } | ||
| } |
There was a problem hiding this comment.
Fenced backticks pollute chip labels
Medium Severity
extractMarkdownInlineCodeValues scans the full markdown string with a backtick regex, so path-like spans inside fenced code blocks are counted even though remarkLinkInlineCodeFilePaths never turns them into links. Those phantom paths feed buildFileLinkParentSuffixByPath, which can add basename suffixes to the only real file chip when none were intended.
Reviewed by Cursor Bugbot for commit 5350fea. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature that changes how markdown inline code is rendered into interactive file chips. Additionally, there's an unresolved medium-severity bug identified where paths inside fenced code blocks may incorrectly affect file chip labels. You can customize Macroscope's approvability policy. Learn more. |
|
🚀 Expo continuous deployment is ready!
|



Summary
Testing
vp checkvp run typecheckvp run lintvp testvp run testNote
Low Risk
Scoped to chat markdown rendering and link heuristics; false positives are mitigated by stricter inline-code rules, with unit and browser tests.
Overview
Chat markdown now turns unambiguous
`path/to/file.ts:line`inline code into the same interactive file tag chips used for markdown file links, instead of plain monospace spans.A new remark pass rewrites qualifying
inlineCodenodes into links before render, and the message text is pre-scanned so chips get line/column labels and parent-path disambiguation when basenames collide. Promotion is intentionally stricter than link hrefs: values need a path separator or a:line/#Lsuffix, and obvious non-paths (e.g.1.2.3,client/server, API snippets) stay as code.Shared resolution lives in
resolveMarkdownInlineCodeFileLinkMetainmarkdown-links.ts; behavior is covered by unit tests and browser tests (chip styling, href resolution, right-panel file preview on click).Reviewed by Cursor Bugbot for commit 5350fea. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Render path-like inline code as interactive file chips in ChatMarkdown
remarkLinkInlineCodeFilePathsremark plugin in ChatMarkdown.tsx that converts inline code nodes whose text looks like a file path into link nodes during AST processing.resolveMarkdownInlineCodeFileLinkMetain markdown-links.ts to constrain resolution to unambiguous path-like values — requiring a slash/backslash or a source position suffix (e.g.:148), an alphabetic basename, and either a.in the basename or a source position.ChatMarkdownscans inline code values and pre-resolves them into itsmarkdownFileLinkMetaByHrefmap so they render with the same file-link class and click behavior as explicit markdown links.1.2.3orsink.write().Macroscope summarized 5350fea.