fix(webui): stop repairing completed Markdown
This commit is contained in:
1 parent
fc3effe39d
commit
450a85fe0e
6 files changed
+48
-7
No files matched your search
@@ -25,12 +25,14 @@ const MemoizedMarkdownRenderer = memo(function MemoizedMarkdownRenderer({
|
||||
className,
|
||||
highlightCode,
|
||||
streaming,
|
||||
preserveStreamingLayout,
|
||||
onOpenFilePreview,
|
||||
}: {
|
||||
source: string;
|
||||
className?: string;
|
||||
highlightCode: boolean;
|
||||
streaming: boolean;
|
||||
preserveStreamingLayout: boolean;
|
||||
onOpenFilePreview?: (path: string) => void;
|
||||
}) {
|
||||
return (
|
||||
@@ -38,6 +40,7 @@ const MemoizedMarkdownRenderer = memo(function MemoizedMarkdownRenderer({
|
||||
className={className}
|
||||
highlightCode={highlightCode}
|
||||
streaming={streaming}
|
||||
preserveStreamingLayout={preserveStreamingLayout}
|
||||
onOpenFilePreview={onOpenFilePreview}
|
||||
>
|
||||
{source}
|
||||
@@ -81,7 +84,6 @@ export function MarkdownText({
|
||||
const renderedSource = children;
|
||||
const renderPhase = streaming ? "streaming" : "complete";
|
||||
const highlightCode = !streaming;
|
||||
const renderWithStreamingLayout = streaming || preserveStreamingLayout;
|
||||
|
||||
useEffect(() => {
|
||||
if (streaming) void preloadMarkdownText();
|
||||
@@ -106,7 +108,8 @@ export function MarkdownText({
|
||||
source={renderedSource}
|
||||
className={className}
|
||||
highlightCode={highlightCode}
|
||||
streaming={renderWithStreamingLayout}
|
||||
streaming={streaming}
|
||||
preserveStreamingLayout={preserveStreamingLayout}
|
||||
onOpenFilePreview={onOpenFilePreview}
|
||||
/>
|
||||
</Suspense>
|
||||
|
||||
@@ -12,6 +12,7 @@ import remarkBreaks from "remark-breaks";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import remarkMath from "remark-math";
|
||||
import { Streamdown, type Components, type StreamdownProps } from "streamdown";
|
||||
import remend from "remend";
|
||||
|
||||
import { AttachmentTile } from "@/components/AttachmentTile";
|
||||
import { CodeBlock } from "@/components/CodeBlock";
|
||||
@@ -42,6 +43,7 @@ interface MarkdownTextRendererProps {
|
||||
className?: string;
|
||||
highlightCode?: boolean;
|
||||
streaming?: boolean;
|
||||
preserveStreamingLayout?: boolean;
|
||||
onOpenFilePreview?: (path: string) => void;
|
||||
}
|
||||
|
||||
@@ -530,6 +532,7 @@ export default function MarkdownTextRenderer({
|
||||
className,
|
||||
highlightCode = true,
|
||||
streaming = false,
|
||||
preserveStreamingLayout = false,
|
||||
onOpenFilePreview,
|
||||
}: MarkdownTextRendererProps) {
|
||||
const { t } = useTranslation();
|
||||
@@ -826,9 +829,8 @@ export default function MarkdownTextRenderer({
|
||||
return (
|
||||
<Streamdown
|
||||
key={needsMath && mathPlugin ? "math" : "text"}
|
||||
mode={streaming ? "streaming" : "static"}
|
||||
parseIncompleteMarkdown
|
||||
remend={REMEND_OPTIONS}
|
||||
mode={streaming || preserveStreamingLayout ? "streaming" : "static"}
|
||||
parseIncompleteMarkdown={false}
|
||||
isAnimating={false}
|
||||
animated={false}
|
||||
linkSafety={DIRECT_LINKS}
|
||||
@@ -851,7 +853,8 @@ export default function MarkdownTextRenderer({
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
{/* Streamdown 2.5 ignores repair-option changes in its memo comparator. */}
|
||||
{streaming ? remend(children, REMEND_OPTIONS) : children}
|
||||
</Streamdown>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user