import React, { useState } from 'react'; import { Bot, LayoutDashboard, Settings, PlusCircle, Menu, X, LogOut, MessageSquare, ShoppingBag, Volume2, Box, Activity, Users, ShieldCheck } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { useAuth } from './context/useAuth'; import Login from './components/Login'; import DebateView from './components/DebateView'; import Marketplace from './components/Marketplace'; import VoiceControl from './components/VoiceControl'; import SpatialDashboard from './components/SpatialDashboard'; import MonitoringView from './components/MonitoringView'; import NewProject from './components/NewProject'; import SettingsView from './components/SettingsView'; import Dashboard from './components/Dashboard'; import ProjectDetail from './components/ProjectDetail'; import AgentsView from './components/AgentsView'; import AgentConsole from './components/AgentConsole'; import SplashScreen from './components/SplashScreen'; import TeamsView from './components/TeamsView'; import AuditView from './components/AuditView'; import { useEffect } from 'react'; import { getUiMode, saveUiMode } from './services/uiMode'; import type { UiMode } from './services/uiMode'; import { getAppVersion } from './services/runtimeConfig'; type AppTab = 'dashboard' | 'project-detail' | 'agents' | 'marketplace' | 'debate' | 'voice' | 'spatial' | 'monitoring' | 'teams' | 'audit' | 'new-project' | 'settings'; const App: React.FC = () => { const { session, loading, signOut, profile, user } = useAuth(); const appVersion = getAppVersion(); const [activeTab, setActiveTab] = useState('dashboard'); const [selectedProjectId, setSelectedProjectId] = useState(null); const [initialTaskId, setInitialTaskId] = useState(null); const [projectDetailReturnTab, setProjectDetailReturnTab] = useState('dashboard'); const [initialProjectData, setInitialProjectData] = useState(null); const [uiMode, setUiMode] = useState(() => getUiMode()); const [isSidebarOpen, setIsSidebarOpen] = useState(() => typeof window === 'undefined' || window.innerWidth >= 900); const [showSplash, setShowSplash] = useState(true); useEffect(() => { const timer = setTimeout(() => setShowSplash(false), 2500); return () => clearTimeout(timer); }, []); useEffect(() => { if (uiMode === 'expert') return; if (['agents', 'marketplace', 'debate', 'voice', 'spatial', 'monitoring'].includes(activeTab)) { setActiveTab('dashboard'); } }, [activeTab, uiMode]); const navigateTo = (tab: AppTab) => { setActiveTab(tab); if (typeof window !== 'undefined' && window.innerWidth < 900) { setIsSidebarOpen(false); } }; const openProjectDetail = (projectId: string, options?: { taskId?: string | null; returnTab?: AppTab }) => { setSelectedProjectId(projectId); setInitialTaskId(options?.taskId ?? null); setProjectDetailReturnTab(options?.returnTab ?? 'dashboard'); navigateTo('project-detail'); }; const updateUiMode = (mode: UiMode) => { setUiMode(mode); saveUiMode(mode); }; if (loading || showSplash) return ; if (!session) return ; return (
{isSidebarOpen &&
{(profile?.full_name || user?.email || 'U').slice(0, 2).toUpperCase()}
{profile?.full_name || user?.email || 'User'}
{profile?.role || 'user'}
Version {appVersion}
)} {/* Main Content */}
API Online
{uiMode === 'guided' ? 'Guided Mode' : 'Expert Mode'}
{activeTab === 'dashboard' && ( { setInitialProjectData(data || null); navigateTo('new-project'); }} onOpenProject={(projectId) => openProjectDetail(projectId)} /> )} {activeTab === 'project-detail' && selectedProjectId && ( { setInitialTaskId(null); navigateTo(projectDetailReturnTab); }} /> )} {activeTab === 'debate' && uiMode === 'expert' && } {activeTab === 'agents' && uiMode === 'expert' && } {activeTab === 'marketplace' && uiMode === 'expert' && } {activeTab === 'voice' && uiMode === 'expert' && } {activeTab === 'spatial' && uiMode === 'expert' && ( setSelectedProjectId(projectId)} onOpenTask={(projectId, taskId) => openProjectDetail(projectId, { taskId, returnTab: 'spatial' })} /> )} {activeTab === 'monitoring' && uiMode === 'expert' && } {activeTab === 'teams' && uiMode === 'expert' && } {activeTab === 'audit' && uiMode === 'expert' && } {activeTab === 'new-project' && { setInitialProjectData(null); navigateTo('dashboard'); }} />} {activeTab === 'settings' && }
{/* Real-time Agent Console */}
); }; const SidebarItem: React.FC<{ icon: React.ReactNode, label: string, active?: boolean, onClick: () => void }> = ({ icon, label, active, onClick }) => ( ); export default App;