import React from "react"; import type { Attachment } from "./props"; import { formatFileSize, getSourceUrl, getDocumentIcon, } from "@copilotkit/shared"; interface AttachmentQueueProps { attachments: Attachment[]; onRemoveAttachment: (id: string) => void; className?: string; } export const AttachmentQueue: React.FC = ({ attachments, onRemoveAttachment, className = "", }) => { if (attachments.length === 0) return null; return (
{attachments.map((attachment) => (
{attachment.status === "uploading" && (
)}
))}
); }; function AttachmentPreview({ attachment }: { attachment: Attachment }) { if (attachment.status === "uploading") { return
; } const src = getSourceUrl(attachment.source); switch (attachment.type) { case "image": return ( {attachment.filename ); case "audio": return (
); case "video": return (
{attachment.thumbnail ? ( {attachment.filename ) : (
); case "document": return (
{getDocumentIcon(attachment.source.mimeType ?? "")}
{attachment.filename || "Document"} {attachment.size != null && ( {formatFileSize(attachment.size)} )}
); } } /** * @deprecated Use `AttachmentQueue` from `@copilotkit/react-ui` instead. * `ImageUploadQueue` only displayed image previews. `AttachmentQueue` supports * images, audio, video, and documents. * See https://docs.copilotkit.ai/migration-guides/migrate-attachments * @since 1.56.0 */ export { AttachmentQueue as ImageUploadQueue };