perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
@@ -20,6 +20,21 @@ interface MarkdownContentProps {
|
||||
}
|
||||
|
||||
export const MarkdownContent = memo(function MarkdownContent({ content, className }: MarkdownContentProps) {
|
||||
// Strip <think>...</think> and <thinking>...</thinking> blocks produced by reasoning models
|
||||
// (MiniMax, DeepSeek R1, etc.) before passing to ReactMarkdown — rehypeRaw would otherwise
|
||||
// try to render them as HTML elements causing React warnings.
|
||||
// Also handles partial/unclosed blocks during streaming (e.g. <think> without </think> yet).
|
||||
const safeContent = useMemo(
|
||||
() => content
|
||||
.replace(/<think>[\s\S]*?<\/think>/gi, '') // complete think blocks
|
||||
.replace(/<think>[\s\S]*/i, '') // unclosed think block (still streaming)
|
||||
.replace(/<thinking>[\s\S]*?<\/thinking>/gi, '') // complete thinking blocks
|
||||
.replace(/<thinking>[\s\S]*/i, '') // unclosed thinking block
|
||||
.trim(),
|
||||
[content]
|
||||
)
|
||||
|
||||
|
||||
return (
|
||||
<div dir="auto" className={`prose prose-sm prose-compact dark:prose-invert max-w-none break-words ${className}`}>
|
||||
<ReactMarkdown
|
||||
@@ -56,8 +71,9 @@ export const MarkdownContent = memo(function MarkdownContent({ content, classNam
|
||||
},
|
||||
}}
|
||||
>
|
||||
{content}
|
||||
{safeContent}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user