chore(video,audio): auto-delete server media on retrieve - #9
Open
aispace-bot wants to merge 2 commits into
Open
Conversation
Video and music generation were stuck showing "Queued — waiting for a
slot" / "Generating..." indefinitely. Two bugs in the same polling
path, both of which had to be fixed for generation to work end-to-end:
1. Wrong retrieve payload -> 400 "Model is required"
The /video/retrieve and /audio/retrieve endpoints require
{ model, queue_id } in the request body, but the polling code sent
{ id } — wrong field name and missing model. Every poll returned
400 {"error":"Model is required"}, and because the catch block
swallowed all errors for up to ~10 minutes (200 attempts), the UI
spun on "Queued" instead of surfacing the real error.
Fix: track `model` from the /queue response and send
{ model, queue_id } on retrieve. Surface permanent 4xx client
errors immediately instead of retrying them behind a spinner.
Applied to use-video.ts, use-music.ts, and the shared
pollUntilDone helper in workflow-engine.ts.
2. Binary response misread as JSON once generation finished
When a non-VPS model completes, /video/retrieve and /audio/retrieve
return the finished media as a binary body (video/mp4 / audio/mpeg),
not JSON. The code called res.json() unconditionally, so the moment
a job completed the response was misread as garbled text and the
poller kept spinning — the completed media was never picked up.
Fix: grab the raw Response via veniceFetch and branch on
Content-Type. Non-JSON -> the body is the finished media; create a
blob URL and stop polling. application/json -> parse and handle
PROCESSING / COMPLETED (VPS-backed models return a download_url at
queue time) / FAILED. Applied to use-video.ts, use-music.ts, and
pollUntilDone (covers video and music workflow nodes).
Also: export veniceFetch from the client (previously internal); add
download_url? to VideoQueueResponse (VPS-backed models); revoke blob
URLs on cancel/reset in both use-video.ts and use-music.ts to avoid
memory leaks.
Verified end-to-end for video: generation progresses queued ->
processing -> completed and the video renders and plays. Audio uses
the identical polling pattern and now handles the binary response.
Closes nikshepsvn#5
Co-authored-by: Cursor <cursoragent@cursor.com>
Per the Venice API docs, /video/retrieve and /audio/retrieve accept a `delete_media_on_completion: true` flag that finalizes the job and deletes the media from Venice storage the moment the retrieve succeeds and returns the binary. This is the documented shortcut for skipping the separate /video/complete and /audio/complete calls. The app never called the complete endpoints, so completed media lingered on Venice's servers. Adding the flag to each retrieve request makes the cleanup atomic with the download — no extra network call, no extra error handling, no leftover media. Applied to all three retrieve call sites: - src/hooks/use-video.ts (Video tab) - src/hooks/use-music.ts (Music tab) - src/lib/workflow-engine.ts (pollUntilDone — video + music nodes) Stacked on nikshepsvn#8; merge nikshepsvn#8 first. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Adds
delete_media_on_completion: trueto every/video/retrieveand/audio/retrievecall so completed media is automatically deleted from Venice storage the moment it's downloaded — instead of lingering indefinitely.Per the Venice API docs, this flag is the documented shortcut for skipping the separate
/video/completeand/audio/completefinalization calls. It makes cleanup atomic with the download: no extra network call, no extra error handling, no leftover server-side media.Context
This is a cleanup/etiquette fix, not a functional bug. Video and audio generation already work end-to-end after #8. The app was simply never finalizing jobs, so completed media piled up on Venice's servers. This PR closes that gap with a single flag per retrieve call.
Stacking note
Stacked on #8 — merge #8 first. Until #8 merges, this PR's diff includes both the retrieve-polling fix and this cleanup. Once #8 merges upstream, GitHub auto-rebases this branch and the diff shrinks to just the one-line-per-file cleanup commit.
Changes
src/hooks/use-video.ts—delete_media_on_completion: trueon the/video/retrievecallsrc/hooks/use-music.ts—delete_media_on_completion: trueon the/audio/retrievecallsrc/lib/workflow-engine.ts—delete_media_on_completion: trueon the sharedpollUntilDoneretrieve (covers video + music workflow nodes)Test plan