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

Music Video: render code shots as a black ground and keep them code end to end (#10299)

[._.]/3b599c86a698
diff --git a/client/src/components/musicVideo/ProjectActionGroups.jsx b/client/src/components/musicVideo/ProjectActionGroups.jsx
index e86855e22e..fa5b67c9b1 100644
--- a/client/src/components/musicVideo/ProjectActionGroups.jsx
+++ b/client/src/components/musicVideo/ProjectActionGroups.jsx
@@ -2,7 +2,7 @@ import { useState } from 'react';
import LlmRouteNote from './LlmRouteNote.jsx';
import { Film, Music, Activity, Image as ImageIcon, Video, Wand2, X } from 'lucide-react';
import { MUSCRIPTOR_MODELS } from '../../lib/muscriptorModels.js';
-import { isLayeredComposition, sceneRenderReady, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
+import { isLayeredComposition, isSelfDrawnLayer, sceneRenderReady, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
import { compositionDraft, RENDER_STYLES } from './compositionDraft.js';
import { projectServicesSummary } from '../../lib/musicVideoStages.js';
import { batchActive, batchSummary, scenesWaitingForFrame, videoBatchPreview, videosButtonLabel } from '../../lib/musicVideoBatchPlan.js';
@@ -146,7 +146,7 @@ export function GenerationActions({ project, videoSettings, sceneMedia, onEditSe
const mode = project.composition?.mode || 'concat';
const layered = isLayeredComposition(project);
const codeMode = mode === 'code' || mode === 'eidoverse';
- const frameScenes = scenes.filter((scene) => !['card', 'code'].includes(sceneVisualLayer(scene, { layered })));
+ const frameScenes = scenes.filter((scene) => !isSelfDrawnLayer(sceneVisualLayer(scene, { layered })));
const footageScenes = scenes.filter((scene) => sceneVisualLayer(scene, { layered }) === 'footage');
const referenceFrameCount = frameScenes.filter((scene) => scene.referenceImageId).length;
const renderableSceneCount = footageScenes.filter((scene) => scene.videoHistoryId).length;
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index dda5f0d076..e2d9fa47ba 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -44,8 +44,10 @@ const SCENE_TIME_FIELDS = [['Start', 'startSec'], ['End', 'endSec']];
* same for an existing gallery clip.
*
* The layer picker (#8985) chooses what a composed render (`layered`) shows
- * for the scene's span: its footage, its selected frame with a camera move, or
- * a title card. A plain render always plays footage, and says so.
+ * for the scene's span: its footage, its selected frame with a camera move, a
+ * title card, or a code shot the composition draws (#10297; no frame or clip
+ * controls — and, unless `documentComposition`, a note that a composed render
+ * shows it as a black frame). A plain render always plays footage, and says so.
* The shot mode (#8977) picks Cutaway (any image-to-video lane) or Performance
* (a singer lip-synced to the master recording). `lipSyncBackend` is the lane a
* render would use ('' = install default); a performance shot on a lane without
@@ -69,7 +71,7 @@ export default function SceneCard({
settingsSaving, videoBlockedReason, canContinueShot,
onMove, onDelete, onEditLocal, onSave,
onGenerateFrame, onGenerateVideo, onContinueVideo,
- onOpenPreview, onSelectTake, onReviewTake, onImportTake, onImportClipTake, takeBusy = false, layered = false,
+ onOpenPreview, onSelectTake, onReviewTake, onImportTake, onImportClipTake, takeBusy = false, layered = false, documentComposition = false,
lipSyncBackend = '', songDurationSec = null, onSplit, falVideoSettings = null, onSeek, performanceReview = null, onRepairPerformance, repairBusy = false,
expanded, onToggleExpand, footageOptional = false, failedScenes = null,
}) {
@@ -110,6 +112,8 @@ export default function SceneCard({
const applyPatch = (patch) => { onEditLocal(scene.sceneId, patch); onSave(scene.sceneId, patch); };
const layer = MUSIC_VIDEO_VISUAL_LAYERS.includes(scene.visualLayer) ? scene.visualLayer : 'footage';
const fieldId = (name) => `mv-scene-${scene.sceneId}-${name}`;
+ // #10297: a code shot is drawn by the composition, so it has no frame or clip to make.
+ const codeShot = layered && layer === 'code';
const performance = isPerformanceScene(scene);
const capability = performance ? performanceCapability(lipSyncBackend) : null;
const timedSpan = typeof scene.startSec === 'number' && typeof scene.endSec === 'number' && scene.endSec > scene.startSec
@@ -358,6 +362,12 @@ export default function SceneCard({
className="rounded bg-port-bg border border-port-border px-2 py-1 min-h-[44px] sm:min-h-0 text-port-text">Loop clip</button>
</div>
)}
+ {codeShot ? (
+ <p className="text-xs text-port-text-muted" data-testid="code-shot-note">
+ The composition draws this shot, so it needs no frame or clip.
+ {!documentComposition && ' A composed render shows it as a black frame under the typography; render from a composition document to draw it.'}
+ </p>
+ ) : (<>
{/* Reference frame — the still image that seeds this shot (Phase 1b) */}
<div className="flex flex-col gap-2 sm:flex-row sm:items-start">
<textarea
@@ -482,6 +492,7 @@ export default function SceneCard({
onSelect={(take) => onSelectTake?.(scene, take)}
onReview={(take, review) => onReviewTake?.(scene, take, review)}
onOpenPreview={onOpenPreview} />
+ </>)}
</div>
</details>
{failure && (
diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsx
index f2c7ad7cdb..b1bc2acd08 100644
--- a/client/src/components/musicVideo/SceneCard.test.jsx
+++ b/client/src/components/musicVideo/SceneCard.test.jsx
@@ -4,6 +4,24 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
vi.mock('../../hooks/useVideoFileSrc.js', () => ({ useVideoFileSrc: () => ({}) }));
import SceneCard from './SceneCard.jsx';
+describe('code shot (#10297)', () => {
+ it('offers no frame or clip generation for a code shot in a layered composition', () => {
+ const scene = { sceneId: 's1', visualLayer: 'code', startSec: 0, endSec: 5, takes: [] };
+ const { rerender } = render(<SceneCard scene={scene} index={0} layered onEditLocal={() => {}} onSave={() => {}} />);
+ expect(screen.getByTestId('code-shot-note').textContent).toMatch(/needs no frame or clip/);
+ // A composed render has no code to run, so it says the shot will be black there.
+ expect(screen.getByTestId('code-shot-note').textContent).toMatch(/composed render shows it as a black frame/);
+ expect(screen.queryByRole('button', { name: 'Generate frame' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Generate video' })).toBeNull();
+ rerender(<SceneCard scene={scene} index={0} layered documentComposition onEditLocal={() => {}} onSave={() => {}} />);
+ expect(screen.getByTestId('code-shot-note').textContent).not.toMatch(/black frame/);
+ // A plain render plays footage, so the generation controls come back.
+ rerender(<SceneCard scene={scene} index={0} layered={false} onEditLocal={() => {}} onSave={() => {}} />);
+ expect(screen.queryByTestId('code-shot-note')).toBeNull();
+ expect(screen.getByRole('button', { name: 'Generate frame' })).toBeTruthy();
+ });
+});
+
describe('performance speaker save boundary', () => {
it('keeps paid generation disabled until the speaker edit is saved, including a failed save', async () => {
let settle;
diff --git a/client/src/components/musicVideo/TreatmentApplyReview.jsx b/client/src/components/musicVideo/TreatmentApplyReview.jsx
index f4ed63968f..7b5a2f0598 100644
--- a/client/src/components/musicVideo/TreatmentApplyReview.jsx
+++ b/client/src/components/musicVideo/TreatmentApplyReview.jsx
@@ -16,6 +16,7 @@ function renderFieldLabel(fields) {
if (!fields) return null;
if (fields.shotMode === 'performance') return 'becomes a lip-synced performance shot';
if (fields.visualLayer === 'card') return 'becomes a title card (composed render only)';
+ if (fields.visualLayer === 'code') return 'becomes a code shot the composition draws';
if (fields.visualLayer === 'still') return 'becomes a moving still (composed render only)';
return null;
}
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index cd326628ec..a3f106b909 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -190,6 +190,7 @@ export default function BoardStage({ board }) {
onImportTake={(target) => board.setPickerTarget({ type: 'take', sceneId: target.sceneId })}
onImportClipTake={(target) => board.setPickerTarget({ type: 'clip', sceneId: target.sceneId })}
layered={layered}
+ documentComposition={project.composition?.mode === 'document'}
/>
))}
</div>
diff --git a/client/src/hooks/useMusicVideoSceneMedia.js b/client/src/hooks/useMusicVideoSceneMedia.js
index 7f883f9c40..15efbe1d5a 100644
--- a/client/src/hooks/useMusicVideoSceneMedia.js
+++ b/client/src/hooks/useMusicVideoSceneMedia.js
@@ -10,7 +10,7 @@ import { generateVideo } from '../services/apiImageVideo.js';
import useSceneBatch from './useSceneBatch.js';
import useSceneRenderLifecycle from './useSceneRenderLifecycle.js';
import { isLtx2FamilyRuntime } from '../lib/runnerFamilies';
-import { isLayeredComposition, sceneVisualLayer } from '../lib/musicVideoLayers.js';
+import { isLayeredComposition, isSelfDrawnLayer, sceneVisualLayer } from '../lib/musicVideoLayers.js';
import { musicVideoFrameGenSize } from '../lib/musicVideoAspect.js';
import { MOTION_CONTINUITY_CLAUSE } from '../lib/musicVideoMotion.js';
import {
@@ -372,7 +372,7 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
// #8985: a composed render's title cards need no frame, and its stills need
// no clip — the batch generators skip them.
const layered = isLayeredComposition(project);
- const frameScenes = scenes.filter((scene) => !['card', 'code'].includes(sceneVisualLayer(scene, { layered })));
+ const frameScenes = scenes.filter((scene) => !isSelfDrawnLayer(sceneVisualLayer(scene, { layered })));
const footageScenes = scenes.filter((scene) => sceneVisualLayer(scene, { layered }) === 'footage');
const planMissingFrames = () => frameScenes.filter((scene) =>
!scene.referenceImageId && !genScenes[scene.sceneId] && buildFramePrompt(scene));
diff --git a/client/src/lib/musicVideoLayers.js b/client/src/lib/musicVideoLayers.js
index ce47b6328a..049fe5347c 100644
--- a/client/src/lib/musicVideoLayers.js
+++ b/client/src/lib/musicVideoLayers.js
@@ -6,6 +6,7 @@
export {
MUSIC_VIDEO_VISUAL_LAYERS,
MUSIC_VIDEO_STILL_MOVES,
+ isSelfDrawnLayer,
sceneVisualLayer,
sceneHasAuthoredSpan,
sceneRenderReady,
diff --git a/client/src/lib/musicVideoSceneAttention.js b/client/src/lib/musicVideoSceneAttention.js
index d6ada0de60..6fa728cad3 100644
--- a/client/src/lib/musicVideoSceneAttention.js
+++ b/client/src/lib/musicVideoSceneAttention.js
@@ -8,7 +8,7 @@
*/
import { shotActionContractProblem } from '../../../server/lib/musicVideoActionContract.js';
import { currentPlateEvidence } from '../../../server/lib/musicVideoPlateEvidence.js';
-import { sceneVisualLayer, sceneHasAuthoredSpan } from './musicVideoLayers.js';
+import { isSelfDrawnLayer, sceneVisualLayer, sceneHasAuthoredSpan } from './musicVideoLayers.js';
import { performanceBlockedReason, performanceCapability, planPerformanceWindow, isPerformanceScene } from './musicVideoShotTiming.js';
import { sceneHasPendingDecision, sceneTakeList } from './musicVideoTakes.js';
@@ -55,7 +55,7 @@ export function sceneAttention(scene, ctx = {}) {
const { layered = false, footageOptional = false, lipSyncBackend = '', songDurationSec = null, clipSec = null, failed = {} } = ctx;
const layer = sceneVisualLayer(scene, { layered });
const codes = [];
- if (layer !== 'card' && layer !== 'code' && !scene.referenceImageId) codes.push('missing-frame');
+ if (!isSelfDrawnLayer(layer) && !scene.referenceImageId) codes.push('missing-frame');
if (layer === 'footage' && !footageOptional && !scene.videoHistoryId) codes.push('missing-clip');
if (layer !== 'footage' && !sceneHasAuthoredSpan(scene)) codes.push('no-span');
if (layer === 'footage' && scene.loop === false && scene.beatAligned && clipSec != null
diff --git a/client/src/lib/musicVideoSceneAttention.test.js b/client/src/lib/musicVideoSceneAttention.test.js
index d05a212523..cbb5a706c0 100644
--- a/client/src/lib/musicVideoSceneAttention.test.js
+++ b/client/src/lib/musicVideoSceneAttention.test.js
@@ -20,6 +20,11 @@ describe('sceneAttention', () => {
expect(sceneAttention({ sceneId: 's', visualLayer: 'card', startSec: 1, endSec: 3 }, { layered: true })).toEqual([]);
});
+ it('never asks a code shot for a frame or clip (#10297)', () => {
+ expect(sceneAttention({ sceneId: 's', visualLayer: 'code', startSec: 1, endSec: 3 }, { layered: true })).toEqual([]);
+ expect(sceneAttention({ sceneId: 's', visualLayer: 'code' }, { layered: true })).toEqual(['no-span']);
+ });
+
it('flags a non-looping beat-aligned shot longer than its measured clip', () => {
const shot = { ...ready, loop: false, beatAligned: true, endSec: 10 };
expect(sceneAttention(shot, { clipSec: 5 })).toEqual(['under-covered']);
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 6759db0e99..39f4e5111e 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -4,7 +4,7 @@
* spend. Pure functions over the project record so the header, the progress
* strip and the tests all read the same answer.
*/
-import { isLayeredComposition, sceneRenderReady } from './musicVideoLayers.js';
+import { isLayeredComposition, isSelfDrawnLayer, sceneRenderReady, sceneVisualLayer } from './musicVideoLayers.js';
import {
AUTONOMOUS_CHECKPOINT_LABELS, AUTONOMOUS_LYRICS_STEP_LABELS, AUTONOMOUS_SONG_STEP_LABELS, AUTONOMOUS_STATUS_LABELS,
} from './musicVideoAutonomous.js';
@@ -99,10 +99,13 @@ export function projectSpend(project) {
* What generating the rest of the board takes (#10157): scenes still missing a
* frame or a clip, the generation limit that covers them plus a 25% review
* allowance, and the known fal.ai price of the missing clips. A frame, or a
- * clip on a route with no quote, counts as unpriced.
+ * clip on a route with no quote, counts as unpriced. Card and code shots in a
+ * layered composition are drawn, not generated (#10297), so they need neither.
*/
export function boardJobEstimate(project) {
- const scenes = Array.isArray(project?.scenes) ? project.scenes : [];
+ const layered = isLayeredComposition(project);
+ const scenes = (Array.isArray(project?.scenes) ? project.scenes : [])
+ .filter((scene) => !isSelfDrawnLayer(sceneVisualLayer(scene, { layered })));
const settings = project?.videoSettings || {};
const missingFrames = scenes.filter((scene) => !scene?.referenceImageId).length;
const missingClips = scenes.filter((scene) => !scene?.videoHistoryId);
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index 1a0c802848..30cd6d7830 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -268,6 +268,17 @@ describe('boardJobEstimate', () => {
expect(boardJobEstimate({ scenes })).toMatchObject({ jobs: 3, unpriced: 3, knownUsd: 0, suggestedMaxGenerations: 4 });
expect(boardJobEstimate({ scenes: [scene()] })).toMatchObject({ jobs: 0, suggestedMaxGenerations: 1 });
});
+
+ it('counts no generation for card or code shots in a layered composition (#10297)', () => {
+ const scenes = [
+ scene({ sceneId: 'a', visualLayer: 'code', referenceImageId: null, videoHistoryId: null }),
+ scene({ sceneId: 'b', visualLayer: 'card', referenceImageId: null, videoHistoryId: null }),
+ scene({ sceneId: 'c', referenceImageId: null, videoHistoryId: null }),
+ ];
+ expect(boardJobEstimate({ scenes, composition: { mode: 'composed' } })).toMatchObject({ jobs: 2 });
+ // A plain render plays footage for every shot, so all three still need generating.
+ expect(boardJobEstimate({ scenes })).toMatchObject({ jobs: 6 });
+ });
});
describe('stage route param', () => {
diff --git a/server/lib/musicVideoLayers.js b/server/lib/musicVideoLayers.js
index 21798ab8f9..4eade4b96e 100644
--- a/server/lib/musicVideoLayers.js
+++ b/server/lib/musicVideoLayers.js
@@ -4,21 +4,29 @@
* In a composed render a scene can show its generated footage (the default,
* and every scene saved before the field existed), its selected still frame
* with a deterministic camera move, a code-rendered title card (a solid
- * colour whose text the typography layer draws), or a code shot (picture drawn
- * by the composition code — no frame or clip is ever generated). A plain concat render always
+ * colour whose text the typography layer draws), or a code shot (#10297) that
+ * the composition's own code draws. A composition document is handed the
+ * `code` layer and no media; whatever its section code draws is the shot (the
+ * stock layered template draws nothing extra, leaving the ground and the type).
+ * A composed render has no code to run, so it lays a black ground under its
+ * typography. Cards and code shots need no frame or clip. A plain concat render always
* uses footage. Pure and dependency-free: the server render and the client
* board read the same rules, so the Render button's readiness matches what the
* render preflight accepts.
*/
export const MUSIC_VIDEO_VISUAL_LAYERS = ['footage', 'still', 'card', 'code'];
+
+/** Layers the composition draws itself: no reference frame and no clip to generate. */
+export const isSelfDrawnLayer = (layer) => layer === 'card' || layer === 'code';
export const MUSIC_VIDEO_STILL_MOVES = ['hold', 'push', 'pan'];
/**
* Whether a composition honours per-scene layers: a composed render cuts
* stills and cards itself, and a composition document (mode `document`) is
- * handed each scene's layer in `window.PORTOS_MV` and draws still/card scenes
- * itself — neither needs a clip for them, and a card needs no frame either.
+ * handed each scene's layer in `window.PORTOS_MV` and draws still/card/code
+ * scenes itself — neither needs a clip for them, and a card or code shot needs
+ * no frame either.
* Plain concat and code renders play footage only.
*/
export const LAYERED_COMPOSITION_MODES = Object.freeze(['composed', 'document']);
@@ -27,7 +35,7 @@ export const isLayeredComposition = (project) => LAYERED_COMPOSITION_MODES.inclu
/** The layer a scene contributes; `layered` is true only for a layered composition (see isLayeredComposition). */
export function sceneVisualLayer(scene, { layered = false } = {}) {
const layer = scene?.visualLayer;
- return layered && (layer === 'still' || layer === 'card' || layer === 'code') ? layer : 'footage';
+ return layered && (layer === 'still' || isSelfDrawnLayer(layer)) ? layer : 'footage';
}
/** A generated document executes the explicit code-first medium plan. */
@@ -35,24 +43,25 @@ export function documentSceneVisualLayer(project, scene, { generated = false } =
if (!generated || project?.productionPolicy?.strategy !== 'code-first') return sceneVisualLayer(scene, { layered: true });
const direction = (project?.treatment?.shotDirections || []).find((entry) => entry.sceneId === scene.sceneId)
|| scene?.direction;
- if (direction?.medium === 'procedural') return 'card';
+ // A director's code shot stays code; only a planned procedural span becomes the template's card.
+ if (direction?.medium === 'procedural') return scene?.visualLayer === 'code' ? 'code' : 'card';
if (direction?.medium === 'still') return 'still';
if (direction?.medium === 'existing-footage' || direction?.medium === 'generated-footage') return 'footage';
return sceneVisualLayer(scene, { layered: true });
}
-/** A still/card section has no clip to measure, so it needs an authored span. */
+/** A still/card/code section has no clip to measure, so it needs an authored span. */
export function sceneHasAuthoredSpan(scene) {
return typeof scene?.startSec === 'number' && typeof scene?.endSec === 'number' && scene.endSec > scene.startSec;
}
/**
* Whether the render can include this scene as-is: footage needs its clip, a
- * still needs its reference frame and a span, and a card or code shot needs only a span (code is drawn by the composition itself).
+ * still needs its reference frame and a span, and a card or code shot needs only a span.
*/
export function sceneRenderReady(scene, { layered = false } = {}) {
const layer = sceneVisualLayer(scene, { layered });
if (layer === 'footage') return Boolean(scene?.videoHistoryId);
if (!sceneHasAuthoredSpan(scene)) return false;
- return layer === 'card' || layer === 'code' || Boolean(scene.referenceImageId);
+ return isSelfDrawnLayer(layer) || Boolean(scene.referenceImageId);
}
diff --git a/server/lib/musicVideoLayers.test.js b/server/lib/musicVideoLayers.test.js
index 6f80f0d55f..1a872d21f2 100644
--- a/server/lib/musicVideoLayers.test.js
+++ b/server/lib/musicVideoLayers.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { isLayeredComposition, sceneRenderReady, sceneVisualLayer } from './musicVideoLayers.js';
+import { documentSceneVisualLayer, isLayeredComposition, isSelfDrawnLayer, sceneRenderReady, sceneVisualLayer } from './musicVideoLayers.js';
describe('musicVideoLayers', () => {
it('treats composed renders and composition documents as layered, concat and code as footage-only', () => {
@@ -26,4 +26,18 @@ describe('musicVideoLayers', () => {
expect(sceneRenderReady(code, { layered: true })).toBe(true);
expect(sceneRenderReady({ visualLayer: 'code' }, { layered: true })).toBe(false);
});
+
+ it('groups cards and code shots as drawn by the composition: no frame or clip to generate', () => {
+ expect(['footage', 'still', 'card', 'code', undefined].map(isSelfDrawnLayer)).toEqual([false, false, true, true, false]);
+ });
+
+ it('hands a generated code-first document a code shot as code, and an unlayered procedural span as a card', () => {
+ const project = { productionPolicy: { strategy: 'code-first' }, treatment: { shotDirections: [
+ { sceneId: 'code', medium: 'procedural' }, { sceneId: 'plain', medium: 'procedural' },
+ ] } };
+ expect(documentSceneVisualLayer(project, { sceneId: 'code', visualLayer: 'code' }, { generated: true })).toBe('code');
+ expect(documentSceneVisualLayer(project, { sceneId: 'plain', visualLayer: 'footage' }, { generated: true })).toBe('card');
+ // An imported document is handed the director's layer as it is.
+ expect(documentSceneVisualLayer(project, { sceneId: 'code', visualLayer: 'code' })).toBe('code');
+ });
});
diff --git a/server/lib/musicVideoMediumPlan.js b/server/lib/musicVideoMediumPlan.js
index 098d059076..e36ac257c7 100644
--- a/server/lib/musicVideoMediumPlan.js
+++ b/server/lib/musicVideoMediumPlan.js
@@ -172,7 +172,7 @@ export function planMusicVideoMedia(project, directions) {
}
let medium = d.medium;
let rationale = d.mediumRationale;
- const manualLayer = scene?.visualLayer === 'still' || scene?.visualLayer === 'card' || scene?.visualLayer === 'code';
+ const manualLayer = ['still', 'card', 'code'].includes(scene?.visualLayer);
if (manualLayer) {
medium = scene.visualLayer === 'still' ? 'still' : 'procedural';
rationale = 'Retain the director-selected visual layer.';
diff --git a/server/routes/musicVideoTreatment.test.js b/server/routes/musicVideoTreatment.test.js
index 5eddab0994..f26a4f6ea4 100644
--- a/server/routes/musicVideoTreatment.test.js
+++ b/server/routes/musicVideoTreatment.test.js
@@ -67,11 +67,12 @@ function seedVideoHistory(rows) {
const base = (id) => `/api/music-video/${id}`;
const reload = (id) => projects.getProject(id);
-async function plannedProject({ lyrics = LYRICS, backend } = {}) {
+async function plannedProject({ lyrics = LYRICS, backend, mediaMode } = {}) {
const project = await projects.createProject({
name: 'Example Video',
concept: { prompt: 'a night run through Example City' },
...(backend ? { videoSettings: { backend } } : {}),
+ ...(mediaMode ? { mediaMode } : {}),
});
await projects.setProjectAnalysis(project.id, ANALYSIS);
if (lyrics.length) await projects.updateProject(project.id, { lyricCues: lyrics });
@@ -427,6 +428,45 @@ describe('treatment → scene render fields (#8977 shot mode, #8985 visual layer
const card = after.scenes[sung];
expect(after.composition.textCues.some((c) => c.startSec >= card.startSec && c.startSec < card.endSec)).toBe(false);
});
+
+ it('turns an unsung code-2d shot into a code shot, not a still, when the media mode allows no images on the legacy policy (#10297)', async () => {
+ const project = await plannedProject({ mediaMode: 'code-only' });
+ const scenes = (await reload(project.id)).scenes;
+ // The planner already types a code-only project's shots as code; reset one to the default layer.
+ expect(scenes.every((sc) => sc.visualLayer === 'code')).toBe(true);
+ const instrumental = scenes.findLastIndex((sc) => !sc.lyricText);
+ await projects.updateScene(project.id, scenes[instrumental].sceneId, { visualLayer: 'footage' });
+ // A code-only project plans code-first by default (no render-field rewrite); this covers a
+ // director who kept the legacy policy, where the treatment still sets render fields.
+ await projects.updateProject(project.id, { productionPolicy: { strategy: 'legacy', maxGeneratedVideoPercent: 0 } });
+ runPromptThroughProvider.mockResolvedValueOnce({
+ text: JSON.stringify({
+ beats: [{ sectionIndex: 0, objective: 'Open' }],
+ shots: [{ index: instrumental, route: 'code-2d', mode: 'graphic', focalSubject: 'rain' }],
+ }),
+ });
+ const modeBefore = (await reload(project.id)).composition?.mode;
+ const { body } = await compile(project.id, { baseRevision: 0 });
+ const res = await request(app).post(`${base(project.id)}/treatment/apply`).send({ revision: body.treatment.revision });
+ expect(res.status).toBe(200);
+ const after = await reload(project.id);
+ expect(after.scenes[instrumental].visualLayer).toBe('code');
+ expect(after.scenes[instrumental].stillMove ?? 'hold').toBe('hold');
+ // Applying the treatment leaves the render style the project chose.
+ expect(after.composition?.mode).toBe(modeBefore);
+ });
+
+ it('plans code shots without switching a plain render to composed, where they would render black (#10297)', async () => {
+ const project = await projects.createProject({ name: 'Example Video', mediaMode: 'code-only' });
+ await projects.updateProject(project.id, { composition: { mode: 'concat' } });
+ await projects.setProjectAnalysis(project.id, ANALYSIS);
+ const plan = await request(app).post(`${base(project.id)}/plan`).send({ seedPrompts: false });
+ expect(plan.status).toBe(200);
+ const after = await reload(project.id);
+ expect(after.scenes.length).toBeGreaterThan(0);
+ expect(after.scenes.every((sc) => sc.visualLayer === 'code')).toBe(true);
+ expect(after.composition.mode).toBe('concat');
+ });
});
describe('treatment proofs, clone and motion references', () => {
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.js
index 4a19c3335f..2fce746c6a 100644
--- a/server/services/codeAnimation/prompt.js
+++ b/server/services/codeAnimation/prompt.js
@@ -419,7 +419,7 @@ export function buildMixedMediaDocumentPrompt({ title, song, palette, treatment,
renderer === 'three' ? '' : CODE_VIDEO_RULES.replace('- Canvas 2D only. No external assets, fonts, or network.', '- Canvas 2D only. No network, remote URLs, filesystem paths or font loading. The host binds only the listed selected project assets; draw over footage/stills without obscuring them, and draw the entire authored world for card scenes, including characters, environments, camera staging, lighting and narrative actions. Local packaged fonts MV Mono, MV Cond and MV Stencil are available; authored titles are allowed, but do not duplicate host subtitles.'),
MUSIC_VIDEO_DIRECTION,
MUSIC_VIDEO_CHOREOGRAPHY,
- renderer === 'three' ? 'The authored Three.js world receives no selected-media handles; all visual staging uses geometry and the host text overlay.' : 'env additionally has mediaKind (video, image or null) and visualLayer (footage, still or card). The host has already drawn the selected media at its in/out time. Do not read DOM or load assets in a section function. Use seeded arithmetic from env.frame for visual motion. Keep repeated hooks related but deliberately vary their action.',
+ renderer === 'three' ? 'The authored Three.js world receives no selected-media handles; all visual staging uses geometry and the host text overlay.' : 'env additionally has mediaKind (video, image or null) and visualLayer (footage, still, card or code — a code shot has no media and is drawn entirely by the section). The host has already drawn the selected media at its in/out time. Do not read DOM or load assets in a section function. Use seeded arithmetic from env.frame for visual motion. Keep repeated hooks related but deliberately vary their action.',
'NARRATIVE CLOCK: song.narrativeEvents are resolved absolute startFrame/endFrame bindings. env.events supplies active events with progress and counter value; env.reactiveGain is bounded by the section gain/maxGain and is zero during silence. The host freezes song time, media and graphics for silence, and draws exact event text/counters/motif labels after your function. Use the narrativeFunction, motif and mediumRationale to motivate your graphic actions; do not duplicate event text or infer new onsets. Prefer code/stills/selected media for exact text and graphics. Footage is for actions that need it and must already be selected.',
`SHARED STYLE CONTRACT:\n${JSON.stringify(sharedStyle || { palette, treatment: { brief: treatment?.brief || null, motifs: treatment?.arc?.motifs || [], styleLook: treatment?.styleLook || null }, visualSpec, styleLines })}`,
directionContext ? `APPROVED CAST & SETS DEFINITIONS AND RULES:\n${directionContext}` : '',
diff --git a/server/services/musicVideo/documentRender.js b/server/services/musicVideo/documentRender.js
index e7358a8a1f..ed65255f0b 100644
--- a/server/services/musicVideo/documentRender.js
+++ b/server/services/musicVideo/documentRender.js
@@ -110,7 +110,8 @@ export async function resolveSceneMedia(project, { history = [], probe = async (
for (const scene of Array.isArray(project?.scenes) ? project.scenes : []) {
if (!scene?.sceneId) continue;
const layer = documentSceneVisualLayer(project, scene, { generated: strictLayers });
- if (strictLayers && layer === 'card') continue;
+ // A code shot (#10297) is drawn by the document itself; it is handed no media.
+ if (layer === 'code' || (strictLayers && layer === 'card')) continue;
const entry = scene.videoHistoryId ? byId.get(scene.videoHistoryId) : null;
const videoPath = entry?.filename ? safeUnder(PATHS.videos, entry.filename) : null;
if ((!strictLayers || layer === 'footage') && videoPath && existsSync(videoPath)) {
diff --git a/server/services/musicVideo/planner.js b/server/services/musicVideo/planner.js
index 2f48cdf112..a10c07b595 100644
--- a/server/services/musicVideo/planner.js
+++ b/server/services/musicVideo/planner.js
@@ -356,7 +356,10 @@ export async function planProject(id, { seedPrompts = true, providerId, model, e
// flight would otherwise be silently dropped from this response and
// visually reverted by the client's replaceProject) and a redundant
// second getProject round trip.
- const hasCards = sceneInputs.some((s) => s.visualLayer === 'card' || s.visualLayer === 'code');
+ // Cards need a layered mode, so planning them switches a plain render to composed. Code shots
+ // do not: only a composition document draws them, and a composed render would show them black
+ // while reading render-ready, so a plain project keeps its mode and its honest "not ready" (#10297).
+ const 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' });
diff --git a/server/services/musicVideo/production.js b/server/services/musicVideo/production.js
index 3b95fd40ee..9ea10ece41 100644
--- a/server/services/musicVideo/production.js
+++ b/server/services/musicVideo/production.js
@@ -43,7 +43,7 @@ import { randomUUID } from 'crypto';
import { ServerError } from '../../lib/errorHandler.js';
import { canonicalSnapshotChecksum } from '../../lib/snapshotChecksum.js';
import { isNonBlankStr, trimTo } from '../../lib/textUtils.js';
-import { isLayeredComposition, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
+import { isLayeredComposition, isSelfDrawnLayer, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
import { codeFirstProductionAssets, normalizeMusicVideoProductionPolicy, summarizeMusicVideoMediumPlan } from '../../lib/musicVideoMediumPlan.js';
import { projectAutoReviews } from './autoReview.js';
import { projectRevisions } from './revision.js';
@@ -366,7 +366,7 @@ function productionTargets(project) {
const layered = isLayeredComposition(project);
const scenes = Array.isArray(project?.scenes) ? project.scenes : [];
return {
- frame: scenes.filter((s) => sceneVisualLayer(s, { layered }) === 'still' || (!['card', 'code'].includes(sceneVisualLayer(s, { layered })) && !s.videoHistoryId)),
+ frame: scenes.filter((s) => sceneVisualLayer(s, { layered }) === 'still' || (!isSelfDrawnLayer(sceneVisualLayer(s, { layered })) && !s.videoHistoryId)),
clip: scenes.filter((s) => sceneVisualLayer(s, { layered }) === 'footage'),
};
}
diff --git a/server/services/musicVideo/productionPilot.js b/server/services/musicVideo/productionPilot.js
index 1733386bee..c7bb08ef81 100644
--- a/server/services/musicVideo/productionPilot.js
+++ b/server/services/musicVideo/productionPilot.js
@@ -2,7 +2,7 @@
import { canonicalSnapshotChecksum } from '../../lib/snapshotChecksum.js';
import { captureMusicVideoEvidence, captureTakeDependencies, musicVideoDependencyChanges } from '../../lib/musicVideoDependencies.js';
import { codeFirstProductionAssets } from '../../lib/musicVideoMediumPlan.js';
-import { isLayeredComposition, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
+import { isLayeredComposition, isSelfDrawnLayer, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
export function pilotClass(scene, project) {
const medium = project.treatment?.shotDirections?.find((d) => d.sceneId === scene.sceneId)?.medium;
@@ -21,7 +21,7 @@ export function selectProductionPilots(project) {
const seen = new Set();
const rank = { performance: 5, interaction: 4, camera: 3, cutaway: 2, still: 1 };
return (project.scenes || [])
- .filter((scene) => allowed ? allowed.has(scene.sceneId) : !['card', 'code'].includes(sceneVisualLayer(scene, { layered: isLayeredComposition(project) })))
+ .filter((scene) => allowed ? allowed.has(scene.sceneId) : !isSelfDrawnLayer(sceneVisualLayer(scene, { layered: isLayeredComposition(project) })))
.map((scene) => ({ sceneId: scene.sceneId, operation: pilotClass(scene, project),
missing: Number(!scene.referenceImageId) + Number(pilotClass(scene, project) !== 'still' && !scene.videoHistoryId),
complexity: (scene.direction?.actionContract?.actions?.length || 0)
diff --git a/server/services/musicVideo/productionService.js b/server/services/musicVideo/productionService.js
index e5f40ab242..079a69254d 100644
--- a/server/services/musicVideo/productionService.js
+++ b/server/services/musicVideo/productionService.js
@@ -33,6 +33,7 @@ import { musicVideoEvents } from './events.js';
import { isFreeProvider } from '../../lib/modelPricing.js';
import { isAuthoringOneShotProvider } from '../../lib/providerVendors.js';
import { codeFirstProductionAssets } from '../../lib/musicVideoMediumPlan.js';
+import { isSelfDrawnLayer } from '../../lib/musicVideoLayers.js';
import { beginNextAttempt } from './autoReview.js';
import { withAutopilotCutting } from './composition.js';
import { currentPilotPass, pilotClass, pilotRepair } from './productionPilot.js';
@@ -153,7 +154,7 @@ const present = (run, project) => {
return { ...run, interrupted: run.status === 'running' && run.processId !== PROCESS_ID,
accounting: {
plannedGenerations: assets ? assets.steps.filter((s) => ['generate-image', 'generate-video'].includes(s.action)).length
- : (project?.scenes || []).reduce((n, scene) => n + (!['card', 'code'].includes(scene.visualLayer) && !scene.referenceImageId && (!scene.videoHistoryId || pilotClass(scene, project) === 'still') ? 1 : 0) + (!scene.videoHistoryId && pilotClass(scene, project) !== 'still' && !['card', 'code'].includes(scene.visualLayer) ? 1 : 0), 0),
+ : (project?.scenes || []).reduce((n, scene) => n + (!isSelfDrawnLayer(scene.visualLayer) && !scene.referenceImageId && (!scene.videoHistoryId || pilotClass(scene, project) === 'still') ? 1 : 0) + (!scene.videoHistoryId && pilotClass(scene, project) !== 'still' && !isSelfDrawnLayer(scene.visualLayer) ? 1 : 0), 0),
reservedUsd: reserved.reduce((n, s) => n + (s.costUsd || 0), 0),
spentUsd: spent.reduce((n, s) => n + (s.costUsd || 0), 0),
unpriced: counted.some((s) => s.costUsd == null),
diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.js
index b11e931614..d8646b190b 100644
--- a/server/services/musicVideo/render.js
+++ b/server/services/musicVideo/render.js
@@ -41,7 +41,7 @@ import { loadHistory, mutateVideoHistory } from '../videoGen/local.js';
import { getTrack } from '../tracks/index.js';
import { getProject, listProjects, updateProject, mutateProjectRecord } from './projects.js';
import { applyProjectPatch } from './projectsLogic.js';
-import { sceneHasAuthoredSpan, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
+import { isSelfDrawnLayer, sceneHasAuthoredSpan, sceneVisualLayer } from '../../lib/musicVideoLayers.js';
import { renderableCues, sectionCardCues } from './composition.js';
import { encodeCodeComposition, prepareCodeRender, writeCodeProofSheet } from './codeRender.js';
import { encodeDocumentComposition, prepareDocumentRender, sweepDocumentScratch } from './documentRender.js';
@@ -241,8 +241,14 @@ export async function resolveSceneClips(project, { layered = false } = {}) {
const spanSec = authoredSpan(scene);
if (spanSec == null) { untimed.push(scene.sceneId); continue; }
const section = { sceneId: scene.sceneId, layer, inSec: 0, outSec: spanSec, duration: spanSec, sourceSec: spanSec };
- if (layer === 'card' || layer === 'code') {
- clips.push({ ...section, cardText: layer === 'card' && typeof scene.cardText === 'string' ? scene.cardText.trim() : '', cardColor: /^#[0-9a-f]{6}$/i.test(scene.cardColor || '') ? scene.cardColor : '#000000' });
+ // A composed render has no code to run: a code shot (#10297) is a black
+ // ground the typography layer draws over, cut exactly like a blank card.
+ if (layer === 'code') {
+ clips.push({ ...section, layer: 'card', cardText: '', cardColor: '#000000' });
+ continue;
+ }
+ if (layer === 'card') {
+ clips.push({ ...section, cardText: typeof scene.cardText === 'string' ? scene.cardText.trim() : '', cardColor: /^#[0-9a-f]{6}$/i.test(scene.cardColor || '') ? scene.cardColor : '#000000' });
continue;
}
const imagePath = scene.referenceImageId ? safeUnder(PATHS.images, scene.referenceImageId) : null;
@@ -600,7 +606,7 @@ export function excerptBoundaryTimes(sections, cues, startSec, endSec, { fps = 2
// authored span. Both callers build on the exact same resolved clip list, so
// an excerpt frame matches what a full render would produce at that song time.
export function assertCurrentClipDependencies(project) {
- const stale = (project.scenes || []).filter((scene) => scene.videoHistoryId && !['still', 'card', 'code'].includes(scene.visualLayer))
+ const stale = (project.scenes || []).filter((scene) => scene.videoHistoryId && scene.visualLayer !== 'still' && !isSelfDrawnLayer(scene.visualLayer))
.filter((scene) => musicVideoTakeChanges(project, scene, (scene.takes || []).find((take) => take.kind === 'video' && take.assetId === scene.videoHistoryId)).length);
if (stale.length) throw new ServerError('Selected clips were derived from changed plates — preview and repair their dependencies before rendering',
{ status: 422, code: 'STALE_CLIP_DEPENDENCIES', context: { sceneIds: stale.map((scene) => scene.sceneId) } });
diff --git a/server/services/musicVideo/render.test.js b/server/services/musicVideo/render.test.js
index 97c15ca69e..d858b0e579 100644
--- a/server/services/musicVideo/render.test.js
+++ b/server/services/musicVideo/render.test.js
@@ -311,6 +311,12 @@ describe('resolveSceneClips', () => {
expect(clips[0].duration).toBe(2); // 48/24
});
+ it('cuts a code shot as a black ground in a composed render (#10297)', async () => {
+ loadHistory.mockResolvedValue([]);
+ const clips = await resolveSceneClips({ scenes: [{ sceneId: 's1', order: 0, visualLayer: 'code', startSec: 2, endSec: 5 }] }, { layered: true });
+ expect(clips).toEqual([expect.objectContaining({ sceneId: 's1', layer: 'card', cardText: '', cardColor: '#000000', duration: 3 })]);
+ });
+
it('throws NO_SCENE_CLIPS when no scene has a clip', async () => {
loadHistory.mockResolvedValue([]);
await expect(resolveSceneClips({ scenes: [{ sceneId: 's1', order: 0, videoHistoryId: null }] }))
diff --git a/server/services/musicVideo/revision.js b/server/services/musicVideo/revision.js
index ca9b573099..fd9b70c5b6 100644
--- a/server/services/musicVideo/revision.js
+++ b/server/services/musicVideo/revision.js
@@ -154,7 +154,7 @@ export function startRevisionOnProject(project, excerptId, { sceneIds } = {}, no
const scene = scenesById.get(section.sceneId);
if (!scene) continue; // deleted since the draft — nothing left to keep or revise
const rejected = rejectIds.has(section.sceneId);
- if (!codeFirst(project) && section.layer === 'card') {
+ if (!codeFirst(project) && (section.layer === 'card' || section.layer === 'code')) {
if (rejected) skippedSceneIds.push(section.sceneId);
continue;
}
diff --git a/server/services/musicVideo/treatment.js b/server/services/musicVideo/treatment.js
index c66995f343..3c0b9c3072 100644
--- a/server/services/musicVideo/treatment.js
+++ b/server/services/musicVideo/treatment.js
@@ -56,6 +56,7 @@ import {
MUSIC_VIDEO_PROOF_STATUSES as PROOF_STATUSES,
} from '../../lib/musicVideoValidation.js';
import { performanceCapability } from '../../lib/musicVideoShotTiming.js';
+import { musicVideoAllowsMedia } from '../../lib/musicVideoMediaPolicy.js';
import { normalizeComposition } from './composition.js';
import { hookKey, hookLines, cueWordOnsets } from './hookTypography.js';
@@ -622,9 +623,10 @@ const summarizePlans = (plans) => PLAN_PRIORITY.find((p) => Object.values(plans)
* - a performance direction becomes `shotMode: 'performance'` only when the
* project's backend has a verified source-audio lip-sync lane;
* - a code-2d route becomes a title card carrying the shot's first sung line
- * (never invented text), or a pushed-in still when there is no line to set.
+ * (never invented text); with no line to set it becomes a pushed-in still,
+ * or a code shot (#10297) when the media mode allows no images.
*/
-function renderFieldPatch(scene, direction, { lipSyncAvailable }) {
+function renderFieldPatch(scene, direction, { lipSyncAvailable, imagesAllowed = true }) {
const defaultLayer = (scene.visualLayer ?? 'footage') === 'footage';
const defaultMode = (scene.shotMode ?? 'cutaway') === 'cutaway';
if (!defaultLayer || !defaultMode) return {};
@@ -636,6 +638,7 @@ function renderFieldPatch(scene, direction, { lipSyncAvailable }) {
? scene.lyricText.split(' / ')[0].trim().slice(0, 500)
: '';
if (line) return { visualLayer: 'card', ...(isNonBlankStr(scene.cardText) ? {} : { cardText: line }) };
+ if (!imagesAllowed) return { visualLayer: 'code' };
return { visualLayer: 'still', ...((scene.stillMove ?? 'hold') === 'hold' ? { stillMove: 'push' } : {}) };
}
@@ -696,6 +699,7 @@ export function buildApplyPreview(project) {
const mediumPlan = summarizeMusicVideoMediumPlan(project, treatment.shotDirections);
const scenesById = new Map((project.scenes || []).map((s) => [s.sceneId, s]));
const lipSyncAvailable = !!performanceCapability(project.videoSettings?.backend || null);
+ const imagesAllowed = musicVideoAllowsMedia(project, 'image');
const planned = [];
const directed = new Set();
const scenes = [];
@@ -710,7 +714,7 @@ export function buildApplyPreview(project) {
const fields = promptFieldPlans(scene, direction);
// This slice only plans code-first execution: never reinterpret procedural
// direction as legacy footage/card selection or switch a render mode.
- const renderFields = mediumPlan.strategy === 'code-first' ? {} : renderFieldPatch(scene, direction, { lipSyncAvailable });
+ const renderFields = mediumPlan.strategy === 'code-first' ? {} : renderFieldPatch(scene, direction, { lipSyncAvailable, imagesAllowed });
planned.push({ ...scene, ...renderFields });
scenes.push({
sceneId: scene.sceneId,