diff --git a/components/attachment-preview.tsx b/components/attachment-preview.tsx new file mode 100644 index 0000000000..8c76198fd5 --- /dev/null +++ b/components/attachment-preview.tsx @@ -0,0 +1,29 @@ +import { X } from 'lucide-react'; +import { Button } from './ui/button'; +import { Attachment } from 'ai'; + +interface AttachmentPreviewProps { + attachment: Attachment; + onRemove: () => void; +} + +export function AttachmentPreview({ + attachment, + onRemove, +}: AttachmentPreviewProps) { + return ( +
+
+ {attachment.name} + +
+
+ ); +} diff --git a/components/chat.tsx b/components/chat.tsx index 2a919b1feb..13538dcdbd 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -15,6 +15,7 @@ import { useArtifactSelector } from '@/hooks/use-artifact'; import { toast } from 'sonner'; import { unstable_serialize } from 'swr/infinite'; import { getChatHistoryPaginationKey } from './sidebar-history'; +import { AttachmentPreview } from './attachment-preview'; export function Chat({ id, @@ -85,7 +86,22 @@ export function Chat({ isArtifactVisible={isArtifactVisible} /> -
+ + {attachments.length > 0 && ( +
+ {attachments.map((attachment, index) => ( + { + const newAttachments = [...attachments]; + newAttachments.splice(index, 1); + setAttachments(newAttachments); + }} + /> + ))} +
+ )} {!isReadonly && (