From dae02d56dac8a349525b24e8d417c6777be86305 Mon Sep 17 00:00:00 2001
From: Miro {children}{children}
+ ),
+ ol: ({ children }) => (
+ {children}
+ ),
+ li: ({ children }) => {children}
+ ),
+ h2: ({ children }) => (
+ {children}
+ ),
+ h3: ({ children }) => (
+ {children}
+ ),
+ blockquote: ({ children }) => (
+
+ {children}
+
+ ),
+ code: ({ className, children }) => {
+ // 块级 code 带 language-* className;行内 code 没有。
+ // @streamdown/code 插件已处理语法高亮,这里只加 seal 终端主题的容器样式。
+ const isBlock = Boolean(className);
+ if (isBlock) {
+ return (
+
+ {children}
+
+ );
+ }
+ return (
+
+ {children}
+
+ );
+ },
+ pre: ({ children }) => (
+
+ {children}
+
+ ),
+ table: ({ children }) => (
+ {children}
+
+ {children}
+
+ ),
+ td: ({ children }) => (
+
+ {children}
+
+ ),
+ hr: () =>
,
+};
+
+/**
+ * 流式 Markdown 渐进渲染。
+ *
+ * 用 streamdown(Apache 2.0)替换 react-markdown:
+ * - 流式模式下逐 token 渐进渲染,而非等全文到达再一次性 parse
+ * - @streamdown/code 提供语法高亮
+ * - @streamdown/cjk 优化中日韩文字排版
+ * - 保留「印章终端」主题的组件样式覆盖
+ *
+ * @param streaming 是否为流式输出(agent 正在生成)。静态模式用于历史消息回填。
+ */
+export function ChatStreamdown({
+ children,
+ streaming = false,
+}: {
+ children: string;
+ streaming?: boolean;
+}) {
+ return (
+
+ {t("historyLoading")} +
+ ) : threads.length === 0 ? ( ++ {t("historyEmpty")} +
+ ) : ( + threads.map((th) => ( + + )) + )} + {historyError && ( ++ {sourceDownLabel} +
+ )} ++ {emptyLabel} +
+ ) : ( + visible.map((m, i) => ( +