import type { AgentInputItem } from '@openai/agents'; import { History } from '@/components/History'; import { Button } from '@/components/ui/Button'; import { useState, useRef, useEffect } from 'react'; import ArrowUpIcon from './icons/ArrowUpIcon'; export type AppProps = { title?: string; history?: AgentInputItem[]; onSend: (message: string) => void; }; export function App({ title = 'Agent Demo', history, onSend }: AppProps) { const [message, setMessage] = useState(''); const [isLoading, setIsLoading] = useState(false); const inputRef = useRef(null); useEffect(() => { if (!isLoading) { inputRef.current?.focus(); } }, [isLoading]); const handleSend = async () => { if (!message.trim()) return; setIsLoading(true); const msg = message; setMessage(''); await onSend(msg); setIsLoading(false); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!message.trim()) return; await handleSend(); }; return (

{title}

{history && history.length > 0 ? ( ) : (
No history available
)}
setMessage(e.target.value)} disabled={isLoading} ref={inputRef} />
); }