import { useEffect, useRef, useState } from 'react'; import { ArrowUp, Play, RefreshCw, Square } from './Icons'; import type { Task } from '../types'; export function Composer({ task, busy, onSend, onResume, onTrackNow, onTrackStop }: { task: Task | null; busy: boolean; onSend: (text: string) => void; onResume: () => void; onTrackNow: () => void; onTrackStop: () => void; }) { const [text, setText] = useState(''); const composing = useRef(false); const area = useRef(null); useEffect(() => { const element = area.current; if (!element) return; element.style.height = 'auto'; element.style.height = `${Math.min(200, Math.max(48, element.scrollHeight))}px`; }, [text]); const submit = (): void => { const value = text.trim(); if (!value || busy) return; setText(''); onSend(value); }; const running = task?.status === 'running'; const placeholder = task?.status === 'paused' ? '在这里回答助手的问题…' : task?.status === 'collecting' ? '补充助手需要的资料…' : '例如:帮我填今天的查课日志,班级计科2301班,听课记录还好'; return (