Repository navigation
Studio: attach video to a chat, and say why when it is unavailable - #9057
Conversation
36c94c7 to
a325f99
Compare
|
Good catch, that one is real. Fixed in a325f99: While rebasing this onto the updated #9056 I also fixed two things on that branch that are worth flagging here, since both were mine:
|
a325f99 to
d3d8059
Compare
d3d8059 to
78637fe
Compare
|
All three were right. Fixed in 78637fe. Capability never copied into the row. This was the serious one: Tool and response_format passthrough. Confirmed the branch returns well before the injection, and Base64 ceiling. Confirmed the arithmetic: a 64 MiB file encodes to Tests added for the last two, and I checked they fail against the old code before keeping them. |
llama.cpp takes video through its OpenAI-compatible chat endpoint as an `input_video` content part, but only when the mmproj declares video, the binary was built with video support and ffmpeg is installed. It reports that verdict at /props under modalities.video. Nothing about the GGUF alone can tell us, so that is what Studio now reads. Frontend: video joins the drop classifier and its own pending queue beside images and audio, and a VideoAttachmentAdapter takes one clip per message from the picker or a drop. When the model cannot take video the adapter names all three possible causes instead of letting llama-server refuse the request later. Backend: video_base64 on the chat request is forwarded whole as an input_video part, since llama-server owns the frame sampling and there is nothing useful to transcode. has_video_input rides the same path as has_audio_input out to the model row. Compare mode is left out on purpose: video_base64 targets the single loaded GGUF, so at most one side could answer. Dropping a clip there now says so rather than ignoring the file. Size caps line up across the three hops (64 MB in the desktop reader, in the composer and in the route) so no hop accepts what the next refuses.
… path Three review findings, all correct. syncModelCapabilities took has_video_input but never copied it into the row, and /api/models/list omits it for the active GGUF, so the adapter read false after every load and refused video even when /props reported it. The feature did not work in its main path. The tool and response_format passthrough returns before the injection and forwards an explicit field list, so a clip rode along nowhere and the model answered without it. Refused now, the way audio already is there. The size cap floored the base64 inflation, so a clip of exactly the size the composer allows was refused with a 413, and the data URI header was counted against the payload. Padded ceiling, measured after stripping.
…here it cannot be served Three separate places map backend capability flags onto a model row and each one dropped the video flag: the direct status adoption, the queued-run capability Pick, and (fixed earlier) syncModelCapabilities. The adapter reads that row, so any of them leaves video refused on a model that supports it. Covered by a rule rather than three spot checks. Injection lives in the GGUF branch, so an external provider or a local transformers model answered as if no clip were attached. Both now refuse, as does token counting, which cannot inject the frames it would need to count. The size check also moved ahead of the automatic model switch so an oversized clip does not evict a working model before the 413, and video now votes in the pre-switch projector requirement alongside audio. The video drain's read-failure toast said 'audio', inherited from the audio drain it was cloned from.
cb6c49e to
57d819a
Compare
|
All four correct. One of them turned out to be broader than reported. Status adoption drops the video capability (correct, and there was a third site). Video before automatic model switching (correct). The size check is a target-independent length check, exactly like the audio one directly above it, so it had no business running after a model load. Moved ahead of the switch, and video now votes in the projector requirement alongside audio. Both checks call one Attachment surviving a model change (correct). Confirmed both halves: Video drain toast says audio (correct). Straight inheritance from the audio drain it was cloned from, on the one path whose whole job is explaining why a dropped video did not attach. Each of the six new tests was confirmed to fail against the pre-fix tree. Full run: 2952 frontend tests pass, 907 backend tests across the inference suites pass (the 6 failures in |
Adding video to require_vision made the shared rejection reachable for a request carrying only a clip, but its text is fixed at 'image or audio input', so the user who attached a video was told about modalities the request never carried. The label now follows what is attached, and defaults to the existing wording so the image-only callers are unchanged.
|
Correct, and it is a regression I introduced in the previous round. Adding
Worth noting what the fix caught on the way in: the existing Four tests, three of which fail against the pre-fix tree:
Backend run over the inference, auto-switch, audio, token-count and video suites: 1530 passed against 1526 on a clean checkout, same 18 pre-existing failures either side (the text-to-video generation suites and |
… recount The /props probe went out without an Authorization header, so under UNSLOTH_DIRECT_STREAM=1 llama-server answered 401 and video capability never came back. Context recount already bails on images and audio because toOpenAIMessages has no branch for them; video has the same property and was missing the bail, so the usage bar priced a text-only prompt and stringified megabytes of base64 on the UI thread.
Review summaryVerdict: useful, merge it. Nine review items triaged, four fixes pushed as Before / after, with the screenshotBefore, dropping or picking an BEFORE Two traps were hit and are recorded rather than papered over: a port collision with another Studio on this box (caught by the identity check), and host noise that read exactly like a PR effect - the welcome greeting is Item verdictsSeven of nine were correct when written (02:42-08:05 on 2026-08-17) and had already been fixed by
Is the issue realYes, and the before-side console says so literally. Worth noting the design call at the centre of it: the feature hinges on llama-server's Does it break anythingPurely additive: a new optional Pydantic field, a new adapter inserted into a composite, new refusal branches. I measured that adding the video adapter steals no pre-existing attachment type - identical dispatch for png/gif/wav/mp3/ogg/flac/webm-audio/m4a/txt/md/html/pdf with and without it. Old llama.cpp builds, the case you asked about: a build too old to report modalities omits the key entirely, Simulation789 new lines of tests, run against real code rather than mocks. 590 backend + 2996 frontend + 371 Rust, 0 failures.
Cross-platform and cross-browser. All five containers simulated as reported by Chrome/Edge, Firefox, Safari, and a Windows box with no codec pack - including the cases that return an empty MIME type ( Fixes pushed in
|
The accept list carries extensions as well as mime types because the browser's answer is unreliable for mkv and some mov files, and the picker takes those files on the extension. Only an empty type was being replaced, so a clip the browser called application/octet-stream kept that type into the attachment, and the request builder recognises a file part only when its mimeType matches ^video/. The clip was attached, sent and dropped, and the model answered as though nothing were there, which is the silent drop this PR exists to remove. The table mirrors the one in native_intents.rs, so a clip read by the desktop reader and one picked in the browser reach the route the same way.
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a3f14663c
ℹ️ 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 base64 = extractVideoPartBase64(part); | ||
| if (base64) return base64; |
There was a problem hiding this comment.
Reject empty video payloads instead of dropping them
When a user selects a zero-byte video, the attachment adapter accepts it because the size check only enforces the maximum, and fileToBase64 produces a data URI with an empty payload. extractVideoPartBase64 then returns "", but this truthiness check treats that as no video, so video_base64 is omitted and the model answers the text prompt without showing the intended “Could not read” error. Reject zero-byte files when adding them, or preserve the empty payload so the backend can return its explicit 400.
Useful? React with 👍 / 👎.
bf2e3bb
into
studio/desktop-drag-drop-9036
* Desktop: make every drop zone take a drop again (#9036) Tauri delivers OS file drops window-wide and suppresses the webview's own drop events, so a zone wired only to `onDrop` does nothing in the desktop app: no drag-over border, and the file is silently ignored. Native drop routing (#8265) was only ever adopted by the shared image picker and the create-project dialog. Every other file drop zone still relied on HTML5 handlers that never fire, which is why this reads as intermittent: the same file works when it lands on the chat, covered by the window-wide handler, and does nothing anywhere else. Adds `useNativeFileDrop`, which claims the native drop for an element and returns drag-over state plus the HTML5 handlers the web build still needs, then adopts it in the zones that were dead: - Projects -> Sources, which also had no drag-over styling at all - Data Recipes unstructured seed - Diffusion training images - Video and audio reference pickers Documents upload by lease rather than an inline read, since the native reader only serves media inline, so the recipe seed route now accepts `nativePathLease` the way the RAG upload routes already do. The native path policy accepts video containers so the reference picker can register what it is given. Also stops two silent discards with the same symptom: a claimed zone that refused a drop while disabled, and compare mode disabling the window-wide handler outright. Both now say what happened. `native-dropzone-coverage.test.ts` walks src/ and fails if a zone reads files from a drag payload without either claiming the native drop or explicitly deferring to the window handler. * Desktop: refuse a dropped model in compare too, and validate before reading Two things the first pass got wrong. Keeping the window-wide listener on outside single chat also handed it model drops, so a GGUF dropped on a compare or project view would load and replace the active model. Nothing happened there before, so that is not a change this should be making. The refusal now covers every kind the handler would act on, models included. The recipe seed route also moved its extension check after the read, so a rejected 500 MB upload was pulled into memory first. Back to validating the filename before reading a byte, as it was. * Desktop: size the native video cap to the largest client-side limit 64 MB sat under the reference picker's own 72 MB, so a clip the picker accepts was refused on drop. The cap is a backstop; callers keep theirs. * Desktop: drop the diffusion zone from this pass, and bound the native read Two review findings, both correct. The diffusion dataset zone accepts .bmp, .m4v, .caption and .jsonl, which the chat attachment policy rejects outright, and .txt, which registers but cannot be read inline. Captions beside images are the documented workflow there, so wiring that zone to the attachment path would have uploaded the images and silently lost the captions. It needs its own registration and upload policy, which is more than this belongs to, so it goes back to the picker it had. The recipe seed route also read a dropped path in full before checking any limit, so a multi-gigabyte local file went into backend memory before the 413. It now refuses on the stat and bounds the read by what the block has left, in case the file grows in between. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Desktop: keep a busy drop zone hit-testable, and size the video cap to the raw limit A disabled seed zone carried pointer-events-none, which takes it out of elementFromPoint, so nativeDropTargetAt could not find the target it had just registered. The disabled message was unreachable and the drop fell through to the window handler instead. MAX_NATIVE_VIDEO_BYTES was set to the reference picker's 96 MiB, but that cap bounds the data URL, not the file: the picker's own raw limit is 75497280 bytes. Rust was reading and base64-encoding up to 96 MiB, 128 MiB across the bridge, for clips the picker then rejected. * Match the document-refusal test to the message it now returns * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: attach video to a chat, and say why when it is unavailable (#9057) * Studio: attach video to a chat, and say why when it is unavailable llama.cpp takes video through its OpenAI-compatible chat endpoint as an `input_video` content part, but only when the mmproj declares video, the binary was built with video support and ffmpeg is installed. It reports that verdict at /props under modalities.video. Nothing about the GGUF alone can tell us, so that is what Studio now reads. Frontend: video joins the drop classifier and its own pending queue beside images and audio, and a VideoAttachmentAdapter takes one clip per message from the picker or a drop. When the model cannot take video the adapter names all three possible causes instead of letting llama-server refuse the request later. Backend: video_base64 on the chat request is forwarded whole as an input_video part, since llama-server owns the frame sampling and there is nothing useful to transcode. has_video_input rides the same path as has_audio_input out to the model row. Compare mode is left out on purpose: video_base64 targets the single loaded GGUF, so at most one side could answer. Dropping a clip there now says so rather than ignoring the file. Size caps line up across the three hops (64 MB in the desktop reader, in the composer and in the route) so no hop accepts what the next refuses. * Studio: carry the video capability through, and cover the passthrough path Three review findings, all correct. syncModelCapabilities took has_video_input but never copied it into the row, and /api/models/list omits it for the active GGUF, so the adapter read false after every load and refused video even when /props reported it. The feature did not work in its main path. The tool and response_format passthrough returns before the injection and forwards an explicit field list, so a clip rode along nowhere and the model answered without it. Refused now, the way audio already is there. The size cap floored the base64 inflation, so a clip of exactly the size the composer allows was refused with a 413, and the data URI header was counted against the payload. Padded ceiling, measured after stripping. * Studio: carry the video capability through every hop, and refuse it where it cannot be served Three separate places map backend capability flags onto a model row and each one dropped the video flag: the direct status adoption, the queued-run capability Pick, and (fixed earlier) syncModelCapabilities. The adapter reads that row, so any of them leaves video refused on a model that supports it. Covered by a rule rather than three spot checks. Injection lives in the GGUF branch, so an external provider or a local transformers model answered as if no clip were attached. Both now refuse, as does token counting, which cannot inject the frames it would need to count. The size check also moved ahead of the automatic model switch so an oversized clip does not evict a working model before the 413, and video now votes in the pre-switch projector requirement alongside audio. The video drain's read-failure toast said 'audio', inherited from the audio drain it was cloned from. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: name the attached modality in the pre-switch refusal Adding video to require_vision made the shared rejection reachable for a request carrying only a clip, but its text is fixed at 'image or audio input', so the user who attached a video was told about modalities the request never carried. The label now follows what is attached, and defaults to the existing wording so the image-only callers are unchanged. * Match the document-refusal test to the message it now returns * Send the API key on the /props readback and skip video in the context recount The /props probe went out without an Authorization header, so under UNSLOTH_DIRECT_STREAM=1 llama-server answered 401 and video capability never came back. Context recount already bails on images and audio because toOpenAIMessages has no branch for them; video has the same property and was missing the bail, so the usage bar priced a text-only prompt and stringified megabytes of base64 on the UI thread. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Send a picked clip under the container its extension names The accept list carries extensions as well as mime types because the browser's answer is unreliable for mkv and some mov files, and the picker takes those files on the extension. Only an empty type was being replaced, so a clip the browser called application/octet-stream kept that type into the attachment, and the request builder recognises a file part only when its mimeType matches ^video/. The clip was attached, sent and dropped, and the model answered as though nothing were there, which is the silent drop this PR exists to remove. The table mirrors the one in native_intents.rs, so a clip read by the desktop reader and one picked in the browser reach the route the same way. --------- Co-authored-by: shimmyshimmer <[email protected]> Co-authored-by: Unsloth <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: shimmyshimmer <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Unsloth <[email protected]> Co-authored-by: Daniel Han <[email protected]>
Fixes unslothai#17062 ## Why Chat refused any video over 64 MB, which is roughly 50 seconds of 720p. That number was picked when video input landed (unslothai#9057) so the composer, the route and the desktop reader agreed with each other. Nothing in the model path needs it: - llama-server picks frames by duration (fps sampling with per-model frame clamps), not by file size, so a bigger file does not mean more context. - Studio already re-encodes any clip larger than 640x360 to 640x360 at 4 fps before llama-server sees it. A 3 minute 720p clip at 8 Mbps (180 MiB) comes out at about 19 MiB. The real ceiling is llama-server's HTTP layer, which refuses request bodies over 100 MB (`CPPHTTPLIB_PAYLOAD_MAX_LENGTH` in its vendored cpp-httplib). The clip travels as base64 in JSON, so anything above about 74 MB that reaches llama-server untouched would fail there. ## What changes - The composer and the chat route accept clips up to 256 MB. Its base64 (about 341M characters) stays under the browser's maximum string length, and the request stays under Studio's default 500 MB body cap. - The pre-llama transcode also runs when a clip is larger than 64 MB, even if its frames are already small, so llama-server never gets a body near its 100 MB limit. Clips at or under 64 MB take exactly the same path as before. - After transcoding, the video payload going to llama-server (all clips in the request together) is checked against that 64 MB budget. A clip that could not be brought under it (failed or timed out transcode, or a very long clip) gets a clear 413 asking for a shorter clip instead of an opaque llama-server error. Anything that was valid on main (64 MB total) still fits. - A size-only re-encode (frames already small, frame rate already low) runs without a video filter, since ffmpeg refuses an empty `-vf`. Every refusal on this path also finalizes the API monitor entry. - The 413 messages and the tests that pinned 64 MB are updated, and tests cover a small-frame clip over the forward budget being transcoded, a clip still over budget after transcoding, and several clips over budget together. Nothing else in the UI or the flow moves: same attach button, same toasts, same one clip per message. Desktop drag-and-drop keeps its native reader cap (about 72 MB, shared with the video generation reference picker); the attach button in Desktop uses the webview picker and gets the new limit. ## Evidence Route functions (`_video_b64_rejection`, then `_shrink_clip_for_llama`) on synthetic clips, main vs this branch: | Clip | main | this branch | |---|---|---| | 180 MiB, 180 s, 1280x720 | 413 `Video file is too large (max 64 MB).` | accepted, forwarded 18.9 MiB (about 25 MiB of JSON) in 20 s | | 99 MiB, 20 s, 640x360 at 40 Mbps | 413 | accepted, transcoded to 13.9 MiB (without the new trigger it would have gone to llama-server as about 132 MB of JSON) | | 297 MiB, 60 s, 640x360 | 413 | 413 `Video file is too large (max 256 MB).` | The synthetic clips are noise-heavy, so real footage shrinks further. ## Testing - `node --test` on the video, native drop and reference size suites: 232 passing; `tsc --noEmit` clean - Backend: `test_video_pr9057_simulation.py` 68, `test_video_attachment_part.py` 32, `test_video_chat_completions_behaviour.py` 80, `test_llama_video_frame_budget.py` 41, `test_llama_video_ffmpeg.py` 20 (2 skipped, same as main), media decode suites 54, all passing - The new transcode test fails on main (the 99 MiB-style small-frame clip is forwarded untouched) and passes here ## Before / after A 99 MiB clip attached in the chat composer (no model loaded, so only the size check runs). Before: refused with a 64MB toast. After: it sits in the composer as an attachment. 

Stacked on #9056. Review that one first, this branch targets it so the diff stays clean.
Why
We could not attach or drop a video in chat, even though llama.cpp has supported it for a while. It takes video through its OpenAI-compatible chat endpoint as an
input_videocontent part:The catch is that it accepts one only when three things line up: the mmproj declares video, the binary was built with video support, and ffmpeg and ffprobe are installed on the machine. It reports that verdict at
GET /propsundermodalities.video. Nothing about the GGUF alone can tell us, so that is what we read rather than guessing.Frontend
VideoAttachmentAdaptertakes one clip per message, from the picker or from a drop. More than one is refused up front: llama-server expands a clip into a run of frames, so a batch would blow the context before reaching the model.Backend
video_base64on the chat request is forwarded whole as aninput_videopart. llama-server owns the frame sampling, so unlike audio there is nothing useful to transcode here.has_video_inputis read from the/propsmodalities at load and rides the same path out to the model row thathas_audio_inputalready takes.What is deliberately left out
Compare mode.
video_base64targets the single loaded GGUF, so at most one side of a compare could answer. Dropping a clip there now says that instead of ignoring the file.Size caps line up across the three hops, 64 MB in the desktop reader, in the composer and in the route, so no hop accepts what the next one refuses.
Testing
npm run typecheckclean,npm test2946 passingpytest tests/test_video_attachment_part.py7 passing, covering the part shape and the/propscapability readcargo checkcleanopenapi.jsonnow carriesChatCompletionRequest.video_base64,InferenceStatusResponse.has_video_inputandLoadResponse.has_video_inputEnd to end generation needs a video-capable mmproj plus ffmpeg on the box, which I did not have here, so that part rests on the wire shape and the capability gate rather than a live run.