From 23cef5fd82a7191accda20dfb4c9c97ddf7d58b4 Mon Sep 17 00:00:00 2001 From: Kacper Date: Tue, 16 Dec 2025 03:11:01 +0100 Subject: [PATCH] feat: enhance image handling in chat and drop zone components - Updated ImageAttachment interface to make 'id' and 'size' optional for better compatibility with server messages. - Improved image display in AgentView for user messages, including a count of attached images and a clickable preview. - Refined ImageDropZone to conditionally render file size and ensure proper handling of image removal actions. --- .../app/src/components/ui/image-drop-zone.tsx | 12 ++-- apps/app/src/components/views/agent-view.tsx | 64 ++++++++++++++++--- apps/app/src/store/app-store.ts | 4 +- apps/app/src/types/electron.d.ts | 4 +- 4 files changed, 65 insertions(+), 19 deletions(-) diff --git a/apps/app/src/components/ui/image-drop-zone.tsx b/apps/app/src/components/ui/image-drop-zone.tsx index 17b4c9d0..70a683cb 100644 --- a/apps/app/src/components/ui/image-drop-zone.tsx +++ b/apps/app/src/components/ui/image-drop-zone.tsx @@ -244,14 +244,16 @@ export function ImageDropZone({

{image.filename}

-

- {formatFileSize(image.size)} -

+ {image.size !== undefined && ( +

+ {formatFileSize(image.size)} +

+ )} {/* Remove button */} - {!disabled && ( + {!disabled && image.id && ( + {image.id && ( + + )} ))} diff --git a/apps/app/src/store/app-store.ts b/apps/app/src/store/app-store.ts index 3c2aeaa4..6992dc2d 100644 --- a/apps/app/src/store/app-store.ts +++ b/apps/app/src/store/app-store.ts @@ -210,11 +210,11 @@ export const DEFAULT_KEYBOARD_SHORTCUTS: KeyboardShortcuts = { }; export interface ImageAttachment { - id: string; + id?: string; // Optional - may not be present in messages loaded from server data: string; // base64 encoded image data mimeType: string; // e.g., "image/png", "image/jpeg" filename: string; - size: number; // file size in bytes + size?: number; // file size in bytes - optional for messages from server } export interface ChatMessage { diff --git a/apps/app/src/types/electron.d.ts b/apps/app/src/types/electron.d.ts index 9f112568..5eb152d0 100644 --- a/apps/app/src/types/electron.d.ts +++ b/apps/app/src/types/electron.d.ts @@ -3,11 +3,11 @@ */ export interface ImageAttachment { - id: string; + id?: string; // Optional - may not be present in messages loaded from server data: string; // base64 encoded image data mimeType: string; // e.g., "image/png", "image/jpeg" filename: string; - size: number; // file size in bytes + size?: number; // file size in bytes - optional for messages from server } export interface Message {