import { useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { useCoreState } from '../providers/CoreStateProvider'; import { useAppSelector } from '../store/hooks'; import { isTauri } from '../utils/tauriCommands'; import DaemonHealthIndicator from './daemon/DaemonHealthIndicator'; import DaemonHealthPanel from './daemon/DaemonHealthPanel'; const navItems = [ { id: 'home', label: 'Home', path: '/home', icon: ( ), }, { id: 'skills', label: 'Skills', path: '/skills', icon: ( ), }, { id: 'conversations', label: 'Conversations', path: '/conversations', icon: ( ), }, { id: 'intelligence', label: 'Intelligence', path: '/intelligence', icon: ( ), }, // { // id: 'invites', // label: 'Invite Friends', // path: '/invites', // icon: ( // // ), // }, { id: 'settings', label: 'Settings', path: '/settings', icon: ( ), }, { id: 'channels', label: 'Channels', path: '/channels', icon: ( ), }, { id: 'cron-jobs', label: 'Cron Jobs', path: '/settings/cron-jobs', icon: ( ), }, ]; const MiniSidebar = () => { const location = useLocation(); const navigate = useNavigate(); const { snapshot } = useCoreState(); const token = snapshot.sessionToken; const [showDaemonPanel, setShowDaemonPanel] = useState(false); // Unread count for Conversations: threads with lastMessageAt > lastViewedAt (must be before early return) const conversationsUnreadCount = useAppSelector(state => { const { threads, lastViewedAt } = state.thread; if (threads.length === 0) return 0; return threads.filter(t => { const viewed = lastViewedAt[t.id]; const lastMsg = new Date(t.lastMessageAt || t.createdAt).getTime(); return viewed == null || lastMsg > viewed; }).length; }); // Hide sidebar on public/setup routes and when not authenticated. const hiddenPaths = ['/', '/login']; if ( !token || hiddenPaths.some(path => location.pathname === path || location.pathname.startsWith(`${path}/`)) ) { return null; } const isActive = (path: string) => { if (path === '/settings') { return ( location.pathname === '/settings' || (location.pathname.startsWith('/settings/') && !location.pathname.startsWith('/settings/cron-jobs')) ); } if (path === '/channels') return location.pathname.startsWith('/channels'); if (path === '/settings/cron-jobs') return location.pathname.startsWith('/settings/cron-jobs'); if (path === '/conversations') return location.pathname.startsWith('/conversations'); return location.pathname === path; }; return ( <>