import type { ElementType } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { ChevronDown, Plus, Search } from "lucide-react"; import { cmdKLabel } from "@/lib/platform"; import { HintTooltip } from "@/components/ui/hint-tooltip"; import { TooltipProvider } from "@/components/ui/tooltip"; /** * Warm-Hive calm spine (design ref: design-files/screens/ia.html). * * The always-visible nav collapses to FIVE everyday places (Home · Chat · Memory · * Agents & tasks · Library); everything else lives one keystroke away in ⌘K. A * power-tier "Pinned · power tools" group floats the tools a power user lives in. * Purely presentational — AppShell resolves routes/badges/tier and passes them in, * so the spine is trivial to unit-test. */ export interface SidebarNavItem { key: string; label: string; icon: ElementType; /** Resolved navigation target. */ to: string; /** Route prefixes that mark this item active (exact or `${prefix}/…`). */ match: string[]; /** Optional predicate override for active state (used when a static prefix * can't express the route, e.g. Chat = /workspaces/:id/chat). */ activeWhen?: (pathname: string) => boolean; /** Optional attention count; only rendered when > 0. */ badge?: number; /** Optional click override — e.g. open the workspace switcher when there is * no real workspace to chat in (avoids a dead nav to `to`). Falls back to * navigating to `to` when absent. */ onClick?: () => void; } interface SidebarProps { workspaceName: string | null; spine: SidebarNavItem[]; /** Pro "Pinned · power tools" group (empty for non-power tiers). */ pinned?: SidebarNavItem[]; onOpenWorkspaceSwitcher: () => void; onOpenCommand: () => void; onSpawnAgent: () => void; userName: string | null; } function initialOf(name: string | null, fallback: string): string { const c = name?.trim()?.[0]; return (c ?? fallback).toUpperCase(); } const Sidebar = ({ workspaceName, spine, pinned = [], onOpenWorkspaceSwitcher, onOpenCommand, onSpawnAgent, userName, }: SidebarProps) => { const navigate = useNavigate(); const { pathname } = useLocation(); const isActive = (item: SidebarNavItem): boolean => item.activeWhen ? item.activeWhen(pathname) : item.match.some((p) => pathname === p || pathname.startsWith(`${p}/`)); const renderNavItem = (item: SidebarNavItem) => { const active = isActive(item); const Icon = item.icon; return ( // Below lg the sidebar collapses to an icon rail — the hover tooltip is the // only way to read the label there. It's redundant (but harmless) at ≥lg. ); }; // Wave V Lane F (a11y): the section labels sit on --bg-2, which is one step // darker than --bg in light — where --text-dim measured 4.47:1 (sub-AA at // 9.5px). --text-muted clears it on --bg-2 in both themes (4.77:1 light / // 6.31:1 dark) while staying quieter than body text. (--text-dim stays tuned // for its --bg surfaces elsewhere; fixing it globally would over-lighten those.) // Wave X Lane C: 9.5px/0.14em uppercase in --text-muted read as garbled noise // (video judge). Bumped to 10.5px and eased tracking to 0.10em so the zone // eyebrows ("PINNED · POWER TOOLS" / "GENERAL") stay legible at 1×. const zoneLabel = "hidden lg:flex items-center gap-2 px-2.5 pt-3.5 pb-1.5 font-mono text-[10.5px] uppercase tracking-[0.1em] text-[var(--text-muted)]"; return ( ); }; export default Sidebar;