import { useMemo, useState } from "react"; import { Menu, Search, 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 { Separator } from "@/components/ui/separator"; import { cn } from "@/lib/utils"; import type { ChatSummary } from "@/lib/types"; interface SidebarProps { sessions: ChatSummary[]; activeKey: string | null; loading: boolean; onNewChat: () => void; onSelect: (key: string) => void; onRequestDelete: (key: string, label: string) => void; onCollapse: () => void; } export function Sidebar(props: SidebarProps) { const { t } = useTranslation(); const [query, setQuery] = useState(""); const normalizedQuery = query.trim().toLowerCase(); const filteredSessions = useMemo(() => { if (!normalizedQuery) return props.sessions; return props.sessions.filter((session) => { const haystack = [ session.preview, session.chatId, session.channel, session.key, ] .filter(Boolean) .join(" ") .toLowerCase(); return haystack.includes(normalizedQuery); }); }, [normalizedQuery, props.sessions]); return ( ); }