Improve markdown file link UX #1956
main fromrefs/pull/1956/head·merged by juliusmarminge View on GitHubWhat Changed#
This tightens the UX for markdown-rendered local file links and keeps file-path presentation more consistent across assistant surfaces.
- Render local markdown file links as dedicated inline file chips instead of plain links
- Add file icons, hover tooltip paths, right-click actions, and line/column labels when present
- Disambiguate duplicate basenames inline within the same markdown message
- Format displayed file paths from the workspace/repo root instead of absolute machine paths where possible
- Reuse that repo-relative formatting in timeline changed-file previews/badges
- Split markdown chip styling away from composer chips and restyle it to match markdown inline code more closely
- Memoize markdown file chips so identical links do less work during streaming
- Stabilize the touched timeline test under full-suite load
Why#
Assistant messages were hard to scan when they referenced the same filename multiple times, especially when the visible markdown text was just menu.tsx or MessagesTimeline.tsx repeatedly. The useful context existed in the href, but the UI was not surfacing it well.
This approach keeps the change small and local to existing rendering paths:
- improves readability without changing message semantics
- keeps normal web links untouched
- preserves editor-open behavior
- avoids duplicating path-formatting logic by extracting a shared formatter
- makes markdown file refs feel like part of prose rather than composer UI
UI Changes#
Before:
- local file refs looked like normal links
- repeated basenames were hard to distinguish
- tooltips showed machine-absolute paths
- markdown file refs visually felt disconnected from nearby inline code
After:
- local file refs render as inline file chips
- duplicate basenames gain inline suffix disambiguation when needed
- tooltips show workspace-relative paths
- chip styling now sits closer to markdown inline code
Screenshots:
CHIPS
CONTEXT MENU
HOVER TOOLTIP
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Note
Improve file link rendering in chat markdown with icon, line/column, and context menu#
- File links in chat markdown now render as styled inline elements with a VSCode icon, a label that includes line/column info (e.g.
filename · L1:C7), and parent path segments to disambiguate duplicate basenames. - Clicking a file link opens it in the preferred editor at the specified line/column; a context menu offers options to copy the relative or full path, with toast feedback.
- Adds
resolveMarkdownFileLinkMetain markdown-links.ts andformatWorkspaceRelativePathin filePathDisplay.ts to support structured metadata and workspace-relative display paths. - File paths in
MessagesTimelinework entry rows and previews are now formatted relative to the workspace root. - Non-file HTTP(S) links continue to open in a new tab unchanged.
Note
Medium Risk Mostly UI/UX changes, but it touches link handling and editor-opening/context-menu behavior; mistakes could break navigation or open/copy actions for file links across chat surfaces.
Overview Improves local markdown file-link UX by replacing plain anchors with memoized inline file chips that show VS Code-style icons, tooltips, and context-menu actions (open in editor, copy relative/full path), while keeping normal external links unchanged.
Adds resolveMarkdownFileLinkMeta + formatWorkspaceRelativePath to compute workspace-relative display paths and parse line/column info, uses that metadata to label links as basename · parentSuffix · Lx(:Cy) (disambiguating duplicate basenames), and reuses the same path formatting for MessagesTimeline changed-file previews/badges.
Updates CSS for the new chip styling and expands/adjusts tests to cover line/column labels, basename disambiguation, web-link passthrough, and timeline path formatting.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b85c8018f4514d1e1d29db9ea7b0284759e892e5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
Approvability#
Verdict: Needs human review
Introduces a new interactive file link UX with styled chips, tooltips, context menus, and path disambiguation logic. While self-contained to the UI layer with good test coverage, the volume of new user-facing behavior (~800 lines of new components and utilities) represents a meaningful new feature that benefits from human review.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b85c8018f4514d1e1d29db9ea7b0284759e892e5. Configure [here](https://www.cursor.com/dashboard/bugbot).
@@ -143,3 +153,8 @@143153 if (!cwd) return null;144154 return resolvePathLinkTarget(pathWithPosition, cwd);145155 }156+157+function basenameOfPath(path: string): string {158+ const separatorIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));159+ return separatorIndex >= 0 ? path.slice(separatorIndex + 1) : path;160+}Duplicate
basenameOfPathin two new files#Low Severity
Two identical private
basenameOfPathfunctions are introduced inmarkdown-links.tsandfilePathDisplay.ts. Both compute the basename by finding the last/or\\separator. A single shared utility (or reuse/extension of the existingbasenameOfPathexport invscode-icons.ts) would avoid the duplication.Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b85c8018f4514d1e1d29db9ea7b0284759e892e5. Configure [here](https://www.cursor.com/dashboard/bugbot).Additional Locations (1)
juliusmarminge merged this68061af
juliusmarminge closed this
Sign in to join this conversation.

Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
614b202f-11f3-4883-b5ad-d5e2e9f986b5You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share