Skip to content

Stop linking bare filenames in chat answers - #1144

Closed
koutst wants to merge 1 commit into
mainfrom
claude/chat-filename-links
Closed

koutst wants to merge 1 commit into
mainfrom
claude/chat-filename-links

Conversation

@koutst

@koutst koutst commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

An assistant answer that names a file, such as notes.md, rendered the name as a link to http://notes.md. This stops bare filenames being linked in chat answers.

  • Cause: the chat renderer (components/AgentChat/MarkdownMessage.tsx) runs markdown-it with linkify: true. Its matcher, linkify-it, links any schemeless name.tld whose last part is a known top-level domain, and that list includes every two-letter country code. .md, .py, .sh, .rs, .cc, .pl and .so are all country codes, and .org, .pro and .info are generic ones, so notes.md, analysis.py, run.sh, main.rs, todo.org all became links. Extensions that are not domains (.csv, .pdf, .ts, .json) were never affected.
  • Fix: schemeless text is now linked only when it starts with www.. The matcher's results are filtered: a match with no scheme is dropped unless it begins with www.. Everything else linkify-it finds is kept as it was.

Still linked: anything with a scheme (https://example.com/notes.md, http://example.org), www.example.com, explicit markdown links, <https://…> autolinks, and email addresses.

No longer linked: bare filenames, and also bare domains written without a scheme or www. (example.com, claude.ai, researchhub.com/paper/1). The two cannot be told apart from the text alone, since todo.org and nature.org have the same shape.

Notes

  • Scope: MarkdownMessage is the only user of markdown-it in the app. It renders assistant answers, and the narration, thinking and tool-draft text in the activity feed, in both the notebook's assistant panel and the assistant chat. Nothing outside the agent chat uses it: user messages in the chat are plain text, the editor has its own link handling, and DraftBlockPreview shares only the sanitizer options.
  • The filter replaces md.linkify.match on this file's own markdown-it instance, which is the call markdown-it's linkify rule makes for running text. Matches that carry a scheme, including mailto: and //, pass through it unchanged.
  • No dependency added.

Test plan

  • npm run type-check
  • npm run lint (0 errors; the 2 warnings are on main in files this PR does not touch)
  • prettier --check on the changed file
  • npm run build
  • In headless Chrome against a local stub, an assistant answer with these cases rendered as expected: notes.md, analysis.py, run.sh, main.rs, lib.cc, todo.org, project.pro and the bare domains example.com, claude.ai, researchhub.com/paper/1 are plain text; https://example.com/notes.md, http://example.org, www.example.com, www.site.de/path, [the docs](https://example.com/docs/readme.md), <https://example.md> and someone@example.com are links that open in a new tab. The same answer on the unfixed renderer linked all seventeen
  • The same filter in node over further cases: filenames in bold, in lists, in table cells, in parentheses and at the end of a sentence; WWW. in capitals; a www. link followed by a full stop; a paragraph mixing filenames and real links
  • CI: SonarCloud and Vercel pass. smoke fails on one test, auth.spec.ts:68 (register a new account), which fails the same way on other open PRs
  • A real assistant answer on a live backend. Not tried

@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
web Ready Ready Preview Oct 6, 2026 5:47pm UTC

Request Review

@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@koutst

koutst commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

Folded into #1143: the fix is now a commit on that branch.

@koutst koutst closed this Oct 6, 2026

This branch was successfully deployed

1 active deployment
Preview — dee887ed Deployed Oct 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant