import { FileText, Image as ImageIcon, X } from "lucide-preact"; import type { ChatAttachment } from "@/lib/api"; import { cn } from "@/lib/utils"; type Props = { attachments: ChatAttachment[]; tone?: "composer" | "user" | "assistant"; onRemove?: (id: string) => void; }; function getTextPreview(value: string) { const normalized = value.replace(/\r/g, "").trim(); if (!normalized) return "(empty file)"; return normalized.length <= 280 ? normalized : `${normalized.slice(0, 280).trimEnd()}...`; } function getSurfaceClasses(tone: Props["tone"]) { if (tone === "user") { return "border-white/12 bg-black/16 text-fuchsia-50"; } if (tone === "assistant") { return "border-violet-300/16 bg-violet-400/8 text-violet-50"; } return "border-violet-300/18 bg-background/40 text-violet-50"; } export function ChatAttachmentList({ attachments, tone = "composer", onRemove }: Props) { if (!attachments.length) return null; const surfaceClasses = getSurfaceClasses(tone); return (
{attachments.map((attachment) => { const isImage = attachment.kind === "image"; return (
{isImage ? (
{attachment.filename}

{attachment.filename}

{attachment.mimeType}

{onRemove ? ( ) : null}
) : (

{attachment.filename}

{attachment.mimeType} {attachment.truncated ? " ยท truncated" : ""}

{onRemove ? ( ) : null}
                      {getTextPreview(attachment.text)}
                    
)}
); })}
); }