import { Send, Settings, Square } from 'lucide-react' import { useCallback, useEffect, useRef, useState } from 'react' import { Button } from '@/components/ui/button' import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea, } from '@/components/ui/input-group' import { useAgent } from '../../agent/useAgent' import { ConfigPanel } from './components/ConfigPanel' import { ActivityCard, EventCard } from './components/cards' import { EmptyState, Logo, StatusDot } from './components/misc' export default function App() { const [showConfig, setShowConfig] = useState(false) const [task, setTask] = useState('') const historyRef = useRef(null) const textareaRef = useRef(null) const { status, history, activity, currentTask, config, execute, stop, configure } = useAgent() // Auto-scroll to bottom on new events useEffect(() => { if (historyRef.current) { historyRef.current.scrollTop = historyRef.current.scrollHeight } }, [history, activity]) const handleSubmit = useCallback( (e?: React.FormEvent) => { e?.preventDefault() if (!task.trim() || status === 'running') return const taskToExecute = task.trim() setTask('') console.log('[SidePanel] Executing task:', taskToExecute) execute(taskToExecute).catch((error) => { console.error('[SidePanel] Failed to execute task:', error) }) }, [task, status, execute] ) const handleStop = useCallback(() => { console.log('[SidePanel] Stopping task...') stop() }, [stop]) const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() handleSubmit() } } if (showConfig) { return ( { await configure(newConfig) setShowConfig(false) }} onClose={() => setShowConfig(false)} /> ) } const isRunning = status === 'running' const showEmptyState = !currentTask && history.length === 0 && !isRunning return (
{/* Header */}
Page Agent Ext
{/* Content */}
{/* Current task */} {currentTask && (
Task
{currentTask}
)} {/* History */}
{showEmptyState && } {history.map((event, index) => ( ))} {/* Activity indicator at bottom */} {activity && }
{/* Input */}
) }