"use client"; /** * The row of files staged in the composer before a message is sent. * * Each chip shows its own upload state, because one failure among several * shouldn't discard the rest — the user removes the failed one and sends. */ import { AlertCircle, FileText, Loader2, X } from "lucide-react"; import { cn } from "@/lib/utils"; import type { UploadedAttachment } from "@/lib/chat"; export type StagedAttachment = { /** Client-side id; the upload has no server identity until it is sent. */ id: string; file: File; /** Object URL for an image thumbnail, revoked when the chip is removed. */ previewUrl?: string; status: "uploading" | "ready" | "failed"; uploaded?: UploadedAttachment; }; export function ComposerAttachments({ items, onRemove, }: { items: StagedAttachment[]; onRemove: (id: string) => void; }) { if (items.length === 0) return null; return (
{items.map((item) => (
{item.previewUrl ? ( // eslint-disable-next-line @next/next/no-img-element ) : ( )} {item.file.name} {item.status === "uploading" && ( )} {item.status === "failed" && ( )}
))}
); }