Skip to content

Open source CapCut alternative.

TypeScript

fix(site): the boot sweep re-checks its guards after the doc fetch so a run never gets two orchestrators

David Leb30b02674299
diff --git a/site/src/cut/lib/genScene.ts b/site/src/cut/lib/genScene.ts
index f635e20d..1141c2b7 100644
--- a/site/src/cut/lib/genScene.ts
+++ b/site/src/cut/lib/genScene.ts
@@ -121,6 +121,10 @@ async function resumeBackgroundRuns(): Promise<void> {
const doc = (await docRes.json()) as { genvideo?: VideoProject | null };
const plan = doc.genvideo;
if (!plan || plan.phase === "done" || plan.phase === "failed" || !plan.breakdownApproved) continue;
+ // Re-check both guards after the awaits: the user may have opened this
+ // project mid-fetch, and its own load then hydrates an orchestrator —
+ // a second one here would render (and bill) every shot twice.
+ if (orchestrators.has(p.id) || useEditor.getState().projectId === p.id) continue;
const orch = buildOrchestrator(p.id, plan);
orchestrators.set(p.id, orch);
orch.run().then(settled(p.id, orch)).catch(failed(p.id, orch));