import * as React from "react"; const { forwardRef, useEffect, useImperativeHandle, useRef, useState } = React; export interface ChatInputHandle { appendToInput(text: string): void; } interface ChatInputProps { loading: boolean; queuedMessages: { id: string; text: string }[]; onSubmit: (message: string) => void; onCancel: () => void; onRemoveQueuedMessage: (id: string) => void; } export const ChatInput = forwardRef( function ChatInput( { loading, queuedMessages, onSubmit, onCancel, onRemoveQueuedMessage }, ref, ) { const [input, setInput] = useState(""); const inputRef = useRef(null); useImperativeHandle(ref, () => ({ appendToInput(text: string) { setInput((prev) => (prev ? `${prev}\n${text}` : text)); }, })); useEffect(() => { inputRef.current?.focus(); }, []); const handleSubmit = () => { if (!input.trim()) return; onSubmit(input); setInput(""); }; return (
{/* Queued message indicators */} {queuedMessages.map(({ id, text }) => (
Queued {text}
))} {/* Input row */}