import { useState, type ReactNode } from "react"; import { Archive, Brain, Menu, Search, Settings, SquarePen, Blocks, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { ChatList } from "@/components/ChatList"; import { ConnectionBadge } from "@/components/ConnectionBadge"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import type { ChatSummary, SidebarViewState, } from "@/lib/types"; import { cn } from "@/lib/utils"; interface SidebarProps { sessions: ChatSummary[]; activeKey: string | null; loading: boolean; onNewChat: () => void; onSelect: (key: string) => void; onRequestDelete: (key: string, label: string) => void; onTogglePin: (key: string) => void; onRequestRename: (key: string, label: string) => void; onToggleArchive: (key: string) => void; onToggleGroup: (groupId: string) => void; onRequestRenameProject: (projectKey: string, label: string) => void; onNewChatInProject: (projectPath: string, projectName: string) => void; onOpenSettings: () => void; onOpenApps: () => void; onOpenSkills: () => void; onOpenSearch: () => void; activeUtility?: "apps" | "skills" | null; onToggleArchived: () => void; onCollapse: () => void; onExpand?: () => void; containActionMenus?: boolean; collapsed?: boolean; pinnedKeys?: string[]; archivedKeys?: string[]; titleOverrides?: Record; projectNameOverrides?: Record; collapsedGroups?: Record; runningChatIds?: string[]; completedChatIds?: string[]; viewState?: SidebarViewState; showArchived?: boolean; archivedCount?: number; defaultWorkspacePath?: string | null; hostChromeInset?: boolean; } type NavigatorWithUserAgentData = Navigator & { userAgentData?: { platform?: string }; }; function isApplePlatform(): boolean { if (typeof navigator === "undefined") return false; const platform = navigator.platform || ""; const userAgentPlatform = (navigator as NavigatorWithUserAgentData).userAgentData?.platform || ""; return /mac|iphone|ipad|ipod/i.test(`${platform} ${userAgentPlatform}`); } function newChatShortcutLabel(): string { return isApplePlatform() ? "⌘⇧O" : "Ctrl+Shift+O"; } export function Sidebar(props: SidebarProps) { const { t } = useTranslation(); const [menuPortalContainer, setMenuPortalContainer] = useState(null); const collapsed = Boolean(props.collapsed); const toggleLabel = t("thread.header.toggleSidebar"); const newChatShortcut = newChatShortcutLabel(); return ( ); } function SidebarActionButton({ collapsed, label, icon, onClick, active = false, className, shortcut, ariaKeyShortcuts, }: { collapsed: boolean; label: string; icon: ReactNode; onClick: () => void; active?: boolean; className?: string; shortcut?: string; ariaKeyShortcuts?: string; }) { const title = shortcut ? `${label} (${shortcut})` : collapsed ? label : undefined; return ( ); }