);
}
// ─── Segmented rendering for assistant messages ───────────────────
// If we have contentSegments, render them in order (interleaved text + tools).
// Otherwise fall back to legacy rendering (all tools then all text).
const hasSegments = !isUser && message.contentSegments && message.contentSegments.length > 0;
const toolCalls = message.toolCalls || [];
const renderSegmentedContent = () => {
if (!message.contentSegments) return null;
return message.contentSegments.map((segment: ContentSegment, i: number) => {
if (segment.type === "text") {
const text = segment.content?.trim();
if (!text) return null;
return (
{segment.content}
);
}
if (segment.type === "tool") {
const tool = toolCalls[segment.toolIndex];
if (!tool) return null;
return (
);
}
return null;
});
};
const renderLegacyContent = () => {
return (
<>
{/* Tool calls — show BEFORE message text */}
{toolCalls.length > 0 && (
{toolCalls.map((tool) => (
))}
)}
{/* Message text — after tool calls */}
{isEditing ? (