{(() => {
let detectedTag: string | null = null;
let tagStartIndex = -1;
if (streamingTextContent) {
for (const tag of HIDE_STREAMING_XML_TAGS) {
const openingTagPattern = `<${tag}`;
const index = streamingTextContent.indexOf(openingTagPattern);
if (index !== -1) {
detectedTag = tag;
tagStartIndex = index;
break;
}
}
}
const textToRender = streamingTextContent || '';
const textBeforeTag = detectedTag ? textToRender.substring(0, tagStartIndex) : textToRender;
const showCursor = (streamHookStatus === 'streaming' || streamHookStatus === 'connecting') && !detectedTag;
return (
<>
{textBeforeTag && (
{textBeforeTag}
)}
{showCursor && (
)}
{detectedTag && (
{detectedTag}
)}
{streamingToolCall && !detectedTag && (
{(() => {
// Import dynamically to avoid circular dependencies
const { getToolIcon, extractPrimaryParam } = require('@/components/thread/utils');
const toolName = streamingToolCall.name || streamingToolCall.xml_tag_name || 'Tool';
const IconComponent = getToolIcon(toolName);
const paramDisplay = extractPrimaryParam(toolName, streamingToolCall.arguments || '');
return (
{toolName}
{paramDisplay && {paramDisplay} }
);
})()}
)}
>
);
})()}
)}
{/* For playback mode, show streaming text and tool calls */}
{readOnly && groupIndex === groupedMessages.length - 1 && isStreamingText && (
{(() => {
let detectedTag: string | null = null;
let tagStartIndex = -1;
if (streamingText) {
for (const tag of HIDE_STREAMING_XML_TAGS) {
const openingTagPattern = `<${tag}`;
const index = streamingText.indexOf(openingTagPattern);
if (index !== -1) {
detectedTag = tag;
tagStartIndex = index;
break;
}
}
}
const textToRender = streamingText || '';
const textBeforeTag = detectedTag ? textToRender.substring(0, tagStartIndex) : textToRender;
const showCursor = isStreamingText && !detectedTag;
return (
<>
{textBeforeTag && (
{textBeforeTag}
)}
{showCursor && (
)}
{detectedTag && (
{detectedTag}
)}
>
);
})()}
)}