import React, { useState, useRef, useEffect } from 'react' export default function ChatPanel({ nodes, messages, onSendMessage, onClose }) { const [input, setInput] = useState('') const [selectedNode, setSelectedNode] = useState(null) const messagesEndRef = useRef(null) const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }) } useEffect(() => { scrollToBottom() }, [messages]) const handleSend = () => { if (!input.trim() || !selectedNode) return onSendMessage(input, selectedNode) setInput('') } const ceoNode = nodes.find(n => n.type === 'ceo') return (
Communicate with your agents
Select an agent and start chatting
{ceoNode && (Tip: Use CEO to coordinate between agents
)}{msg.senderName}
)}{msg.content}
{new Date(msg.timestamp).toLocaleTimeString()}