Video tab: Generate-all button to queue every scene's clip in sequence
Queues clips one POST at a time in timeline order rather than a single all-scenes request: the H3 prompt rewrite runs synchronously inside each generate-videos request (~1-3 min per scene on local models), so one bulk request for a long timeline would sit for many minutes and risk a client timeout. The label is state-aware - 'Generate all (n)' targets only scenes without a clip (skipping done and in-flight scenes), flipping to 'Regenerate all' when the timeline is complete. A scene that fails to queue toasts and the loop continues. Rendering itself stays serialized by the queue worker. Workflow resolution matches the per-scene Generate button (session pick -> scene's stored workflow -> first enabled video workflow), which also heals scenes whose stored workflow was deleted - without it they enqueue a job doomed to 'No workflow found for job'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
152234ac9b
commit
d243e0a1ab
@@ -136,6 +136,61 @@
|
||||
onError: (err) => toast.error(err instanceof Error ? err.message : String(err)),
|
||||
});
|
||||
|
||||
// --- Batch generate: queue clips one by one, in timeline order. ---
|
||||
// One POST per scene (the H3 prompt rewrite runs synchronously inside each
|
||||
// request, so a single all-scenes POST could take minutes and time out).
|
||||
// The queue worker then renders them strictly in sequence (concurrency 1).
|
||||
let batching = $state(false);
|
||||
let batchNote = $state('');
|
||||
|
||||
const scenesNeedingClip = $derived(
|
||||
scenes.filter((s) => !['done', 'pending', 'running'].includes(statusOf(s))),
|
||||
);
|
||||
const batchTargets = $derived(
|
||||
scenesNeedingClip.length > 0
|
||||
? scenesNeedingClip
|
||||
: scenes.filter((s) => !['pending', 'running'].includes(statusOf(s))),
|
||||
);
|
||||
const batchLabel = $derived(
|
||||
batching
|
||||
? batchNote
|
||||
: scenesNeedingClip.length > 0
|
||||
? `Generate all (${scenesNeedingClip.length})`
|
||||
: 'Regenerate all',
|
||||
);
|
||||
|
||||
async function generateAll() {
|
||||
if (batching || batchTargets.length === 0) return;
|
||||
batching = true;
|
||||
let queued = 0;
|
||||
const targets = [...batchTargets].sort((a, b) => a.order_index - b.order_index);
|
||||
for (let i = 0; i < targets.length; i++) {
|
||||
const scene = targets[i];
|
||||
batchNote = `Queueing ${i + 1}/${targets.length}…`;
|
||||
try {
|
||||
// Resolve like the per-scene button does: session pick → scene's stored
|
||||
// workflow → first enabled video workflow. A scene whose stored workflow
|
||||
// was deleted would otherwise enqueue a job doomed to "No workflow found".
|
||||
await jobsApi.generateVideos(projectId, {
|
||||
scene_ids: [scene.id],
|
||||
workflow_id: workflowFor(scene)?.id,
|
||||
});
|
||||
queued++;
|
||||
client.invalidateQueries({ queryKey: ['jobs'] });
|
||||
client.invalidateQueries({ queryKey: ['scenes'] });
|
||||
} catch (err) {
|
||||
toast.error(
|
||||
`Scene #${scene.order_index}: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
batching = false;
|
||||
batchNote = '';
|
||||
if (queued > 0) toast.success(`${queued} clip${queued === 1 ? '' : 's'} queued — rendering in sequence`);
|
||||
await client.invalidateQueries({ queryKey: ['jobs'] });
|
||||
await client.invalidateQueries({ queryKey: ['scenes'] });
|
||||
}
|
||||
|
||||
function workflowFor(scene: Scene): Workflow | undefined {
|
||||
const id = selectedWorkflow[scene.id] ?? scene.workflow_id ?? undefined;
|
||||
return enabledWorkflows.find((w) => w.id === id) ?? enabledWorkflows[0] ?? undefined;
|
||||
@@ -345,6 +400,17 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
{#if scenes.length > 0}
|
||||
<Button
|
||||
variant="primary"
|
||||
disabled={batching || batchTargets.length === 0}
|
||||
loading={batching}
|
||||
title="Queue every scene's clip in timeline order; the worker renders them one at a time"
|
||||
onclick={generateAll}
|
||||
>
|
||||
<Icon name="film" size={14} /> {batchLabel}
|
||||
</Button>
|
||||
{/if}
|
||||
<Button variant="secondary" onclick={togglePause}>
|
||||
{$queueStatusQuery.data?.paused ? 'Resume queue' : 'Pause queue'}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user