feat: multimodal image support with drag-and-drop file handling#1025
Open
0xsline wants to merge 4 commits intoItzCrazyKns:masterfrom
Open
feat: multimodal image support with drag-and-drop file handling#10250xsline wants to merge 4 commits intoItzCrazyKns:masterfrom
0xsline wants to merge 4 commits intoItzCrazyKns:masterfrom
Conversation
- Add NotoSansSC font for Chinese/Japanese/Korean PDF export support - Create lazy-loading font loader with caching for optimal performance - Fix SearXNG build failure by adding typing_extensions dependency - Fix container startup by setting HOSTNAME=0.0.0.0 in docker-compose Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add multimodal image upload for AI conversations (OpenAI, Ollama) - Support image paste (Ctrl+V/Cmd+V) and drag-and-drop in chat inputs - Support document file (PDF/DOCX/TXT) paste and drag-and-drop upload - Display uploaded images in chat history with click-to-preview lightbox - Add per-file delete buttons for both images and documents in attachments - Show upload progress indicator for document file uploads - Extract shared file handling logic into useFileHandler hook
Contributor
There was a problem hiding this comment.
7 issues found across 23 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/MessageInputActions/Attach.tsx">
<violation number="1" location="src/components/MessageInputActions/Attach.tsx:32">
P2: handleFileChange sets loading to true but lacks error handling; if fetch/res.json throws, setLoading(false) never runs and the attach UI can get stuck on the spinner.</violation>
<violation number="2" location="src/components/MessageInputActions/Attach.tsx:84">
P2: Async image selection appends with captured `images`, which can drop previous selections. Use a functional state update.</violation>
</file>
<file name="src/lib/hooks/useChat.tsx">
<violation number="1" location="src/lib/hooks/useChat.tsx:750">
P2: Images state isn’t cleared when switching chats, so unsent images from a previous chat can be attached to a different chat’s next message.</violation>
</file>
<file name="src/lib/hooks/useFileHandler.ts">
<violation number="1" location="src/lib/hooks/useFileHandler.ts:47">
P2: FileReader errors/aborts are not handled; a failed read leaves the per-file promise pending so Promise.all never resolves, stalling the entire image batch.</violation>
<violation number="2" location="src/lib/hooks/useFileHandler.ts:58">
P2: Async callbacks append to state using ref snapshots rather than functional updates, so multiple completions before a render can overwrite each other and drop images/files. Use functional `set*` updates to make merges atomic.</violation>
</file>
<file name="src/app/api/search/route.ts">
<violation number="1" location="src/app/api/search/route.ts:63">
P1: Search route drops uploaded image context by forcing `images` to an empty array instead of forwarding request images.</violation>
</file>
<file name="src/components/MessageInputActions/AttachSmall.tsx">
<violation number="1" location="src/components/MessageInputActions/AttachSmall.tsx:81">
P2: Async image uploads append using a stale `images` array, so overlapping selections can overwrite earlier results. Use a functional state update to preserve concurrent additions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- P1: forward images in search route instead of dropping them - P2: add try/catch/finally to file upload handlers (Attach, AttachSmall) - P2: use refs for latest state in async callbacks to prevent stale closures - P2: add FileReader onerror/onabort handlers to prevent pending promises - P2: clear images state when switching chats to prevent cross-chat leaks
Contributor
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/MessageInputActions/Attach.tsx">
<violation number="1" location="src/components/MessageInputActions/Attach.tsx:64">
P2: Async uploads/readers use ref snapshots when updating files/fileIds/images, so near-simultaneous completions can overwrite each other and drop attachments. Use functional state updates to merge against the latest value.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Change context types for setFiles/setFileIds/setImages to Dispatch<SetStateAction<T>> to support functional updates - Replace all ref-based state reads with prev => [...prev, ...new] pattern in async callbacks (useFileHandler, Attach, AttachSmall) - Eliminates risk of concurrent async completions overwriting each other
xkonjin
reviewed
Mar 8, 2026
xkonjin
left a comment
There was a problem hiding this comment.
Quick review pass:
- Main risk area here is input validation, path handling, and malformed payload behavior.
- I didn’t see targeted regression coverage in the diff; please add or point CI at a focused test for the changed path in Dockerfile, docker-compose.yaml, NotoSansSC-Regular.ttf (+20 more).
- Before merge, I’d smoke-test the behavior touched by Dockerfile, docker-compose.yaml, NotoSansSC-Regular.ttf (+20 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Backend (LLM providers)
ContentParttypes (text/image_url) tosrc/lib/types.tsContentPart[]in OpenAI and Ollama message convertersFrontend
useFileHandlerhook: shared paste + drag-and-drop logic with ref-based state to avoid stale closuresImagePreviewcomponent: click-to-enlarge lightbox overlayMessageInput/EmptyChatMessageInput: paste, drag-and-drop, upload progress toastAttach/AttachSmall: per-file X delete buttons for documentsMessageBox: render image thumbnails in chat historyuseChat: track images state, include in message payloadTest plan
Summary by cubic
Add image attachments to chat with paste and drag-and-drop, thumbnails in history, and click-to-preview. Improves file handling reliability, forwards images through search, and fixes PDF export (CJK) and container startup.
New Features
Bug Fixes
Written for commit dd386df. Summary will update on new commits.