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: the autopilot stills review records approval only when every still was seen and nothing is left open

[._.]/ Adam Eivy6955d369f657
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index 1b1291bbe6..9845ac5b6c 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -1240,6 +1240,7 @@ async function reviewStills(projectId, run) {
const shots = (project.scenes || []).filter((scene) => scene.referenceImageId);
const issues = [];
const reviews = [];
+ let shown = 0;
for (let i = 0; i < shots.length; i += STILLS_BATCH) {
const listed = [];
const images = [];
@@ -1252,6 +1253,7 @@ async function reviewStills(projectId, run) {
cast: project.productionReview?.draft?.cast || '',
shots: listed.map((scene, n) => ({ image: n + 1, sceneId: scene.sceneId, label: scene.label || '', still: trimTo(scene.framePrompt || scene.prompt, 400) })) }), images);
reviews.push(review);
+ if (review.visual) shown += listed.length;
// A review that could not see the stills cannot judge them.
const known = new Set(listed.map((scene) => scene.sceneId));
if (review.visual && review.verdict === 'revise') issues.push(...review.issues.filter((issue) => known.has(issue.sceneId)));
@@ -1259,13 +1261,16 @@ async function reviewStills(projectId, run) {
const spent = revisionsSpent(await latestRun(projectId), 'stills');
const regenerate = spent < reviewLimit(run) ? issues : [];
const scored = reviews.map((r) => r.score).filter((n) => n != null);
+ // Approval needs every still seen and nothing flagged; an inconclusive or unresolved round is not one.
+ const conclusive = shots.length > 0 && shown === shots.length;
+ const unresolved = issues.length > 0 && !regenerate.length;
const why = !reviews.length ? 'No still could be shown to the reviewer. '
: reviews.some((r) => !r.visual) ? 'The reviewer could not see every still. '
- : issues.length && !regenerate.length ? 'Revision limit reached; accepted the latest stills. ' : '';
- await recordReview(projectId, { checkpoint: 'stills', verdict: regenerate.length ? 'revise' : 'approve',
+ : unresolved ? 'Revision limit reached with changes still open. ' : '';
+ await recordReview(projectId, { checkpoint: 'stills', verdict: regenerate.length || unresolved || !conclusive ? 'revise' : 'approve',
score: scored.length ? Math.min(...scored) : null, route: reviews.at(-1)?.route || null, visual: reviews.length > 0 && reviews.every((r) => r.visual),
notes: trimTo(`${why}${regenerate.length ? `Regenerating ${regenerate.length} still${regenerate.length === 1 ? '' : 's'}. ` : ''}${reviews.map((r) => r.notes).filter(Boolean).join(' ')}`, 1500),
- ...(regenerate.length ? { changes: regenerate.map((issue) => trimTo(`${issue.sceneId}: ${issue.text}`, 300)) } : {}) });
+ ...(regenerate.length || unresolved ? { changes: (regenerate.length ? regenerate : issues).map((issue) => trimTo(`${issue.sceneId}: ${issue.text}`, 300)) } : {}) });
return regenerate;
}
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index ebd7812266..00d0cbf4c7 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1466,6 +1466,17 @@ describe('orchestrated mode (brief.orchestrator)', () => {
expect(doubles.resumeProduction.mock.calls[0][2].stopBefore).toBeUndefined();
});
+ // Uniquely catches an unviewable still being recorded as an approved review while the run still waits for the director.
+ it('does not record approval for stills the reviewer could not see', 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' }];
+ doubles.galleryImagePath.mockRejectedValue(new Error('missing'));
+ await service.__testing.onProductionEvent({ projectId: 'mv-auto', runId: 'mvpr-1', run: { status: 'awaiting-video' } });
+ expect(reviews().filter((r) => r.startsWith('stills'))).toEqual(['stills:revise']);
+ expect(runOf()).toMatchObject({ status: 'awaiting-approval', awaiting: 'stills' });
+ });
+
// 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 });