Skip to content

chore(video,audio): auto-delete server media on retrieve - #9

Open
aispace-bot wants to merge 2 commits into
nikshepsvn:masterfrom
aispace-bot:fix/video-audio-complete-cleanup
Open

chore(video,audio): auto-delete server media on retrieve#9
aispace-bot wants to merge 2 commits into
nikshepsvn:masterfrom
aispace-bot:fix/video-audio-complete-cleanup

Conversation

@aispace-bot

Copy link
Copy Markdown

Summary

Adds delete_media_on_completion: true to every /video/retrieve and /audio/retrieve call 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/complete and /audio/complete finalization 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.tsdelete_media_on_completion: true on the /video/retrieve call
  • src/hooks/use-music.tsdelete_media_on_completion: true on the /audio/retrieve call
  • src/lib/workflow-engine.tsdelete_media_on_completion: true on the shared pollUntilDone retrieve (covers video + music workflow nodes)

Test plan

  • Video tab: generate a video — confirm it still completes and plays (no behavior change; the flag only affects server-side cleanup)
  • Music tab: generate a track — confirm it still completes and plays
  • Workflow video/music node: confirm completion still works
  • (Optional) Check Venice dashboard / API that completed jobs no longer leave media in storage

aispace-bot and others added 2 commits July 4, 2026 12:03
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant