import { useState, type ReactNode } from "react"; import { Archive, ListFilter, Menu, Search, Settings, SquarePen, } 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 { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Separator } from "@/components/ui/separator"; import type { ChatSummary, SidebarSortMode, 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; onOpenSettings: () => void; onOpenSearch: () => void; onToggleArchived: () => void; onUpdateView: (view: Partial) => void; onCollapse: () => void; onExpand?: () => void; containActionMenus?: boolean; collapsed?: boolean; pinnedKeys?: string[]; archivedKeys?: string[]; titleOverrides?: Record; runningChatIds?: string[]; completedChatIds?: string[]; viewState?: SidebarViewState; showArchived?: boolean; archivedCount?: number; } export function Sidebar(props: SidebarProps) { const { t } = useTranslation(); const [menuPortalContainer, setMenuPortalContainer] = useState(null); const collapsed = Boolean(props.collapsed); const toggleLabel = t("thread.header.toggleSidebar"); return ( ); } function SidebarActionButton({ collapsed, label, icon, onClick, className, }: { collapsed: boolean; label: string; icon: ReactNode; onClick: () => void; className?: string; }) { return ( ); } function SidebarViewMenu({ compact = false, view, onUpdateView, }: { compact?: boolean; view?: SidebarViewState; onUpdateView: (view: Partial) => void; }) { const { t } = useTranslation(); const sort = view?.sort ?? "updated_desc"; const setSort = (value: string) => { if (isSidebarSortMode(value)) onUpdateView({ sort: value }); }; return ( {t("sidebar.viewOptions")} onUpdateView({ density: checked ? "compact" : "comfortable" }) } onSelect={(event) => event.preventDefault()} > {t("sidebar.compactList")} onUpdateView({ show_previews: Boolean(checked) }) } onSelect={(event) => event.preventDefault()} > {t("sidebar.showPreviews")} onUpdateView({ show_timestamps: Boolean(checked) }) } onSelect={(event) => event.preventDefault()} > {t("sidebar.showTimestamps")} {t("sidebar.sortLabel")} {t("sidebar.sortUpdated")} {t("sidebar.sortCreated")} {t("sidebar.sortTitle")} ); } function isSidebarSortMode(value: string): value is SidebarSortMode { return value === "updated_desc" || value === "created_desc" || value === "title_asc"; }