Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix: reconcile streamed code block children in the native renderer

Steven Enamakel93641b6a78f1
diff --git a/app/src/components/assistant-ui/markdown-text.tsx b/app/src/components/assistant-ui/markdown-text.tsx
index d8d651beff..761b1613a1 100644
--- a/app/src/components/assistant-ui/markdown-text.tsx
+++ b/app/src/components/assistant-ui/markdown-text.tsx
@@ -240,7 +240,7 @@ const CodeBlockPre: FC<ComponentPropsWithoutRef<'pre'>> = ({ className, children
);
};
-const defaultComponents = memoizeMarkdownComponents({
+const memoizedComponents = memoizeMarkdownComponents({
h1: ({ className, ...props }) => (
<h1
className={cn(
@@ -383,7 +383,6 @@ const defaultComponents = memoizeMarkdownComponents({
sup: ({ className, ...props }) => (
<sup className={cn('aui-md-sup [&>a]:text-xs [&>a]:no-underline', className)} {...props} />
),
- pre: CodeBlockPre,
code: function Code({ className, ...props }) {
const isCodeBlock = useIsMarkdownCodeBlock();
return (
@@ -398,3 +397,8 @@ const defaultComponents = memoizeMarkdownComponents({
);
},
});
+
+// The kit forwards pre props through an effect-updated callback, so its
+// hast node can lag behind the current code children. Comparing only that
+// node can freeze a streamed block; reconcile the wrapper's children normally.
+const defaultComponents = { ...memoizedComponents, pre: CodeBlockPre };