Repository navigation
Fix desktop image drops for chat attachments - #7982
danielhanchen merged 21 commits into
Conversation
99ba5cc to
aa0b16b
Compare
|
Looking great, thank you @Souravrajvi0! great work, will leave a review of the code as well if there is anything that needs to be cleaned up. |
|
Pushed three commits to this branch (thanks for leaving maintainer edits on) and re-merged The red CI isn't your feature. The merge in e7cb908 resolved in favour of the branch across the board and reverted ~13k lines of The two open P2s from the last review:
Local: 798 frontend tests, 173 Rust tests, typecheck and build clean. The drag-drop itself still needs a desktop build to smoke. |
Classify image drops separately from RAG documents, queue them for the composer, and read dropped image bytes through Tauri so vision attachments no longer fail on the document upload path.
Verify the attachment target key before each addAttachment and re-queue remaining intents when the user switches chats mid-import. Align the desktop reliability contract with the 30px titlebar control size.
Re-queue remaining intents on composer unmount or target change, and handle per-image failures without dropping later valid attachments. Align the desktop reliability contract with the 30px New chat button.
Subscribe to the image queue instead of tying the drain worker to hasPendingImageAttachments, return after requeueing failed suffixes, block send/queue while images materialize, and allow image drops without backend path leases.
… holes - dictation: the recording bar's send now waits on materializing image drops instead of spending the held send on a submit that shouldBlockSend bounces - drain: a drain for a target the composer has already left no longer clears the shared materializing flag out from under the live target - rust: cap the attachment read itself, so a file that grows after the stat can't get past the 20 MiB limit
VisionImageAdapter.add already toasts before it throws, and every rejection it can reach on this path is chat-wide (no model, or not multimodal) rather than per-file, since Rust enforces the same 20 MiB cap. Requeueing the rest of the batch just read each image over IPC to reject it again, so a 3-image drop onto a text-only model produced six toasts. Stop at the first failure, matching how the document drop path reports a batch-wide refusal once.
…seam unslothai#7963 was two features sharing one list until it drifted. The image drop path has a second seam of that shape: native_intents.rs stamps the File's MIME type and the composer routes to an adapter by MIME, with nothing tying the two together. Pin them, so a format added to one side can't silently stop being droppable.
A send parked behind document indexing fired the moment indexing cleared, without re-checking the gate it passed on the way in. Drop an image onto that draft and the text goes out without it, and the image attaches to the next draft instead.
- registration: the gate only saw the queue, which the intents don't reach until Rust has answered. An Enter in that window sent the text alone. The count is deliberately not keyed: until the intents land there is no settled target, since an implicit single chat re-keys the moment its thread exists. - failure: a parked send fired when a dropped image failed to materialize, turning a failed drop into a send of the text without it. Cancel the parked send instead, so the user keeps their text and the toast explains why.
The update() path now wraps setup in _WindowsLauncherUpdateTransaction instead of _release_self_exe_lock_windows. Align the ordering assertion with the current studio.py structure.
provider.tsx now uses --studio-titlebar-navigation-offset-y 4px and --studio-chat-header-padding-top 9px; update the desktop reliability contract assertions to match.
2bd5619 to
4c741bd
Compare
Registration failures, listener teardown and partial batches each lost a dropped image or sent the text without it. Also binds the native read to the fingerprint the token was validated against. - store: imageDropFailures, bumped when a drop fails before it queues, so the composer can drop a parked send instead of sending the text alone. - use-native-drop: register per path (allSettled) so one bad file no longer discards its siblings' leases, and enqueue registered intents even when the listener was disposed mid-flight. - thread: requeue a drained batch under the key the same composer moved to, so a fresh chat persisting mid-batch no longer strands it; guard the parked send on pendingSendRef for a cancel in the same commit. - native_intents: open with O_NOFOLLOW and recheck size and mtime against the entry, so a file swapped in after validation is not read. - tests: extension to MIME arm parity, composer picker parity, doc/image disjointness, and four Rust tests for the read path.
|
Pushed d19bb57. The feature itself is right, and I checked that it does not disturb anything that worked before: I ran main's classifier and this branch's over 48,203 generated drop payloads (Linux, macOS and Windows path shapes, case variants, dotfiles, double extensions, unicode, spaces, batches of 1 to 4) and there are zero behaviour changes for any payload that previously classified as a model or a document drop. Every change is What I fixed, all of it in the failure and teardown paths rather than the happy path. 1. A failed registration released the send gate with no way to cancel a parked send. 2. Teardown mid-registration lost the images. 3. A mixed drop was all-or-nothing. One failing document rejected the whole 4. A re-key mid-batch stranded the batch. 5. The native read was not bound to the fingerprint it had just validated. Tests. The two parity tests never joined up: Local: 897 frontend tests, typecheck, build and biome all clean, biome at the same error and warning counts as before the change. Two things I left alone and would suggest as follow-ups rather than fold in here. One thing worth knowing rather than fixing: Tauri has open reports of On the red CI: the four Backend CI failures in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d19bb57356
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const registeringImageDrops = useNativeIntentStore( | ||
| (s) => s.registeringImageDrops > 0, | ||
| ); |
There was a problem hiding this comment.
Scope the image-registration gate to its target chat
When an image dropped in chat A is still registering and the user switches to chat B, this global counter keeps B's shouldBlockSend and queue gate closed even though the resulting intents remain bound to A. Registration can remain in flight noticeably for a large batch or paths on a slow or unavailable network filesystem, making the unrelated active chat unable to send until A's work settles; track registration by the captured attachment target rather than as a window-wide boolean.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct as stated, but I do not think keying it is an improvement. The counter exists precisely to cover the window before the intents reach a queue, and that window is where a fresh chat re-keys from single:new to single:. Keying the gate to the drop-time value re-opens the hole it was added for, in exchange for a Send that is blocked for the length of one registration round trip on a chat the user just switched to. The queued intents themselves are already bound to the right chat, and the per-chat signal that does matter, imageDropFailures, is keyed in e512022. Happy to revisit if you have a repro where the block is long enough to notice on a local disk.
…nslothai#7982 - A read failure now carries on to the next image and reports once at the end of the drain, instead of one toast per file when a whole batch is unreadable. - The addAttachment catch drops its toast: VisionImageAdapter.add already toasts before it throws, and its only other throw is the 20 MiB cap that Rust enforces first. - Both cancels test composer identity, matching requeueKey, so a fresh chat rekeying mid-read still cancels its own parked send.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b8a9a547e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| isModelLoading: Boolean(loadingModel) || modelLoading, | ||
| onAutoLoad: handleNativeModelDropAutoLoad, | ||
| onAttach: handleNativeAttachmentDrop, | ||
| onAttachImages: handleNativeImageDrop, |
There was a problem hiding this comment.
Route native image drops into compare mode
In desktop compare mode this callback is attached only to useNativeModelDrop, whose enabled condition remains restricted to view.mode === "single". The compare SharedComposer also explicitly returns from its drag handlers when isTauri (lines 1883–1895), so PNG/JPEG drops in compare mode are ignored even though that composer supports the same image types through its picker. Add native image-drop routing for SharedComposer or otherwise enable an appropriate compare-mode listener.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct that compare mode ignores these drops, but that is not this PR. enabled: active && view.mode === "single" is on main today at chat-page.tsx:2602, so compare mode has never taken a native drop of any kind, documents included. Wiring SharedComposer up is a new capability rather than a fix for #7963, and it needs its own decisions: compare has two panes and a drop lands on the window, so something has to say which pane gets the image. Worth its own issue, and I would rather not widen this one.
…thai#7982 - cancelQueuedSend clears the dictation hold as well: a transcript held behind the same block otherwise submits itself once the block clears, without the image the drop failed to attach. - The drag overlay claimed "Indexed for this chat" for images, which are never indexed. The attach state now carries its kind and the copy follows.
…hem for PR unslothai#7982 - A fresh chat persisting remounts Composer, so the outgoing instance cannot hand its queue to the new key: it tags the batch with its composer identity and the next instance with that identity claims it on mount. - interceptSend parks the send while images materialize instead of swallowing the click, with wait-toast copy that names what it is waiting for.
…for PR unslothai#7982 - The replacement composer's claim ran once at mount, so a predecessor that requeued after that point left its batch stranded. The claim is reactive now, watching imageDropOwners for an entry tagged with this composer. - handleSubmit has its own gate ahead of interceptSend, so the image park was unreachable from a click or Enter. Both gates call one parkIfWaitingOnImages.
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Fixes #7963.
Dragging a PNG/JPG onto the desktop window was rejected because
drop-paths.tsderived its whitelist fromRAG_UPLOAD_ACCEPT(documents only). The chat composer already accepts vision images via a separateIMAGE_ACCEPTlist.Fix
drop-paths.tsCHAT_IMAGE_DROP_ACCEPT(.jpg,.jpeg,.png,.webp,.gif) merged into the native drop classifier; updateSUPPORTED_DROP_HINTnative_path_policy.rsIMAGE_ATTACHMENT_EXTSand allow them inclassify_native_attachment_pathwithout widening document/RAG ingestRAG_UPLOAD_ACCEPTis unchanged, so the knowledge-base uploader still only accepts documents.Testing
Covers image-only drops, mixed doc+image batches, hint text, and frontend↔Rust extension parity for both document and image sets.
Not run here: Tauri desktop drag-drop smoke (needs a built app).