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
Fill a scene's empty clip slot with a supplied-audio take
Claudecc23f9be62d8
diff --git a/server/services/musicVideo/takes.js b/server/services/musicVideo/takes.jsindex 7f6be493c9..74cfd680ad 100644--- a/server/services/musicVideo/takes.js+++ b/server/services/musicVideo/takes.js@@ -124,11 +124,14 @@ function replaceScene(project, idx, scene) {* or a re-import is a no-op for the list). A slot is filled only while it is* empty, by the first appended take of that kind; an existing selection is* never replaced, and a motion-reference take (#8980) never fills a slot — it- * becomes final picture only by an explicit select. Returns+ * becomes final picture only by an explicit select. A take already stale+ * against the whole PROJECT (its plate, timing, or for a supplied-audio take+ * the song master/lyrics) does not fill either; the check needs the real+ * project, since a song reference reads the project's song fields. Returns* `{ scene, appended }` — `appended` lists the take for every input, whether* newly created or already present.*/-function appendToScene(scene, inputs, now) {+function appendToScene(project, scene, inputs, now) {let takes = ensureSceneTakes(scene, now);const next = { ...scene };const appended = [];@@ -139,7 +142,7 @@ function appendToScene(scene, inputs, now) {if (!existing) takes = [...takes, take];appended.push(take);const field = TAKE_SLOT[input.kind];- if (!isNonBlankStr(next[field]) && take.status !== 'rejected' && take.use !== 'motion-reference' && !musicVideoTakeChanges({ scenes: [scene] }, scene, take).length) next[field] = take.assetId;+ if (!isNonBlankStr(next[field]) && take.status !== 'rejected' && take.use !== 'motion-reference' && !musicVideoTakeChanges(project, scene, take).length) next[field] = take.assetId;}next.takes = pruneTakes(takes, next);// A take landing for the lane a failure was recorded against is the retry@@ -172,7 +175,7 @@ export function setSceneLastFailure(project, sceneId, failure) {export function appendSceneTakes(project, sceneId, inputs) {for (const input of inputs) assertMusicVideoMedia(project, input.kind, 'take import');const idx = findSceneIndex(project, sceneId);- const { scene, appended } = appendToScene(project.scenes[idx], inputs, new Date().toISOString());+ const { scene, appended } = appendToScene(project, project.scenes[idx], inputs, new Date().toISOString());return { project: replaceScene(project, idx, scene), scene, appended };}@@ -196,7 +199,7 @@ export function appendTakesAcrossScenes(project, items) {const scenes = project.scenes.map((scene) => {const entries = bySceneId.get(scene.sceneId);if (!entries) return scene;- const result = appendToScene(scene, entries.map((e) => e.item), now);+ const result = appendToScene(project, scene, entries.map((e) => e.item), now);entries.forEach((e, i) => { appended[e.index] = { sceneId: scene.sceneId, take: result.appended[i] }; });return result.scene;});diff --git a/server/services/musicVideo/takes.test.js b/server/services/musicVideo/takes.test.jsindex 3efb14b755..35ac454418 100644--- a/server/services/musicVideo/takes.test.js+++ b/server/services/musicVideo/takes.test.js@@ -1,5 +1,6 @@import { describe, expect, it } from 'vitest';import { appendSceneTakes } from './takes.js';+import { captureMusicVideoEvidence, captureTakeDependencies } from '../../lib/musicVideoDependencies.js';const project = () => ({ id: 'mv-1', scenes: [{ sceneId: 's1' }] });@@ -18,3 +19,32 @@ describe('take generation cost (#10157)', () => {expect(appended[3]).not.toHaveProperty('costUsd');});});++describe('supplied-audio take fills an empty slot', () => {+ // A supplied-audio clip records the song master as a dependency; the+ // slot-fill staleness check must read it against the real project, not a+ // scene-only stub (which made every such take look stale and stay candidate).+ const songProject = () => ({+ id: 'mv-1', trackId: 'track-1', lyricCues: [{ id: 'c1', text: 'Example line', startSec: 1, endSec: 2 }],+ scenes: [{ sceneId: 's1', startSec: 1, endSec: 4, referenceImageId: 'plate.png' }],+ });+ const takeFor = (project) => {+ const dependencies = captureTakeDependencies(project.scenes[0], 'plate.png');+ dependencies.references.push(...captureMusicVideoEvidence(project, { sceneIds: [], composition: false }).references);+ return { kind: 'video', assetId: 'clip-1', source: 'generated', sourceImageId: 'plate.png', dependencies };+ };++ it('selects the first current take', () => {+ const project = songProject();+ const { scene } = appendSceneTakes(project, 's1', [takeFor(project)]);+ expect(scene.videoHistoryId).toBe('clip-1');+ });++ it('leaves the slot empty when the song changed after the clip was submitted', () => {+ const project = songProject();+ const input = takeFor(project);+ const { scene } = appendSceneTakes({ ...project, lyricCues: [] }, 's1', [input]);+ expect(scene.videoHistoryId).toBeUndefined();+ expect(scene.takes.at(-1).status).toBe('candidate');+ });+});