// Agent panel — chat is the write-path function ChatPanel({ onOpenDirectives, offline }) { const DS = window.CommiTeaDesignSystem_20e63b; const { Icon, IconButton } = DS; const d = window.CT_DATA; const [msgs, setMsgs] = React.useState(d.chat); const [text, setText] = React.useState(''); const [thinking, setThinking] = React.useState(false); const scrollRef = React.useRef(null); React.useEffect(() => { const el = scrollRef.current; if (el) el.scrollTop = el.scrollHeight; }, [msgs, thinking]); const send = () => { const t = text.trim(); if (!t) return; setMsgs((m) => [...m, { from: 'user', text: t }]); setText(''); setThinking(true); setTimeout(() => { setThinking(false); setMsgs((m) => [...m, { from: 'agent', text: d.cannedReply }]); }, 900); }; return ( ); } Object.assign(window, { ChatPanel });