'use client'; import React from 'react'; import { Bot } from 'lucide-react'; import type { ControlCenterMessage } from '@/types/control-center'; import { cn } from '@/lib/utils'; import { ToolCallCard } from './ToolCallCard'; import { ToolResultCard } from './ToolResultCard'; interface AIMessageBubbleProps { message: ControlCenterMessage; isStreaming?: boolean; } export const AIMessageBubble: React.FC = ({ message, isStreaming = false, }) => { const hasToolCalls = message.toolCalls && message.toolCalls.length > 0; const hasToolResults = message.toolResults && message.toolResults.length > 0; const hasContent = message.content && message.content.trim().length > 0; return (
{/* AI Avatar */}
{/* Message Content */}
{/* Text Content Bubble */} {(hasContent || isStreaming) && (
{/* Message Text */}
{message.content} {isStreaming && ( | )}
{/* Streaming "Thinking" Animation */} {isStreaming && !hasContent && (
Thinking...
)}
)} {/* Tool Calls */} {hasToolCalls && (
{message.toolCalls!.map((toolCall) => ( ))}
)} {/* Tool Results */} {hasToolResults && (
{message.toolResults!.map((toolResult) => ( ))}
)} {/* Timestamp */}
{new Date(message.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', })}
); }; export default AIMessageBubble;