import { Link, useMatchRoute } from "@tanstack/react-router"; import { AnimatePresence, motion } from "framer-motion"; import { Boxes, Check, ChevronRight, ChevronsUpDown, Eye, EyeOff, LayoutDashboard, Lightbulb, MessageSquare, Moon, Settings, Sun, Users, Webhook, } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { HealthDot } from "@/components/shared/HealthDot"; import { useDemo } from "@/hooks/useDemo"; import { useHealthStatus } from "@/hooks/useHealthStatus"; import { useInstances } from "@/hooks/useInstances"; import { useTheme } from "@/hooks/useTheme"; import { COLOR } from "@/lib/constants"; const TOP_NAV = [ { to: "/" as const, label: "Dashboard", icon: LayoutDashboard, exact: true }, { to: "/workspaces" as const, label: "Workspaces", icon: Boxes, exact: false }, { to: "/settings" as const, label: "Settings", icon: Settings, exact: false }, ]; const WORKSPACE_SECTIONS = [ { label: "Peers", icon: Users, section: "peers" }, { label: "Sessions", icon: MessageSquare, section: "sessions" }, { label: "Conclusions", icon: Lightbulb, section: "conclusions" }, { label: "Webhooks", icon: Webhook, section: "webhooks" }, ] as const; export function Sidebar() { const matchRoute = useMatchRoute(); const { instances, active, activate } = useInstances(); const { theme, toggle } = useTheme(); const { demo, toggle: toggleDemo, mask } = useDemo(); const { data: health } = useHealthStatus(); const [switcherOpen, setSwitcherOpen] = useState(false); const switcherRef = useRef(null); useEffect(() => { if (!switcherOpen) return; function onClick(e: MouseEvent) { if (!switcherRef.current?.contains(e.target as Node)) { setSwitcherOpen(false); } } window.addEventListener("mousedown", onClick); return () => window.removeEventListener("mousedown", onClick); }, [switcherOpen]); // Detect workspace context — matchRoute returns params or false const wsMatch = matchRoute({ to: "/workspaces/$workspaceId" as never, fuzzy: true, }) as { workspaceId: string } | false; const activeWorkspaceId = wsMatch ? wsMatch.workspaceId : null; return ( {/* Logo */}
OpenConcho
OpenConcho
{active && (
{switcherOpen && instances.length > 1 && (
{instances.map((inst) => ( ))}
)}
)}
{/* Nav */} {/* Theme toggle + footer */}

v{__APP_VERSION__}

); }