Skip to content

Render path-like inline code as file chips#3134

Open
juliusmarminge wants to merge 1 commit into
mainfrom
t3code/markdown-file-chips
Open

Render path-like inline code as file chips#3134
juliusmarminge wants to merge 1 commit into
mainfrom
t3code/markdown-file-chips

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Promote unambiguous inline code references to interactive file chips in chat markdown.
  • Add shared resolution logic for inline-code file paths, including line/column suffix handling and basename disambiguation.
  • Cover the new behavior with unit tests for link resolution and browser-level rendering.

Testing

  • vp check
  • vp run typecheck
  • vp run lint
  • vp test
  • vp run test
  • Not run: native mobile lint (no mobile code changed)

Note

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 inlineCode nodes 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 / #L suffix, and obvious non-paths (e.g. 1.2.3, client/server, API snippets) stay as code.

Shared resolution lives in resolveMarkdownInlineCodeFileLinkMeta in markdown-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

  • Adds a remarkLinkInlineCodeFilePaths remark plugin in ChatMarkdown.tsx that converts inline code nodes whose text looks like a file path into link nodes during AST processing.
  • Adds resolveMarkdownInlineCodeFileLinkMeta in 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.
  • ChatMarkdown scans inline code values and pre-resolves them into its markdownFileLinkMetaByHref map so they render with the same file-link class and click behavior as explicit markdown links.
  • Bare filenames without a path separator are only linkified when accompanied by a line/column suffix, preventing false positives on values like 1.2.3 or sink.write().

Macroscope summarized 5350fea.

- Promote unambiguous inline code paths to clickable file chips
- Add resolution tests for line-suffixed paths and disambiguation
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b912b659-5f9c-4db6-b6fa-9caef1fdffd6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/markdown-file-chips

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 17, 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 and found 1 potential issue.

Fix All in Cursor

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.

Create PR

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);
}
}

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.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5350fea. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint 052dc86843f08d733f88b4c444db61397f6e5117 56f0ff9f61b9906d203c2fea265e3f9507332117
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 052dc86843f08d733f88b4c444db61397f6e5117
App version: 0.1.0
Git commit: 3f05d7d9d43c5a13768408e8ba79cd9ee093ce95
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 56f0ff9f61b9906d203c2fea265e3f9507332117
App version: 0.1.0
Git commit: 3f05d7d9d43c5a13768408e8ba79cd9ee093ce95
Update Details Update Permalink
DetailsBranch: pr-3134
Runtime version: 052dc86843f08d733f88b4c444db61397f6e5117
Git commit: 3f05d7d9d43c5a13768408e8ba79cd9ee093ce95
Update Permalink
DetailsBranch: pr-3134
Runtime version: 56f0ff9f61b9906d203c2fea265e3f9507332117
Git commit: 3f05d7d9d43c5a13768408e8ba79cd9ee093ce95
Update QR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant