2026-08-25 18:16:49 +03:00
|
|
|
import { commitStreamedText } from '../../lib/streamTextCommit';
|
|
|
|
|
|
2026-03-12 23:45:45 +02:00
|
|
|
export const resolveAssistantDisplayText = (input: {
|
|
|
|
|
textContent: string;
|
|
|
|
|
throttledTextContent: string;
|
|
|
|
|
isStreaming: boolean;
|
|
|
|
|
}): string => {
|
2026-08-25 18:16:49 +03:00
|
|
|
// While streaming, reveal whole blocks only: rendering stops at the last
|
|
|
|
|
// complete line so a shown paragraph never mutates in place. The held
|
|
|
|
|
// tail lands with the next line break (or the finalize pass).
|
|
|
|
|
return input.isStreaming
|
|
|
|
|
? commitStreamedText(input.throttledTextContent)
|
|
|
|
|
: input.textContent;
|
2026-03-12 23:45:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const shouldRenderAssistantText = (input: {
|
|
|
|
|
displayTextContent: string;
|
|
|
|
|
isFinalized: boolean;
|
|
|
|
|
}): boolean => {
|
|
|
|
|
if (!input.isFinalized && input.displayTextContent.trim().length === 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return input.displayTextContent.trim().length > 0;
|
|
|
|
|
};
|