import { useCallback, useMemo } from 'react' import { Zap, Cpu, Activity } from 'lucide-react' import { ChatContainer } from './components/Chat/ChatContainer' import { TopicList } from './components/Sidebar/TopicList' import { ToolPanel } from './components/Panel/ToolPanel' import { ConnectionStatus } from './components/ConnectionStatus' import { useWebSocket } from './hooks/useWebSocket' import { useChat } from './hooks/useChat' import type { Command } from './types/protocol' const WS_URL = 'ws://127.0.0.1:19876/ws' function App() { const { messages, currentSessionId, currentTopicId, topics, isLoading, handleMessage, handleCommand, handleServerMessage, } = useChat() const { status, sendMessage } = useWebSocket({ url: WS_URL, onMessage: handleServerMessage, }) const handleSendMessage = useCallback( (content: string) => { if (content.startsWith('/')) { const parts = content.slice(1).split(' ') const command = parts[0] const args = parts.slice(1) let cmd: Command switch (command) { case 'new': cmd = { type: 'create_session', title: args.join(' ') || undefined } break case 'list': cmd = { type: 'list_sessions', include_archived: args[0] === 'all' } break case 'use': if (args[0]) { cmd = { type: 'switch_session', session_id: args[0] } } else { alert('Usage: /use ') return } break case 'save': cmd = { type: 'save_topic', filepath: args[0] || undefined, include_subagents: false } break default: alert(`Unknown command: /${command}`) return } handleCommand(cmd) sendMessage({ type: 'command', payload: JSON.stringify(cmd) }) } else { handleMessage(content) sendMessage({ type: 'message', content, chat_id: currentTopicId ?? undefined, }) } }, [sendMessage, handleMessage, handleCommand, currentTopicId] ) const handleCreateTopic = useCallback(() => { const title = prompt('Enter topic title:') if (title) { const cmd: Command = { type: 'create_session', title } handleCommand(cmd) sendMessage({ type: 'command', payload: JSON.stringify(cmd) }) } }, [sendMessage, handleCommand]) const handleSwitchTopic = useCallback( (topicId: string) => { const cmd: Command = { type: 'switch_session', session_id: topicId } handleCommand(cmd) sendMessage({ type: 'command', payload: JSON.stringify(cmd) }) }, [sendMessage, handleCommand] ) const toolMessages = useMemo(() => messages, [messages]) return (
{/* Header */}

Pico Bot

AI Ready
{currentSessionId && (
{currentSessionId.slice(0, 8)}...
)}
{/* Main Content */}
{/* Left Sidebar - Topic List */}
{/* Center - Chat */}
{/* Right Sidebar - Tool Panel */}
) } export default App