Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { useResolvedTheme } from '../../theme-provider';
import type { ConversationFontSize } from '@/atoms/settings';
import { useTaskImageUrl } from '@/hooks/use-task-image';
import { MarkdownDiffBlock } from './markdown-diff-block';
import { resolveMarkdownStreamdownMode } from './markdown-streamdown-mode';
import { createMarkdownMermaidConfig, createMarkdownMermaidPlugin } from './markdown-mermaid';
import { MermaidDiagramViewer, type MermaidDiagramSelection } from './mermaid-diagram-viewer';

Expand Down Expand Up @@ -1409,7 +1410,7 @@ export const MarkdownRenderer = memo(function MarkdownRenderer({
// remount when raw-HTML mode or Mermaid theme changes so sanitized
// rendering and diagram colors update correctly.
key={streamdownKey}
mode="streaming"
mode={resolveMarkdownStreamdownMode(isStreaming)}
Comment thread
slashdevcorpse marked this conversation as resolved.
Outdated
className="space-y-0"
controls={STREAMDOWN_CONTROLS}
isAnimating={isStreaming}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function resolveMarkdownStreamdownMode(isStreaming: boolean): 'static' | 'streaming' {
return isStreaming ? 'streaming' : 'static';
}
13 changes: 13 additions & 0 deletions packages/components/tests/markdown-streamdown-mode.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest';

import { resolveMarkdownStreamdownMode } from '../src/components/ai-gui/markdown-streamdown-mode';

describe('resolveMarkdownStreamdownMode', () => {
it('uses static mode for finished markdown', () => {
expect(resolveMarkdownStreamdownMode(false)).toBe('static');
});

it('uses streaming mode while a turn is still growing', () => {
expect(resolveMarkdownStreamdownMode(true)).toBe('streaming');
});
});
Loading