Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: a stills review that finishes after the autonomous run was stopped or cancelled no longer clears stills or resumes production

[._.]/ Adam Eivy8473b03a5880
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index 605172984e..1b1291bbe6 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -1283,15 +1283,22 @@ async function settleStills(projectId, run, productionRunId) {
try {
await reviewOrPark(projectId, run, productionRunId);
} catch (err) {
- await park(projectId, 'needs-human', { error: trimTo(`The stills review failed: ${err.message}`, 500), errorCode: err.code || 'STILLS_REVIEW_FAILED' });
+ if (await ownsStillsReview(projectId, productionRunId)) await park(projectId, 'needs-human', { error: trimTo(`The stills review failed: ${err.message}`, 500), errorCode: err.code || 'STILLS_REVIEW_FAILED' });
} finally {
settlingStills.delete(productionRunId);
}
}
+/** A stop or cancel while the stills review was pending releases the run; its verdict must then change nothing. */
+async function ownsStillsReview(projectId, productionRunId) {
+ const latest = projectAutonomousRun(await getProject(projectId));
+ return latest?.status === 'running' && latest.processId === PROCESS_ID && latest.output?.productionRunId === productionRunId;
+}
+
async function reviewOrPark(projectId, run, productionRunId) {
if (isOrchestratedRun(run)) {
const regenerate = await reviewStills(projectId, run);
+ if (!await ownsStillsReview(projectId, productionRunId)) return;
if (regenerate.length) {
const fixes = new Map();
for (const issue of regenerate) fixes.set(issue.sceneId, [fixes.get(issue.sceneId), issue.text].filter(Boolean).join(' '));
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index efe1a8daf8..ebd7812266 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1466,6 +1466,27 @@ describe('orchestrated mode (brief.orchestrator)', () => {
expect(doubles.resumeProduction.mock.calls[0][2].stopBefore).toBeUndefined();
});
+ // Uniquely catches a cancel during the pending stills review being undone by its verdict (clearing stills, resuming production, spending).
+ it('ignores a stills verdict that lands after the run was cancelled', async () => {
+ await service.startAutonomousVideo({ prompt: 'p', tools: ['image:local'], orchestrator: ORCHESTRATOR }, { autoApproveAuthorized: true });
+ await vi.waitFor(() => expect(doubles.startProduction).toHaveBeenCalledOnce());
+ store.get('mv-auto').scenes = [{ sceneId: 'mvs-a', label: 'Intro', framePrompt: 'a skater', referenceImageId: 'a1.png' }];
+ let release;
+ doubles.orchestrate.mockImplementation(() => new Promise((resolve) => { release = () => resolve({
+ text: JSON.stringify({ verdict: 'revise', score: 4, notes: 'Bad.', issues: [{ sceneId: 'mvs-a', text: 'wrong' }] }),
+ route: { providerId: 'orch', model: 'judge' }, visual: true }); }));
+ doubles.resumeProduction.mockClear();
+ doubles.orchestrate.mockClear();
+ const settling = service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'awaiting-video' } });
+ await vi.waitFor(() => expect(doubles.orchestrate).toHaveBeenCalled());
+ await service.cancelAutonomousVideo('mv-auto');
+ release();
+ await settling;
+ expect(runOf().status).toBe('canceled');
+ expect(doubles.resumeProduction).not.toHaveBeenCalled();
+ expect(store.get('mv-auto').scenes[0].referenceImageId).toBe('a1.png');
+ });
+
// Uniquely catches the orchestrator approving art or a storyboard it still wants changed once its revisions run out.
it('parks for the director with the open changes named when a production gate runs out of revisions', async () => {
creativeReview.real = true;