From 738b71be47ebb777542109fcb3af0c0db29caedc Mon Sep 17 00:00:00 2001 From: LofiSu Date: Fri, 6 Feb 2026 14:30:57 +0800 Subject: [PATCH] fix(messages): prevent URL autolink bleeding into adjacent text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For human messages, disable remark-gfm autolink feature to prevent URLs from incorrectly including adjacent text (especially Chinese characters) as part of the link. This ensures that when users input "https://example.com 帮我分析", only the URL becomes a link. Co-authored-by: Cursor --- .../workspace/messages/message-list-item.tsx | 7 ++++--- frontend/src/core/streamdown/plugins.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/workspace/messages/message-list-item.tsx b/frontend/src/components/workspace/messages/message-list-item.tsx index c69dc10..96049ae 100644 --- a/frontend/src/components/workspace/messages/message-list-item.tsx +++ b/frontend/src/components/workspace/messages/message-list-item.tsx @@ -30,7 +30,7 @@ import { type UploadedFile, } from "@/core/messages/utils"; import { useRehypeSplitWordsIntoSpans } from "@/core/rehype"; -import { streamdownPlugins } from "@/core/streamdown"; +import { humanMessagePlugins, streamdownPlugins } from "@/core/streamdown"; import { cn } from "@/lib/utils"; import { CopyButton } from "../copy-button"; @@ -222,10 +222,11 @@ function MessageContent_({ }), [citationMap, thread_id, isHuman]); // Render message response + // Human messages use humanMessagePlugins (no autolink) to prevent URL bleeding into adjacent text const messageResponse = cleanContent ? ( {cleanContent} diff --git a/frontend/src/core/streamdown/plugins.ts b/frontend/src/core/streamdown/plugins.ts index ce99f31..b0d9824 100644 --- a/frontend/src/core/streamdown/plugins.ts +++ b/frontend/src/core/streamdown/plugins.ts @@ -12,3 +12,15 @@ export const streamdownPlugins = { [rehypeKatex, { output: "html" }], ] as StreamdownProps["rehypePlugins"], }; + +// Plugins for human messages - no autolink to prevent URL bleeding into adjacent text +export const humanMessagePlugins = { + remarkPlugins: [ + // Use remark-gfm without autolink literals by not including it + // Only include math support for human messages + [remarkMath, { singleDollarTextMath: true }], + ] as StreamdownProps["remarkPlugins"], + rehypePlugins: [ + [rehypeKatex, { output: "html" }], + ] as StreamdownProps["rehypePlugins"], +};