import { useRef } from "react"; import { Activity, Info, Check, ChevronDown, ChevronLeft, LogOut, Loader2, RotateCcw, Blocks, Palette, Server, ShieldCheck, SlidersHorizontal, type LucideIcon, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { SIDEBAR_SELECTION_ITEM_CLASS, SidebarSelectionHighlight, } from "@/components/SidebarSelectionHighlight"; import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { cn } from "@/lib/utils"; const SETTINGS_NAV_ITEMS: Array<{ key: SettingsSectionKey; icon: LucideIcon; fallback: string }> = [ { key: "overview", icon: Activity, fallback: "Overview" }, { key: "appearance", icon: Palette, fallback: "Appearance" }, { key: "models", icon: SlidersHorizontal, fallback: "Models" }, { key: "capabilities", icon: Blocks, fallback: "Capabilities" }, { key: "runtime", icon: Server, fallback: "System" }, { key: "advanced", icon: ShieldCheck, fallback: "Advanced" }, { key: "about", icon: Info, fallback: "About" }, ]; export function standaloneSectionTitle(section: SettingsSectionKey): string { if (section === "apps") return "Apps"; if (section === "automations") return "Automations"; if (section === "skills") return "Skills"; if (section === "channels") return "Channels"; return SETTINGS_NAV_ITEMS.find((item) => item.key === section)?.fallback ?? "Settings"; } export function SettingsSidebar({ activeSection, onSelectSection, onBackToChat, onLogout, hostChromeInset, onRestart, isRestarting, restartPending, isNativeHost, }: { activeSection: SettingsSectionKey; onSelectSection: (section: SettingsSectionKey) => void; onBackToChat: () => void; onLogout?: () => void; hostChromeInset?: boolean; onRestart?: () => void; isRestarting?: boolean; restartPending?: boolean; isNativeHost?: boolean; }) { const { t } = useTranslation(); const restartLabel = isRestarting ? t(isNativeHost ? "app.system.restartingEngine" : "app.system.restarting") : t("app.system.restartAction"); const navSection = isCapabilitySection(activeSection) ? "capabilities" : activeSection; const activeNavItemRef = useRef(null); const activeItem = SETTINGS_NAV_ITEMS.find((item) => item.key === navSection) ?? SETTINGS_NAV_ITEMS[0]; const ActiveIcon = activeItem.icon; const activeLabel = t(`settings.nav.${activeItem.key}`, { defaultValue: activeItem.fallback, }); return ( ); }