mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-21 05:14:45 +08:00
fix(messages): prevent URL autolink bleeding into adjacent text
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 <cursoragent@cursor.com>
This commit is contained in:
@@ -30,7 +30,7 @@ import {
|
|||||||
type UploadedFile,
|
type UploadedFile,
|
||||||
} from "@/core/messages/utils";
|
} from "@/core/messages/utils";
|
||||||
import { useRehypeSplitWordsIntoSpans } from "@/core/rehype";
|
import { useRehypeSplitWordsIntoSpans } from "@/core/rehype";
|
||||||
import { streamdownPlugins } from "@/core/streamdown";
|
import { humanMessagePlugins, streamdownPlugins } from "@/core/streamdown";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
import { CopyButton } from "../copy-button";
|
import { CopyButton } from "../copy-button";
|
||||||
@@ -222,10 +222,11 @@ function MessageContent_({
|
|||||||
}), [citationMap, thread_id, isHuman]);
|
}), [citationMap, thread_id, isHuman]);
|
||||||
|
|
||||||
// Render message response
|
// Render message response
|
||||||
|
// Human messages use humanMessagePlugins (no autolink) to prevent URL bleeding into adjacent text
|
||||||
const messageResponse = cleanContent ? (
|
const messageResponse = cleanContent ? (
|
||||||
<AIElementMessageResponse
|
<AIElementMessageResponse
|
||||||
remarkPlugins={streamdownPlugins.remarkPlugins}
|
remarkPlugins={isHuman ? humanMessagePlugins.remarkPlugins : streamdownPlugins.remarkPlugins}
|
||||||
rehypePlugins={isHuman ? streamdownPlugins.rehypePlugins : [...rehypePlugins, [rehypeKatex, { output: "html" }]]}
|
rehypePlugins={isHuman ? humanMessagePlugins.rehypePlugins : [...rehypePlugins, [rehypeKatex, { output: "html" }]]}
|
||||||
components={markdownComponents}
|
components={markdownComponents}
|
||||||
>
|
>
|
||||||
{cleanContent}
|
{cleanContent}
|
||||||
|
|||||||
@@ -12,3 +12,15 @@ export const streamdownPlugins = {
|
|||||||
[rehypeKatex, { output: "html" }],
|
[rehypeKatex, { output: "html" }],
|
||||||
] as StreamdownProps["rehypePlugins"],
|
] 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"],
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user