From dee887ed50a686cf43166af5f55dce710488284e Mon Sep 17 00:00:00 2001 From: Taki Koutsomitis Date: Tue, 6 Oct 2026 13:45:55 -0400 Subject: [PATCH] Stop linking bare filenames in chat answers --- components/AgentChat/MarkdownMessage.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/AgentChat/MarkdownMessage.tsx b/components/AgentChat/MarkdownMessage.tsx index e7020e4ad..5fbcfd314 100644 --- a/components/AgentChat/MarkdownMessage.tsx +++ b/components/AgentChat/MarkdownMessage.tsx @@ -14,6 +14,12 @@ const md = new MarkdownIt({ breaks: true, }); +// Schemeless text links only behind "www.": linkify-it links any name.tld, and +// file extensions such as .md, .py, .sh and .rs are country-code domains. +const matchLinks = md.linkify.match.bind(md.linkify); +md.linkify.match = (text) => + matchLinks(text)?.filter((link) => link.schema !== '' || /^www\./i.test(link.raw)) ?? null; + export const ASSISTANT_HTML_SANITIZE_OPTIONS: sanitizeHtml.IOptions = { allowedTags: [ 'p',