diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsx index 18b37980b..a0ac7db5f 100644 --- a/web-app/src/containers/ChatInput.tsx +++ b/web-app/src/containers/ChatInput.tsx @@ -225,11 +225,7 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => { const actualType = getFileTypeFromExtension(file.name) || detectedType // Check file type - images only - const allowedTypes = [ - 'image/jpg', - 'image/jpeg', - 'image/png', - ] + const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png'] if (!allowedTypes.includes(actualType)) { setMessage( @@ -336,23 +332,23 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => { const clipboardItems = e.clipboardData?.items if (!clipboardItems) return - const imageItems = Array.from(clipboardItems).filter(item => + const imageItems = Array.from(clipboardItems).filter((item) => item.type.startsWith('image/') ) if (imageItems.length > 0) { e.preventDefault() - + const files: File[] = [] let processedCount = 0 - + imageItems.forEach((item) => { const file = item.getAsFile() if (file) { files.push(file) } processedCount++ - + // When all items are processed, handle the valid files if (processedCount === imageItems.length && files.length > 0) { const syntheticEvent = { @@ -360,7 +356,7 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => { files: files, }, } as unknown as React.ChangeEvent - + handleFileChange(syntheticEvent) } }) @@ -494,7 +490,7 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => { )} {/* File attachment - always available */}