import { MoreHorizontal, Pin } from "lucide-react"; import type { ChatConversationListItem } from "@paperclipai/shared"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { cn } from "../lib/utils"; interface ChatConversationItemProps { conversation: ChatConversationListItem; isActive: boolean; onSelect: (id: string) => void; onRename: (id: string, title: string) => void; onPin: (id: string, pinned: boolean) => void; onArchive: (id: string) => void; onDelete: (id: string) => void; } export function ChatConversationItem({ conversation, isActive, onSelect, onRename, onPin, onArchive, onDelete, }: ChatConversationItemProps) { const isPinned = !!conversation.pinnedAt; const title = conversation.title ?? "New Conversation"; const handleRename = (e: React.MouseEvent) => { e.stopPropagation(); const newTitle = window.prompt("Rename conversation", title); if (newTitle && newTitle.trim()) { onRename(conversation.id, newTitle.trim()); } }; const handlePin = (e: React.MouseEvent) => { e.stopPropagation(); onPin(conversation.id, !isPinned); }; const handleArchive = (e: React.MouseEvent) => { e.stopPropagation(); onArchive(conversation.id); }; const handleDelete = (e: React.MouseEvent) => { e.stopPropagation(); onDelete(conversation.id); }; return (
onSelect(conversation.id)} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") onSelect(conversation.id); }} className={cn( "group flex flex-col gap-0.5 rounded px-2 py-1.5 cursor-pointer relative", isActive ? "bg-accent/60" : "hover:bg-accent", )} >
{isPinned && } {title} {/* Action menu -- visible on hover */} Rename {isPinned ? "Unpin" : "Pin"} Archive Delete
{conversation.lastMessagePreview && ( {conversation.lastMessagePreview} )}
); }