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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: retain generated candidates and report persisted scene outcomes (#11218)
Adam Eivy1d83d104a1ef
diff --git a/server/services/musicVideo/planner.js b/server/services/musicVideo/planner.jsindex fa26c5813d..181694717f 100644--- a/server/services/musicVideo/planner.js+++ b/server/services/musicVideo/planner.js@@ -427,11 +427,11 @@ export async function planProject(id, { seedPrompts = true, providerId, model, econst hasCards = sceneInputs.some((s) => s.visualLayer === 'card');// Persist card scenes and the mode that renders them in the same transaction.// Read the current composition under the lock so concurrent edits survive.- const { project: persisted, scenes } = await persistPlan(id, sceneInputs, { hasCards, replace: mode === 'replace' });+ const { project: persisted, scenes, rejected } = await persistPlan(id, sceneInputs, { hasCards, replace: mode === 'replace' });// Only a project with an automation brief keeps the route it planned on.const updated = (persisted.automation && await recordLlmRoute(id, 'plan', llmRoute)) || persisted;console.log(`🪄 Music Video plan: seeded ${scenes.length} scene${scenes.length === 1 ? '' : 's'} for ${id} (prompts ${promptsSeeded ? 'seeded' : `skipped: ${promptsSkippedReason || 'n/a'}`})`);- return { project: updated, scenesAdded: scenes.length, promptsSeeded, promptsSkippedReason, pacing, llmRoute };+ return { project: updated, scenesAdded: rejected ? 0 : scenes.length, promptsSeeded, promptsSkippedReason, pacing, llmRoute };}const castSets = (project) => (project.castAndSets?.status === 'skipped' ? null : project.castAndSets?.direction?.sets) || [];diff --git a/server/services/musicVideo/productionReview.js b/server/services/musicVideo/productionReview.jsindex 5ed5745458..e4ab89f659 100644--- a/server/services/musicVideo/productionReview.js+++ b/server/services/musicVideo/productionReview.js@@ -148,7 +148,7 @@ export function shotLocks(project) {export function preserveAutomatedShotLocks(before, after, source) {const locks = shotLocks(before) || {};const locked = (before.scenes || []).filter(scene => locks[scene.sceneId] === 'locked');- if (!locked.length) return after;+ if (!locked.length) return { project: after, rejected: false };const rejected = locked.filter(scene => {const proposed = after.scenes?.find(next => next.sceneId === scene.sceneId);return !proposed || shotApprovalBasis(before, scene) !== shotApprovalBasis(after, proposed);@@ -159,10 +159,13 @@ export function preserveAutomatedShotLocks(before, after, source) {for (const scene of locked) shotApprovals[scene.sceneId] = before.productionReview?.shotApprovals?.[scene.sceneId]|| { ...before.productionReview?.approvals?.storyboard, basis: shotApprovalBasis(before, scene), fromBoardApproval: true };let next = { ...after, productionReview: { ...after.productionReview, shotApprovals } };- if (!rejected.length) return next;+ if (!rejected.length) return { project: next, rejected: false };// A merge/re-plan may replace IDs or spans. Refuse the whole board mutation// rather than splice an old locked shot into an overlapping new timeline.- next = { ...next, scenes: before.scenes, productionReview: { ...next.productionReview,+ next = { ...next, scenes: before.scenes.map(scene => {+ const output = after.scenes?.find(candidate => candidate.sceneId === scene.sceneId);+ return output ? { ...scene, takes: output.takes, videoHistoryId: output.videoHistoryId } : scene;+ }), productionReview: { ...next.productionReview,draft: before.productionReview?.draft } };for (const scene of rejected) {const proposed = after.scenes?.find(next => next.sceneId === scene.sceneId);@@ -171,7 +174,7 @@ export function preserveAutomatedShotLocks(before, after, source) {text: `${source} proposed changing locked shot ${scene.sceneId}; unlock it before applying this proposal. ${JSON.stringify({ scene: proposed || null,storyboard: after.productionReview?.draft?.storyboard?.find(row => row.sceneId === scene.sceneId) || null }).slice(0, 6000)}` });}- return next;+ return { project: next, rejected: true };}/** Lock or unlock Board shots for the director. A lock binds to the shot as it is now. */diff --git a/server/services/musicVideo/projects.js b/server/services/musicVideo/projects.jsindex 74e4f66c69..e8388080a0 100644--- a/server/services/musicVideo/projects.js+++ b/server/services/musicVideo/projects.js@@ -290,6 +290,11 @@ export async function mergeProjectNextScene(id, sceneId, options = {}) {// Append candidate takes to one scene: `{ scene, appended }`. A take fills its// slot only while the slot is empty — never replaces a selection (takes.js).export async function appendSceneTakes(id, sceneId, inputs) {+ if (inputs.some(input => input.source === 'generated')) {+ const { appendSceneTakes: append } = await import('./takes.js');+ const outcome = await mutateProjectRecord(id, current => append(current, sceneId, inputs), { source: 'generation-completion' });+ return { scene: outcome.project.scenes.find(scene => scene.sceneId === sceneId), appended: outcome.appended };+ }const result = await (await selectBackend()).appendSceneTakes(id, sceneId, inputs);emitRecordUpdated('musicVideoProject', id);return result;@@ -335,7 +340,17 @@ export async function mutateProjectRecord(id, transform, { source = null } = {})const { preserveAutomatedShotLocks } = source ? await import('./productionReview.js') : {};const outcome = await (await selectBackend()).mutateProjectRecord(id, (current) => {const outcome = transform(current);- if (source) outcome.project = preserveAutomatedShotLocks(current, outcome.project, source);+ if (source) {+ const guarded = preserveAutomatedShotLocks(current, outcome.project, source);+ outcome.project = guarded.project;+ if (guarded.rejected) {+ outcome.rejected = true;+ if (outcome.scenes) outcome.scenes = guarded.project.scenes;+ if (outcome.scene) outcome.scene = guarded.project.scenes.find(scene => scene.sceneId === outcome.scene.sceneId) || null;+ if (outcome.updated) outcome.updated = guarded.project.scenes.find(scene => scene.sceneId === outcome.updated.sceneId) || null;+ if ('replaced' in outcome) outcome.replaced = 0;+ }+ }return { ...outcome, project: retainMusicVideoDependencies(current, outcome.project) };});emitRecordUpdated('musicVideoProject', id);diff --git a/server/services/musicVideo/projects.test.js b/server/services/musicVideo/projects.test.jsindex 714466847f..b2ac385457 100644--- a/server/services/musicVideo/projects.test.js+++ b/server/services/musicVideo/projects.test.js@@ -274,6 +274,8 @@ describe('automation respects persisted shot locks (#11218)', () => {expect(revised.project.productionReview.draft.storyboard[0].action).toBe('Stay');const replaced = await projects.mutateProjectRecord(p.id, current => replaceScenes(current, [{ startSec: 0, endSec: 2, prompt: 'New span' }]), { source: 'shot-planner' });expect(replaced.project.scenes.map(s => s.sceneId)).toEqual([scene.sceneId]);+ expect(replaced).toMatchObject({ rejected: true, replaced: 0 });+ expect(replaced.scenes).toEqual((await projects.getProject(p.id)).scenes);expect(shotLocks(await projects.getProject(p.id))[scene.sceneId]).toBe('locked');expect(replaced.project.productionReview.feedback).toHaveLength(2);});@@ -285,6 +287,10 @@ describe('automation respects persisted shot locks (#11218)', () => {await projects.mutateProjectRecord(p.id, current => ({ project: setShotLocks(current, { sceneIds: [scene.sceneId], locked: true }) }));const repair = await projects.mutateProjectRecord(p.id, current => ({ project: { ...current, scenes: current.scenes.map(s => ({ ...s, clipFixes: { text: 'New motion' } })) } }), { source: 'orchestrator' });expect(repair.project.scenes[0].clipFixes).toBeUndefined();+ const frame = await projects.appendSceneTakes(p.id, scene.sceneId, [{ kind: 'image', assetId: 'candidate.png', source: 'generated' }]);+ expect(frame.scene.referenceImageId).toBeNull();+ expect(frame.scene.takes.some(take => take.assetId === 'candidate.png')).toBe(true);+ expect(shotLocks(await projects.getProject(p.id))[scene.sceneId]).toBe('locked');const clip = await projects.mutateProjectRecord(p.id, current => ({ project: { ...current, scenes: current.scenes.map(s => ({ ...s, videoHistoryId: 'new-clip' })) } }), { source: 'production-run' });expect(clip.project.scenes[0].videoHistoryId).toBe('new-clip');expect(shotLocks(clip.project)[scene.sceneId]).toBe('locked');