import { MoreHorizontal, Trash2 } from "lucide-react"; import { useTranslation } from "react-i18next"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ScrollArea } from "@/components/ui/scroll-area"; import { relativeTime } from "@/lib/format"; import { cn } from "@/lib/utils"; import type { ChatSummary } from "@/lib/types"; interface ChatListProps { sessions: ChatSummary[]; activeKey: string | null; onSelect: (key: string) => void; onRequestDelete: (key: string, label: string) => void; loading?: boolean; } function titleFor(s: ChatSummary, fallbackTitle: string): string { const p = s.preview?.trim(); if (p) return p.length > 48 ? `${p.slice(0, 45)}…` : p; return fallbackTitle; } export function ChatList({ sessions, activeKey, onSelect, onRequestDelete, loading, }: ChatListProps) { const { t } = useTranslation(); if (loading && sessions.length === 0) { return (
{t("chat.loading")}
); } if (sessions.length === 0) { return (
{t("chat.noSessions")}
); } return ( ); }