From a1a03877442a1af9b169342aebd2f616ad66663c Mon Sep 17 00:00:00 2001 From: Nikunj Kohli Date: Mon, 27 Oct 2025 09:39:38 +0530 Subject: [PATCH] chore(chat): remove image previews, keep drag-to-reorder --- frontend/src/components/MessageInput.tsx | 113 +++++++++-------------- frontend/src/upload/uploadSlice.ts | 4 - 2 files changed, 42 insertions(+), 75 deletions(-) diff --git a/frontend/src/components/MessageInput.tsx b/frontend/src/components/MessageInput.tsx index 7a6156fb..320cea31 100644 --- a/frontend/src/components/MessageInput.tsx +++ b/frontend/src/components/MessageInput.tsx @@ -95,15 +95,9 @@ export default function MessageInput({ const xhr = new XMLHttpRequest(); const uniqueId = crypto.randomUUID(); - // create preview for images - const isImage = file.type.startsWith('image/'); - const previewUrl = isImage ? URL.createObjectURL(file) : undefined; - const newAttachment = { id: uniqueId, fileName: file.name, - previewUrl, - mimeType: file.type, progress: 0, status: 'uploading' as const, taskId: '', @@ -145,7 +139,6 @@ export default function MessageInput({ updates: { status: 'failed' }, }), ); - if (previewUrl) URL.revokeObjectURL(previewUrl); } }; @@ -156,7 +149,6 @@ export default function MessageInput({ updates: { status: 'failed' }, }), ); - if (previewUrl) URL.revokeObjectURL(previewUrl); }; xhr.open('POST', `${apiHost}${endpoints.USER.STORE_ATTACHMENT}`); @@ -277,15 +269,7 @@ export default function MessageInput({ // Drag state for reordering const [draggingId, setDraggingId] = useState(null); - // Revoke object URLs on unmount to avoid memory leaks - useEffect(() => { - return () => { - attachments.forEach((att) => { - if (att.previewUrl) URL.revokeObjectURL(att.previewUrl); - }); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + // no preview object URLs to revoke (preview removed per reviewer request) const findIndexById = (id: string) => attachments.findIndex((a) => a.id === id); @@ -322,8 +306,6 @@ export default function MessageInput({
{attachments.map((attachment) => { - const isImage = attachment.mimeType?.startsWith?.('image/'); - const index = attachments.findIndex((a) => a.id === attachment.id); return (
-
- {isImage && attachment.previewUrl ? ( +
+ {attachment.status === 'completed' && ( {attachment.fileName} - ) : ( -
- {attachment.status === 'completed' && ( - Attachment - )} + )} - {attachment.status === 'failed' && ( - Failed - )} + {attachment.status === 'failed' && ( + Failed + )} - {(attachment.status === 'uploading' || - attachment.status === 'processing') && ( -
- - - - -
- )} + {(attachment.status === 'uploading' || + attachment.status === 'processing') && ( +
+ + + +
)}
@@ -402,7 +374,6 @@ export default function MessageInput({