mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-13 08:18:57 +00:00
* fix(frontend): improve chat math rendering * fix(frontend): refine math rendering stability * fix(frontend): address review feedback on math preprocessing - Fix escaped-backslash blind spot: consume \\\\ as a unit so \\( and \\[ are not mis-interpreted as math delimiters when the backslash itself is escaped. - Thread inInlineCode state across lines so multi-line backtick code spans are protected from delimiter conversion. - Remove double math normalization: preprocessStreamdownMarkdown now only handles Mermaid; math normalization lives solely in ClipboardSafeStreamdown, preventing non-idempotent double passes. - Wire parseIncompleteMarkdown to isLoading in MarkdownContent so Streamdown's streaming-incomplete-math handling is actually active during streaming. * fix(frontend): address streamdown math review issues * refactor(frontend): move streamdown preprocessing out of ai elements
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
MessageResponse,
|
|
type MessageResponseProps,
|
|
} from "@/components/ai-elements/message";
|
|
import {
|
|
ReasoningContent,
|
|
type ReasoningContentProps,
|
|
} from "@/components/ai-elements/reasoning";
|
|
import {
|
|
ClipboardSafeStreamdown,
|
|
type ClipboardSafeStreamdownProps,
|
|
} from "@/components/ai-elements/streamdown";
|
|
|
|
import {
|
|
useSafeStreamdownChildren,
|
|
useSafeStreamdownMarkdown,
|
|
} from "./safe-children";
|
|
|
|
export function SafeStreamdown({
|
|
children,
|
|
...props
|
|
}: ClipboardSafeStreamdownProps) {
|
|
const safeChildren = useSafeStreamdownChildren(children);
|
|
|
|
return (
|
|
<ClipboardSafeStreamdown {...props}>{safeChildren}</ClipboardSafeStreamdown>
|
|
);
|
|
}
|
|
|
|
export function SafeMessageResponse({
|
|
children,
|
|
...props
|
|
}: MessageResponseProps) {
|
|
const safeChildren = useSafeStreamdownChildren(children);
|
|
|
|
return <MessageResponse {...props}>{safeChildren}</MessageResponse>;
|
|
}
|
|
|
|
export function SafeReasoningContent({
|
|
children,
|
|
...props
|
|
}: ReasoningContentProps) {
|
|
const safeChildren = useSafeStreamdownMarkdown(children);
|
|
|
|
return <ReasoningContent {...props}>{safeChildren}</ReasoningContent>;
|
|
}
|