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

Add style-break end frames for music video scenes

Claudeb6e8a8737c77
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index c8d7ed291e..b14e10b1ff 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -9,6 +9,7 @@ import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';
import PerformanceEvidence from './PerformanceEvidence.jsx';
import { planPerformanceRepair } from '../../lib/musicVideoShotTiming.js';
import SceneTakeStrip from './SceneTakeStrip.jsx';
+import SceneEndFrame from './SceneEndFrame.jsx';
import { MUSIC_VIDEO_LYRIC_ROLES, MUSIC_VIDEO_TEXT_ZONES, MUSIC_VIDEO_VISUAL_LAYERS, sceneHasAuthoredSpan } from '../../lib/musicVideoLayers.js';
// #8985: what a composed render shows for this scene's span.
@@ -86,7 +87,7 @@ export default function SceneCard({
scene, index, isLast, generatingFrame, generatingVideo, frameProgress = null, videoProgress = null,
settingsSaving, videoBlockedReason, canContinueShot,
onMove, onDelete, onEditLocal, onSave,
- onGenerateFrame, onGenerateVideo, onContinueVideo,
+ onGenerateFrame, onGenerateVideo, onContinueVideo, onGenerateEndFrame, generatingEndFrame = false,
onOpenPreview, onSelectTake, onReviewTake, onImportTake, onImportClipTake, takeBusy = false, layered = false, documentComposition = false,
lipSyncBackend = '', songDurationSec = null, onSplit, onMergeNext, nextEndSec = null, falVideoSettings = null, onSeek, performanceReview = null, onRepairPerformance, repairBusy = false,
expanded, onToggleExpand, footageOptional = false, failedScenes = null, songReview = null,
@@ -433,6 +434,12 @@ export default function SceneCard({
onSelect={(take) => onSelectTake?.(scene, take)}
onReview={(take, review) => onReviewTake?.(scene, take, review)}
onOpenPreview={onOpenPreview} />
+ {/* Style-break end frame (#11173) — what a fal clip ends on */}
+ {onGenerateEndFrame && layer === 'footage' && (
+ <SceneEndFrame scene={scene} index={index} generating={!!generatingEndFrame} onGenerate={onGenerateEndFrame}
+ onEditLocal={onEditLocal} onSave={onSave} onOpenPreview={onOpenPreview} takeBusy={takeBusy}
+ onSelectTake={onSelectTake} onReviewTake={onReviewTake} videoSettings={falVideoSettings} />
+ )}
{/* Scene clip — i2v video generated from the reference frame (Phase 1) */}
<div className="flex items-center gap-2 flex-wrap">
{scene.videoHistoryId && performance && (
diff --git a/client/src/components/musicVideo/SceneEndFrame.jsx b/client/src/components/musicVideo/SceneEndFrame.jsx
new file mode 100644
index 0000000000..3709326e2c
--- /dev/null
+++ b/client/src/components/musicVideo/SceneEndFrame.jsx
@@ -0,0 +1,78 @@
+import { Activity, Wand2, X } from 'lucide-react';
+import SceneTakeStrip from './SceneTakeStrip.jsx';
+import { sceneEndFramePlan } from '../../../../server/lib/musicVideoEndFrame.js';
+
+/**
+ * A scene's optional style-break end frame (#11173): a still the clip moves
+ * into from its photographic start frame, such as a pencil-sketch rotoscope or
+ * a magazine-cutout collage. The director describes it, renders it from the
+ * selected start frame, and picks among its takes like any frame. A fal clip on
+ * a model that takes an end frame ends on it; the note says when the current
+ * renderer will ignore it.
+ */
+export default function SceneEndFrame({
+ scene, index, generating = false, onGenerate, onEditLocal, onSave, onOpenPreview,
+ takeBusy = false, onSelectTake, onReviewTake, videoSettings = null,
+}) {
+ const settings = videoSettings || {};
+ // Same mode the clip request is built with (useMusicVideoSceneMedia generateSceneVideo).
+ const mode = settings.generationMode === 'suppliedAudio' || (settings.backend === 'local' && settings.generationMode === 'audioReactive') ? 'a2v' : 'image';
+ const plan = sceneEndFramePlan(scene, { backend: settings.backend || null, falModelId: settings.falModelId || null, mode });
+ const promptId = `mv-scene-${scene.sceneId}-end-frame-prompt`;
+ return (
+ <details className="rounded border border-port-border bg-port-bg/40 px-2 py-1.5" open={Boolean(scene.endImageId || scene.endFramePrompt)}>
+ <summary className="cursor-pointer text-xs text-port-text-muted min-h-[44px] sm:min-h-0 flex items-center">
+ End frame (style break){scene.endImageId ? ' · set' : ''}
+ </summary>
+ <div className="mt-2 space-y-2">
+ <div className="flex flex-col gap-2 sm:flex-row sm:items-start">
+ <div className="flex-1 min-w-0">
+ <label htmlFor={promptId} className="sr-only">End frame prompt</label>
+ <textarea
+ id={promptId}
+ value={scene.endFramePrompt || ''} rows={2}
+ onChange={(e) => onEditLocal(scene.sceneId, { endFramePrompt: e.target.value })}
+ onBlur={(e) => onSave(scene.sceneId, { endFramePrompt: e.target.value || null })}
+ placeholder="What the last frame becomes, e.g. the same frame as a pencil-sketch rotoscope"
+ className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
+ />
+ </div>
+ <div className="flex items-center gap-2">
+ {scene.endImageId && (
+ <div className="relative shrink-0">
+ <button type="button" onClick={() => onOpenPreview?.(`image:${scene.endImageId}`)}
+ aria-label={`View scene ${index + 1} end frame full size`}
+ className="block rounded border border-port-border overflow-hidden focus:outline-none focus:ring-2 focus:ring-port-accent">
+ <img src={`/data/images/${encodeURIComponent(scene.endImageId)}`} alt="" className="w-32 aspect-video object-cover block" />
+ </button>
+ <button type="button" onClick={() => { onEditLocal(scene.sceneId, { endImageId: null }); onSave(scene.sceneId, { endImageId: null }); }}
+ aria-label={`Clear scene ${index + 1} end frame`} title="Clear the end frame (its takes stay)"
+ className="always-dark absolute top-1 right-1 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 p-1 flex items-center justify-center rounded bg-black/50 text-white hover:bg-black/80">
+ <X className="w-3 h-3" />
+ </button>
+ </div>
+ )}
+ <button type="button" onClick={() => onGenerate?.(scene)}
+ disabled={generating || !scene.referenceImageId || !scene.endFramePrompt?.trim()}
+ title={!scene.referenceImageId ? 'Generate a reference frame first'
+ : !scene.endFramePrompt?.trim() ? 'Describe the end frame first'
+ : 'Render the end frame from this scene\'s selected start frame'}
+ className="flex items-center gap-1 bg-port-border hover:bg-port-border/70 disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0 whitespace-nowrap">
+ {generating ? <Activity size={14} className="animate-spin" /> : <Wand2 size={14} />}
+ {generating ? 'Generating end frame…' : (scene.endImageId ? 'New end frame take' : 'Generate end frame')}
+ </button>
+ </div>
+ </div>
+ {scene.endImageId && (
+ <p className={`text-[11px] ${plan.used ? 'text-port-text-muted' : 'text-port-warning'}`}>
+ {plan.used ? 'The clip ends on this frame.' : plan.reason}
+ </p>
+ )}
+ <SceneTakeStrip scene={scene} kind="endImage" busy={takeBusy}
+ onSelect={(take) => onSelectTake?.(scene, take)}
+ onReview={(take, review) => onReviewTake?.(scene, take, review)}
+ onOpenPreview={onOpenPreview} />
+ </div>
+ </details>
+ );
+}
diff --git a/client/src/components/musicVideo/SceneTakeStrip.jsx b/client/src/components/musicVideo/SceneTakeStrip.jsx
index 520ff8dab3..ca296033fb 100644
--- a/client/src/components/musicVideo/SceneTakeStrip.jsx
+++ b/client/src/components/musicVideo/SceneTakeStrip.jsx
@@ -4,7 +4,7 @@ import { sceneTakeList, takePreviewKey, takeThumbUrl, takeClipUrl, takeProvenanc
import { plateVerdict } from './PlateComparison.jsx';
const VERDICT_TONE = { pass: 'bg-port-success/20 text-port-success', fail: 'bg-port-error/20 text-port-error', unverified: 'bg-port-warning/20 text-port-warning' };
-const KIND_LABEL = { image: 'Frame takes', video: 'Clip takes' };
+const KIND_LABEL = { image: 'Frame takes', video: 'Clip takes', endImage: 'End frame takes' };
/**
* Side-by-side review of one scene slot's takes (#8965): every render or
@@ -56,7 +56,7 @@ export default function SceneTakeStrip({
onMouseLeave={() => setPlayingId(null)}
onFocus={() => setPlayingId(playKey)}
onBlur={() => setPlayingId(null)}
- aria-label={`View ${kind === 'image' ? 'frame' : 'clip'} take full size`}
+ aria-label={`View ${kind === 'video' ? 'clip' : 'frame'} take full size`}
className={`relative block w-full rounded overflow-hidden border focus:outline-none focus:ring-2 focus:ring-port-accent ${isSelected ? 'border-port-accent ring-2 ring-port-accent' : 'border-port-border'} ${rejected ? 'opacity-40' : ''}`}
>
<img src={takeThumbUrl(take)} alt="" loading="lazy" className="w-full aspect-video object-cover block bg-black" />
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index 74dd4b5ae9..d676682895 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -189,6 +189,8 @@ export default function BoardStage({ board }) {
onEditLocal={board.editSceneLocal}
onSave={board.saveScene}
onGenerateFrame={sceneMedia.generateFrame}
+ onGenerateEndFrame={sceneMedia.generateEndFrame}
+ generatingEndFrame={sceneMedia.genEndFrameScenes?.[scene.sceneId]}
onGenerateVideo={sceneMedia.generateSceneVideo}
onContinueVideo={sceneMedia.continueSceneVideo}
onOpenPreview={board.openPreview}
diff --git a/client/src/hooks/useMusicVideoSceneMedia.js b/client/src/hooks/useMusicVideoSceneMedia.js
index 7b5f9048c9..c4cbccd721 100644
--- a/client/src/hooks/useMusicVideoSceneMedia.js
+++ b/client/src/hooks/useMusicVideoSceneMedia.js
@@ -2,6 +2,7 @@ import { shotActionContractProblem, shotActionPrompt } from '../../../server/lib
import { shotCameraPrompt } from '../../../server/lib/cameraMovements.js';
import { isOutsideMusicVideoReference, musicVideoConditioningReferences, MUSIC_VIDEO_MAX_CONDITIONING_REFERENCES } from '../../../server/lib/musicVideoConditioning.js';
import { musicVideoCreativeContext, musicVideoDirectorLook } from '../../../server/lib/musicVideoCreativeContext.js';
+import { sceneEndFrameRequestFields } from '../../../server/lib/musicVideoEndFrame.js';
import { useEffect, useRef } from 'react';
import socket from '../services/socket';
import toast from '../components/ui/Toast';
@@ -111,11 +112,24 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
startedEvent: 'image-gen:started',
progressEvent: 'image-gen:progress',
onSettled: frameBatch.settled,
- apply: ({ projectId, sceneId, referenceImageId, takes, lastFailure }) =>
- applyScenePatch?.(projectId, sceneId, { referenceImageId, ...(Array.isArray(takes) ? { takes } : {}), ...(lastFailure !== undefined ? { lastFailure } : {}) }),
+ // The same event lands start and end frames (#11173), so it folds in both slots.
+ apply: ({ projectId, sceneId, referenceImageId, endImageId, takes, lastFailure }) =>
+ applyScenePatch?.(projectId, sceneId, { referenceImageId, ...(endImageId !== undefined ? { endImageId } : {}), ...(Array.isArray(takes) ? { takes } : {}), ...(lastFailure !== undefined ? { lastFailure } : {}) }),
failMessage: 'Frame render failed',
sceneLabel,
});
+ // Style-break end frames (#11173): their own spinners, so a scene can render
+ // its start and end frame at once. The frame lane above applies the landed
+ // still (both ride music-video:scene-image), so this lane only tracks jobs.
+ const endFrameLane = useSceneRenderLifecycle({
+ attachEvent: 'music-video:scene-image',
+ completedEvent: 'image-gen:completed',
+ failedEvent: 'image-gen:failed',
+ canceledEvent: 'image-gen:canceled',
+ apply: () => {},
+ failMessage: 'End frame render failed',
+ sceneLabel,
+ });
const videoLane = useSceneRenderLifecycle({
attachEvent: 'music-video:scene-video',
completedEvent: 'video-gen:completed',
@@ -146,6 +160,7 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
const projectId = project?.id;
const { restoreJobs: restoreFrameJobs } = frameLane;
const { restoreJobs: restoreVideoJobs } = videoLane;
+ const { restoreJobs: restoreEndFrameJobs } = endFrameLane;
useEffect(() => {
if (!projectId) return undefined;
let live = true;
@@ -154,10 +169,11 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
if (!live || !Array.isArray(jobs)) return;
restoreFrameJobs(jobs.filter((j) => j.lane === 'image'));
restoreVideoJobs(jobs.filter((j) => j.lane === 'video'));
+ restoreEndFrameJobs(jobs.filter((j) => j.lane === 'endImage'));
})
.catch(() => {}); // best-effort: a failed lookup just means no restored spinners
return () => { live = false; };
- }, [projectId, restoreFrameJobs, restoreVideoJobs]);
+ }, [projectId, restoreFrameJobs, restoreVideoJobs, restoreEndFrameJobs]);
const genScenes = frameLane.genScenes;
const genVideoScenes = videoLane.genScenes;
const failedScenes = { frame: frameLane.failedScenes, video: videoLane.failedScenes };
@@ -254,6 +270,52 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
});
};
+ /**
+ * Render a style-break end frame (#11173): the scene's end-frame prompt
+ * (e.g. "the same frame as a pencil-sketch rotoscope") conditioned on its
+ * selected start frame, so the composition carries over and only the look
+ * changes. It lands as an `endImage` take (musicVideoSceneImageHook files the
+ * `slot: 'end'` tag); a fal clip on a model that takes an end frame then ends
+ * on it. Resolves `{ ok }` like generateFrame.
+ */
+ const generateEndFrame = (scene) => {
+ if (!scene.referenceImageId) { toast.error('Generate a reference frame first'); return Promise.resolve({ ok: false }); }
+ const endPrompt = scene.endFramePrompt?.trim();
+ if (!endPrompt) { toast.error('Describe the end frame first'); return Promise.resolve({ ok: false }); }
+ const projectId = project.id;
+ endFrameLane.startScene(scene.sceneId);
+ return generateImage({
+ prompt: `${endPrompt}. Keep the reference image's composition, subject, pose and framing; change only the visual style.`,
+ ...musicVideoFrameGenSize(project),
+ referenceImageFiles: [scene.referenceImageId],
+ musicVideo: { projectId, sceneId: scene.sceneId, slot: 'end' },
+ }, { silent: true })
+ .then((res) => {
+ if (res?.status === 'queued' || res?.status === 'running') {
+ const jobId = res?.jobId || res?.generationId;
+ if (!jobId) { endFrameLane.clearScene(scene.sceneId); return { ok: false }; }
+ endFrameLane.trackJob(jobId, scene.sceneId);
+ return { ok: true, jobId };
+ }
+ if (res?.filename) {
+ addMusicVideoSceneTake(projectId, scene.sceneId, { kind: 'endImage', assetId: res.filename, source: 'generated' }, { silent: true })
+ .then(({ scene: updated }) => applyScenePatch?.(projectId, scene.sceneId, {
+ endImageId: updated.endImageId ?? null, takes: updated.takes,
+ }))
+ .catch((err) => toast.error(err?.message || 'Failed to attach end frame'));
+ }
+ endFrameLane.clearScene(scene.sceneId);
+ return { ok: true };
+ })
+ .catch((err) => {
+ toast.error(REFERENCE_CAPABILITY_CODES.has(err?.code)
+ ? `The current image backend can't render from the start frame: ${err.message}. Switch the image backend to one that takes a reference image.`
+ : err?.message || 'End frame generation failed');
+ endFrameLane.clearScene(scene.sceneId);
+ return { ok: false };
+ });
+ };
+
// Correlate a kicked-off video job with its scene, or clear the spinner when
// the response carried no id to track. trackJob reconciles a terminal event
// that raced ahead of this .then. Resolves `{ ok }` — see generateFrame's
@@ -307,6 +369,10 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
const prompt = audioReactiveSelected
? `${basePrompt}. ${AUDIO_REACTIVE_PERFORMANCE_GUARD}`
: [basePrompt, motionCues].filter(Boolean).join('. ');
+ const mode = audioReactiveSelected || settings.generationMode === 'suppliedAudio' ? 'a2v' : 'image';
+ const falFields = settings.backend === 'fal'
+ ? falTakeRequestFields(falSceneTake({ scene, videoSettings: settings, songDurationSec: project?.audioAnalysis?.durationSec ?? null }))
+ : null;
videoLane.startScene(scene.sceneId);
return generateVideo({
prompt,
@@ -321,16 +387,18 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
// pinned length) and its resolution; a performance clip's length
// follows its song slice (server-side), so it sends only the lip-sync
// resolution.
- : settings.backend === 'fal'
- ? falTakeRequestFields(falSceneTake({ scene, videoSettings: settings, songDurationSec: project?.audioAnalysis?.durationSec ?? null }))
+ : falFields
+ ? falFields
: settings.backend === 'local'
? { modelId: settings.modelId || undefined, disableAudio: true }
// A named model is local-only machinery at the server boundary and
// would force the resolver off a Grok install default. Keep the
// shared pin saved, but omit it until this peer chooses Local.
: { grokDuration: settings.grokDuration, disableAudio: true }),
- mode: audioReactiveSelected || settings.generationMode === 'suppliedAudio' ? 'a2v' : 'image',
+ mode,
sourceImageFile: scene.referenceImageId,
+ // A style-break end frame (#11173), when this fal model takes one.
+ ...sceneEndFrameRequestFields(scene, { backend: settings.backend, falModelId: falFields?.falModelId, mode }),
...(audioReactiveSelected ? {
audioStartSec: scene.startSec || 0,
loraFilenames: [detectedAudioReactiveLora.filename],
@@ -430,6 +498,7 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
genScenes,
genVideoScenes,
failedScenes,
+ genEndFrameScenes: endFrameLane.genScenes,
sceneProgress: frameLane.sceneProgress,
videoSceneProgress: videoLane.sceneProgress,
frameBatch,
@@ -438,6 +507,7 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
buildFramePrompt,
buildShotPrompt,
generateFrame,
+ generateEndFrame,
generateSceneVideo,
continueSceneVideo,
planMissingFrames,
diff --git a/client/src/hooks/useMusicVideoSceneMedia.test.jsx b/client/src/hooks/useMusicVideoSceneMedia.test.jsx
index 44860900e2..5a9a2b98db 100644
--- a/client/src/hooks/useMusicVideoSceneMedia.test.jsx
+++ b/client/src/hooks/useMusicVideoSceneMedia.test.jsx
@@ -1,11 +1,17 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { renderHook, act, cleanup, waitFor } from '@testing-library/react';
-const handlers = new Map();
+// Every listener per event, like the real socket: the frame and end-frame
+// lanes both listen on music-video:scene-image (#11173).
+const listeners = new Map();
+const handlers = {
+ get: (event) => (data) => [...(listeners.get(event) || [])].forEach((fn) => fn(data)),
+ clear: () => listeners.clear(),
+};
vi.mock('../services/socket', () => ({
default: {
- on: (event, fn) => { handlers.set(event, fn); },
- off: (event, fn) => { if (handlers.get(event) === fn) handlers.delete(event); },
+ on: (event, fn) => { listeners.set(event, new Set([...(listeners.get(event) || []), fn])); },
+ off: (event, fn) => { listeners.get(event)?.delete(fn); },
emit: () => {},
},
}));
diff --git a/client/src/hooks/useMusicVideoTakes.js b/client/src/hooks/useMusicVideoTakes.js
index ddcdf4c11d..64e6231918 100644
--- a/client/src/hooks/useMusicVideoTakes.js
+++ b/client/src/hooks/useMusicVideoTakes.js
@@ -50,6 +50,7 @@ export default function useMusicVideoTakes({ project, applyScenePatch }) {
const applyScene = (projectId, scene) => applyScenePatch?.(projectId, scene.sceneId, {
referenceImageId: scene.referenceImageId ?? null,
videoHistoryId: scene.videoHistoryId ?? null,
+ endImageId: scene.endImageId ?? null,
takes: scene.takes || [],
});
diff --git a/client/src/lib/musicVideoTakes.js b/client/src/lib/musicVideoTakes.js
index 1e8cd2019f..e9c7aff6d3 100644
--- a/client/src/lib/musicVideoTakes.js
+++ b/client/src/lib/musicVideoTakes.js
@@ -8,7 +8,8 @@
* `legacy` take rather than hiding it.
*/
-export const TAKE_SLOT = Object.freeze({ image: 'referenceImageId', video: 'videoHistoryId' });
+// `endImage` (#11173): the optional style-break end frame a fal clip ends on.
+export const TAKE_SLOT = Object.freeze({ image: 'referenceImageId', video: 'videoHistoryId', endImage: 'endImageId' });
/** The takes of one kind for a scene, with an un-materialized selection appended. */
export function sceneTakeList(scene, kind) {
@@ -20,11 +21,11 @@ export function sceneTakeList(scene, kind) {
return takes;
}
-/** Preview/lightbox key for a take (`image:<filename>` / `video:<historyId>`). */
-export const takePreviewKey = (take) => `${take.kind}:${take.assetId}`;
+/** Preview/lightbox key for a take (`image:<filename>` / `video:<historyId>`); an end frame is a gallery image. */
+export const takePreviewKey = (take) => `${take.kind === 'video' ? 'video' : 'image'}:${take.assetId}`;
/** Thumbnail URL for a take: the gallery still, or the clip's generated poster. */
-export const takeThumbUrl = (take) => (take.kind === 'image'
+export const takeThumbUrl = (take) => (take.kind !== 'video'
? `/data/images/${encodeURIComponent(take.assetId)}`
: `/data/video-thumbnails/${encodeURIComponent(take.assetId)}.jpg`);
@@ -33,7 +34,7 @@ export const takeClipUrl = (take) => `/data/videos/${encodeURIComponent(take.ass
/** Scenes whose slot still has an undecided candidate (a candidate that is not the selection). */
export function sceneHasPendingDecision(scene) {
- return ['image', 'video'].some((kind) => {
+ return Object.keys(TAKE_SLOT).some((kind) => {
const selected = scene?.[TAKE_SLOT[kind]] || null;
return sceneTakeList(scene, kind).some((t) => t.takeId && t.status === 'candidate' && t.assetId !== selected);
});
diff --git a/server/lib/README.md b/server/lib/README.md
index 93d4e1e33c..1af5819ffb 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -859,6 +859,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `filmLookValidation.js` | `filmLookSchema` / `filmLookBakeSchema`: the Zod shape of a film look, derived from `FILM_LOOK_CONTROLS`. |
| `musicVideoTitleCard.js` | The MTV-style opening title card (song, artist, year over the opener): `normalizeTitleCard`, `titleCardVisible`, `titleCardPrefill` (a new card's text and a window ending before the first sung line), and `titleCardRuntimeSource` (the page script the live preview and the document render install to draw it per seek, with its fade and title-safe layout). Browser-safe. |
| `musicVideoDependencies.js` | Versioned take/evidence provenance, dependency comparisons and bounded selective-repair previews. |
+| `musicVideoEndFrame.js` | Style-break end frames (#11173): `sceneEndFramePlan(scene, { backend, falModelId })` says whether a clip sends the scene's end frame (only fal models with an end image, never a performance shot) and why not; `sceneEndFrameRequestFields` turns it into `lastImageFile`. Shared by the board and production. |
| `musicVideoCrossLinks.js` | Cross-links between a release's posts: each post's public link, the `Label: url` lines a new draft adds, which links a posted record carries (`links`, or what its draft always linked), and `crossLinkBackfill(kit)` listing the links each editable post (YouTube, Suno, X, Stacker News) still lacks. Shared by the publish payloads and the Publish stage. |
| `musicVideoExcerptRange.js` | `excerptRangeFits(startSec, endSec, totalSec, fps)`: whether a code/document excerpt window fits a frame-quantized render, allowing the end up to one frame past it (scene ends follow the analysed song length; the caller clamps). The start must fall inside the render; an unknown fps allows no slack. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 6052f32eaf..ebfe971f90 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -837,6 +837,7 @@ export * from './filmLook.js';
export * from './filmLookValidation.js';
export * from './musicVideoTitleCard.js';
export * from './musicVideoDependencies.js';
+export * from './musicVideoEndFrame.js';
export * from './musicVideoCrossLinks.js';
export * from './musicVideoExcerptRange.js';
diff --git a/server/lib/musicVideoDependencies.js b/server/lib/musicVideoDependencies.js
index d5fef203ef..6d05a0921d 100644
--- a/server/lib/musicVideoDependencies.js
+++ b/server/lib/musicVideoDependencies.js
@@ -2,10 +2,12 @@
import { canonicalSnapshotChecksum } from './snapshotChecksum.js';
export const MUSIC_VIDEO_DEPENDENCY_VERSION = 1;
-const slots = { plate: 'referenceImageId', clip: 'videoHistoryId' };
+// `endPlate` (#11173): the style-break end frame a fal clip was generated to end on.
+const slots = { plate: 'referenceImageId', clip: 'videoHistoryId', endPlate: 'endImageId' };
+const takeKinds = { plate: 'image', clip: 'video', endPlate: 'endImage' };
const checksum = (value) => canonicalSnapshotChecksum(value);
const selectedTake = (scene, role, assetId = scene?.[slots[role]]) => (scene?.takes || [])
- .find((take) => take.kind === (role === 'plate' ? 'image' : 'video') && take.assetId === assetId);
+ .find((take) => take.kind === takeKinds[role] && take.assetId === assetId);
const assetRef = (scene, role, assetId = scene?.[slots[role]]) => ({
role, sceneId: scene.sceneId, assetId: assetId || null,
revision: checksum({ assetId: assetId || null, inputs: selectedTake(scene, role, assetId)?.inputAssets || [] }),
@@ -19,9 +21,12 @@ const layerRef = (scene) => ({ role: 'layer', sceneId: scene.sceneId, assetId: s
.concat(scene.performanceStyle === 'music' ? [['performanceStyle', 'music']] : []))) });
const snapshot = (references) => ({ version: MUSIC_VIDEO_DEPENDENCY_VERSION, references });
-/** Capture the actual submitted plate, including optional crop/mask provenance. */
-export function captureTakeDependencies(scene, sourceImageId = scene?.referenceImageId) {
- return snapshot(sourceImageId ? [assetRef(scene, 'plate', sourceImageId)] : []);
+/** Capture the actual submitted plate (and end frame), including optional crop/mask provenance. */
+export function captureTakeDependencies(scene, sourceImageId = scene?.referenceImageId, endImageId = null) {
+ return snapshot([
+ ...(sourceImageId ? [assetRef(scene, 'plate', sourceImageId)] : []),
+ ...(endImageId ? [assetRef(scene, 'endPlate', endImageId)] : []),
+ ]);
}
const intersects = (scene, startSec, endSec) => !(typeof scene.startSec === 'number' && typeof scene.endSec === 'number')
@@ -78,7 +83,7 @@ export function musicVideoDependencyChanges(project, dependencies) {
else if (slots[ref.role]) current = assetRef(scene, ref.role);
else if (ref.role === 'layer') current = layerRef(scene);
if (!current || current.assetId !== ref.assetId || current.revision !== ref.revision) {
- changes.push({ ...ref, reason: `${ref.role === 'song' ? 'Master audio, lyrics or alignment' : ref.role === 'plate' ? 'Selected plate or its crop/mask inputs' : ref.role === 'clip' ? 'Selected clip' : ref.role === 'layer' ? 'Shot timing or composition layer' : 'Composition'} changed` });
+ changes.push({ ...ref, reason: `${ref.role === 'song' ? 'Master audio, lyrics or alignment' : ref.role === 'plate' ? 'Selected plate or its crop/mask inputs' : ref.role === 'endPlate' ? 'Selected end frame' : ref.role === 'clip' ? 'Selected clip' : ref.role === 'layer' ? 'Shot timing or composition layer' : 'Composition'} changed` });
}
}
return changes;
diff --git a/server/lib/musicVideoEndFrame.js b/server/lib/musicVideoEndFrame.js
new file mode 100644
index 0000000000..9aeee2a317
--- /dev/null
+++ b/server/lib/musicVideoEndFrame.js
@@ -0,0 +1,38 @@
+/**
+ * Music Video style-break end frames (#11173).
+ *
+ * A scene may carry an optional end frame (`scene.endImageId`, the selected
+ * `endImage` take): a stylized still the clip moves into from its photographic
+ * start frame, such as a pencil-sketch or magazine-cutout version. Only fal
+ * models whose catalog entry takes an end image can honour it. Every other lane
+ * ignores it, and this module says why, so the board and the production
+ * dispatcher make the same call.
+ */
+import { FAL_DEFAULT_IMAGE_VIDEO_MODEL, getFalVideoModel } from './falVideoModels.js';
+import { isPerformanceScene } from './musicVideoShotTiming.js';
+
+const endImageOf = (scene) => (typeof scene?.endImageId === 'string' && scene.endImageId.trim() ? scene.endImageId : null);
+
+/**
+ * Whether a clip for `scene` on `backend` (with `falModelId` for fal, and the
+ * request's video `mode`, image-to-video by default) sends the scene's end
+ * frame. Returns `{ endImageId, used, reason }`: `reason` names why a selected
+ * end frame is ignored, and is null when it is used or absent.
+ */
+export function sceneEndFramePlan(scene, { backend = null, falModelId = null, mode = 'image' } = {}) {
+ const endImageId = endImageOf(scene);
+ if (!endImageId) return { endImageId: null, used: false, reason: null };
+ const ignored = (reason) => ({ endImageId, used: false, reason });
+ if (isPerformanceScene(scene)) return ignored('A performance shot follows the song and takes no end frame');
+ if (mode !== 'image') return ignored('A song-driven clip takes no end frame');
+ if (backend !== 'fal') return ignored('Only fal.ai models that take an end frame use it; this renderer ignores it');
+ const model = getFalVideoModel(falModelId || FAL_DEFAULT_IMAGE_VIDEO_MODEL);
+ if (!model?.endImage) return ignored(`${model?.label || 'This fal.ai model'} takes no end frame; choose one that does`);
+ return { endImageId, used: true, reason: null };
+}
+
+/** The `/api/video-gen` field that carries the end frame, or nothing. */
+export const sceneEndFrameRequestFields = (scene, options) => {
+ const plan = sceneEndFramePlan(scene, options);
+ return plan.used ? { lastImageFile: plan.endImageId } : {};
+};
diff --git a/server/lib/musicVideoMediaPolicy.js b/server/lib/musicVideoMediaPolicy.js
index b97cd9def2..b1f7f918aa 100644
--- a/server/lib/musicVideoMediaPolicy.js
+++ b/server/lib/musicVideoMediaPolicy.js
@@ -14,6 +14,8 @@ export function musicVideoMediaMode(project) {
}
export function musicVideoAllowsMedia(project, kind) {
const mode = musicVideoMediaMode(project);
+ // A style-break end frame (#11173) is an image like the start frame.
+ if (kind === 'endImage') kind = 'image';
return kind === 'image' ? mode !== 'code-only' : kind === 'video' ? mode === 'code-images-video' : true;
}
export function assertMusicVideoMedia(project, kind, purpose = 'asset') {
@@ -25,7 +27,7 @@ export function assertMusicVideoMedia(project, kind, purpose = 'asset') {
export function assertMusicVideoMediaSelections(project) {
if (project?.visualSpec?.references?.length || project?.visualSpec?.moodBoardId || project?.styleReferences?.some((ref) => ref.imageId)) assertMusicVideoMedia(project, 'image', 'references');
for (const scene of project?.scenes || []) {
- if (scene.referenceImageId) assertMusicVideoMedia(project, 'image', 'selection');
+ if (scene.referenceImageId || scene.endImageId) assertMusicVideoMedia(project, 'image', 'selection');
if (scene.videoHistoryId) assertMusicVideoMedia(project, 'video', 'selection');
}
}
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 92f0584bd9..24539db856 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -283,7 +283,8 @@ export const musicVideoVisualSpecSchema = z.object({
{ message: `at most ${MUSIC_VIDEO_MAX_CONDITIONING_REFERENCES} references can condition frames`, path: ['references'] },
);
-export const MUSIC_VIDEO_TAKE_KINDS = ['image', 'video'];
+// `endImage` (#11173): a candidate for the scene's optional style-break end frame.
+export const MUSIC_VIDEO_TAKE_KINDS = ['image', 'video', 'endImage'];
export const MUSIC_VIDEO_TAKE_STATUSES = ['candidate', 'rejected'];
// A take's intended use (#8980). A `motion-reference` take is scaffolding (e.g.
// generated footage to trace a hand-drawn pass over): it is kept as a candidate
@@ -308,7 +309,7 @@ export const musicVideoTakeInputSchema = z.object({
inputAssets: z.array(z.object({ role: z.enum(['crop', 'mask']), assetId: galleryImageName, revision: z.number().int().min(1).max(1000000) }).strict()).max(4).optional(),
use: z.enum(MUSIC_VIDEO_TAKE_USES).optional(),
}).strict().superRefine((take, ctx) => {
- const check = take.kind === 'image' ? galleryImageName : videoHistoryIdSchema;
+ const check = take.kind === 'video' ? videoHistoryIdSchema : galleryImageName;
const parsed = check.safeParse(take.assetId);
if (!parsed.success) ctx.addIssue({ code: 'custom', path: ['assetId'], message: parsed.error.issues[0].message });
});
@@ -1434,6 +1435,10 @@ export const musicVideoSceneUpdateSchema = z.object({
performanceStyle: z.enum(MUSIC_VIDEO_PERFORMANCE_STYLES).nullable().optional(),
referenceImageId: z.string().max(256).nullable().optional(),
videoHistoryId: z.string().max(64).nullable().optional(),
+ // #11173: an optional style-break end frame (the selected `endImage` take)
+ // and the prompt that renders it from the start frame.
+ endImageId: z.string().max(256).nullable().optional(),
+ endFramePrompt: z.string().max(8000).nullable().optional(),
// #10154: the last generation failure the render hooks persisted. The board
// may send `null` to dismiss it; a full object is accepted so a client that
// round-trips the scene doesn't 400.
diff --git a/server/routes/imageGen.js b/server/routes/imageGen.js
index c9e275a732..10432f33d9 100644
--- a/server/routes/imageGen.js
+++ b/server/routes/imageGen.js
@@ -235,6 +235,9 @@ const generateSchema = z.object({
// Selective section revision (#9011): see the matching comment on the
// video route's musicVideo schema (server/routes/videoGen.js).
revisionId: z.string().min(1).max(200).optional(),
+ // #11173: 'end' files the render as the scene's style-break end frame
+ // (an `endImage` take) instead of its start frame.
+ slot: z.enum(['end']).optional(),
}).optional(),
// Durable catalog attach (#1359). When present, the mediaJobQueue completion
// hook (catalogImageAttachHook) files the finished render onto this catalog
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index 5fd92760f6..1ef8000110 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -1501,7 +1501,7 @@ router.post('/:id/scenes/:sceneId/merge-next', asyncHandler(async (req, res) =>
// a clip in the video history (both reached through the existing upload
// routes) — so a take can never point at an arbitrary file.
async function takeAssetExists(kind, assetId) {
- if (kind === 'image') return Boolean(resolveGalleryImage(assetId));
+ if (kind !== 'video') return Boolean(resolveGalleryImage(assetId));
return Boolean(await getHistoryItem(assetId));
}
@@ -1510,7 +1510,7 @@ async function takeAssetExists(kind, assetId) {
router.post('/:id/scenes/:sceneId/takes', asyncHandler(async (req, res) => {
const { kind, assetId, source = 'imported', provider, originalName, use, sourceImageId, inputAssets } = validateRequest(musicVideoTakeInputSchema, req.body);
if (!(await takeAssetExists(kind, assetId))) {
- throw new ServerError(`${kind === 'image' ? 'Image' : 'Video'} not found in this install's media library`, { status: 400, code: 'TAKE_ASSET_NOT_FOUND' });
+ throw new ServerError(`${kind === 'video' ? 'Video' : 'Image'} not found in this install's media library`, { status: 400, code: 'TAKE_ASSET_NOT_FOUND' });
}
for (const imageId of [sourceImageId, ...(inputAssets || []).map((input) => input.assetId)].filter(Boolean)) {
if (!(await takeAssetExists('image', imageId))) throw new ServerError('Dependency image not found', { status: 400, code: 'TAKE_ASSET_NOT_FOUND' });
diff --git a/server/services/musicVideo/events.js b/server/services/musicVideo/events.js
index 335ee476cd..1bd65ff427 100644
--- a/server/services/musicVideo/events.js
+++ b/server/services/musicVideo/events.js
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
// Event bus for Music Video async side effects that need to reach the client
// after the originating HTTP request has returned. It carries:
//
-// 'scene-image' → { projectId, sceneId, referenceImageId, takes, takeId }
+// 'scene-image' → { projectId, sceneId, referenceImageId, endImageId, takes, takeId }
// 'scene-video' → { projectId, sceneId, videoHistoryId, takes, takeId }
//
// emitted by `musicVideoSceneImageHook` / `musicVideoSceneVideoHook` once an
diff --git a/server/services/musicVideo/productionDispatch.js b/server/services/musicVideo/productionDispatch.js
index 75a812f4a0..6f96f92c00 100644
--- a/server/services/musicVideo/productionDispatch.js
+++ b/server/services/musicVideo/productionDispatch.js
@@ -31,6 +31,7 @@ import { resolveGalleryImage } from '../../lib/pathSafety.js';
import { RENDER_TARGET } from '../../lib/renderTargets.js';
import { approximateMotionCues, falSceneTake, falTakeRequestFields, grokCoverage } from '../../lib/musicVideoShotTiming.js';
import { sceneFramePrompt, sceneShotPrompt } from './handoff.js';
+import { sceneEndFrameRequestFields } from '../../lib/musicVideoEndFrame.js';
import { conditioningReferences, falRouteVideoSettings } from './productionPool.js';
import { musicVideoFrameGenSize } from '../../lib/musicVideoAspect.js';
@@ -133,6 +134,8 @@ async function dispatchClip({ project, scene, route, tag }) {
mode: 'image',
sourceImageFile: scene.referenceImageId,
...(byBackend[route.mode] || {}),
+ // A style-break end frame (#11173), when this fal model takes one.
+ ...sceneEndFrameRequestFields(scene, { backend: route.mode, falModelId: byBackend.fal?.falModelId }),
musicVideo: tag,
}, {});
return { jobId };
diff --git a/server/services/musicVideo/productionDispatch.test.js b/server/services/musicVideo/productionDispatch.test.js
index 93c5b90f78..d365565e72 100644
--- a/server/services/musicVideo/productionDispatch.test.js
+++ b/server/services/musicVideo/productionDispatch.test.js
@@ -181,4 +181,20 @@ describe('production scene dispatch (#9066)', () => {
expect(performance).not.toHaveProperty('falDuration');
expect(performance).not.toHaveProperty('falModelId');
});
+
+ // Uniquely catches a style-break end frame (#11173) never reaching fal, or
+ // reaching a model or renderer that takes none.
+ it('sends the scene end frame only to a fal model that takes one', async () => {
+ const clipTag = { ...tag, productionStepKey: 'clip:mvs-a:base:1' };
+ const styleBreak = { ...scene, endImageId: 'end-example.png' };
+ const onModel = (falModelId) => ({ ...project, videoSettings: { backend: 'fal', falModelId } });
+ const fal = { kind: 'video', mode: 'fal', model: null };
+ await dispatchProductionStep({ stepKind: 'clip', project: onModel('fal-ai/kling-video/v3/pro/image-to-video'), scene: styleBreak, route: fal, tag: clipTag, settings });
+ expect(submitVideoGenJob.mock.calls[0][0]).toMatchObject({ backend: 'fal', mode: 'image', sourceImageFile: 'frame-example.png', lastImageFile: 'end-example.png' });
+ await dispatchProductionStep({ stepKind: 'clip', project: onModel('fal-ai/veo3.1/fast/image-to-video'), scene: styleBreak, route: fal, tag: clipTag, settings });
+ await dispatchProductionStep({ stepKind: 'clip', project, scene: styleBreak, route: { kind: 'video', mode: 'grok', model: null }, tag: clipTag, settings });
+ await dispatchProductionStep({ stepKind: 'clip', project: onModel('fal-ai/kling-video/v3/pro/image-to-video'), scene, route: fal, tag: clipTag, settings });
+ for (const call of submitVideoGenJob.mock.calls.slice(1)) expect(call[0]).not.toHaveProperty('lastImageFile');
+ });
});
+
diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.js
index df22c107ff..ed8e857435 100644
--- a/server/services/musicVideo/projectsLogic.js
+++ b/server/services/musicVideo/projectsLogic.js
@@ -217,6 +217,7 @@ export function cloneProjectRecord(source, {
order,
referenceImageId: includeGeneratedMedia ? (scene.referenceImageId ?? null) : null,
videoHistoryId: includeGeneratedMedia ? (scene.videoHistoryId ?? null) : null,
+ endImageId: includeGeneratedMedia ? (scene.endImageId ?? null) : null,
// Takes are immutable pointers to shared media, so a media-keeping clone
// carries the whole candidate history; a clean clone starts empty.
takes: includeGeneratedMedia ? ensureSceneTakes(scene, now) : [],
@@ -572,6 +573,8 @@ export function replaceScenes(project, sceneInputs) {
sceneId: prior.sceneId,
referenceImageId: prior.referenceImageId ?? null,
videoHistoryId: prior.videoHistoryId ?? null,
+ ...(prior.endImageId ? { endImageId: prior.endImageId } : {}),
+ ...(prior.endFramePrompt ? { endFramePrompt: prior.endFramePrompt } : {}),
takes: prior.takes || [],
...(prior.direction ? { direction: prior.direction } : {}),
};
diff --git a/server/services/musicVideo/sceneJobs.js b/server/services/musicVideo/sceneJobs.js
index cdd8ec6710..b4a59e0505 100644
--- a/server/services/musicVideo/sceneJobs.js
+++ b/server/services/musicVideo/sceneJobs.js
@@ -21,7 +21,8 @@ export function listInFlightSceneJobs(projectId) {
const lane = LANE_BY_KIND[job.kind];
const tag = job.params?.musicVideo;
if (!lane || tag?.projectId !== projectId || !tag.sceneId) continue;
- out.push({ jobId: job.id, lane, sceneId: tag.sceneId, status: job.status });
+ // An end-frame render (#11173) restores into the board's end-frame lane.
+ out.push({ jobId: job.id, lane: lane === 'image' && tag.slot === 'end' ? 'endImage' : lane, sceneId: tag.sceneId, status: job.status });
}
return out;
}
diff --git a/server/services/musicVideo/takes.js b/server/services/musicVideo/takes.js
index 74cfd680ad..6cb2012a52 100644
--- a/server/services/musicVideo/takes.js
+++ b/server/services/musicVideo/takes.js
@@ -27,7 +27,8 @@ import { randomUUID } from 'crypto';
import { ServerError } from '../../lib/errorHandler.js';
import { isNonBlankStr, trimTo } from '../../lib/textUtils.js';
-export const TAKE_SLOT = Object.freeze({ image: 'referenceImageId', video: 'videoHistoryId' });
+// `endImage` (#11173): an optional style-break end frame a fal clip ends on.
+export const TAKE_SLOT = Object.freeze({ image: 'referenceImageId', video: 'videoHistoryId', endImage: 'endImageId' });
// Per-scene cap. Takes are small pointer records, but an unattended "regenerate
// until it looks right" loop must not grow one project row without bound. When
diff --git a/server/services/musicVideo/takes.test.js b/server/services/musicVideo/takes.test.js
index 35ac454418..ec69bf0d95 100644
--- a/server/services/musicVideo/takes.test.js
+++ b/server/services/musicVideo/takes.test.js
@@ -48,3 +48,25 @@ describe('supplied-audio take fills an empty slot', () => {
expect(scene.takes.at(-1).status).toBe('candidate');
});
});
+
+describe('a clip made toward an end frame (#11173)', () => {
+ const endProject = () => ({ id: 'mv-1', scenes: [{ sceneId: 's1', referenceImageId: 'plate.png', endImageId: 'end.png' }] });
+ const clipTake = (project) => ({
+ kind: 'video', assetId: 'clip-1', source: 'generated', sourceImageId: 'plate.png',
+ dependencies: captureTakeDependencies(project.scenes[0], 'plate.png', 'end.png'),
+ });
+
+ it('fills the slot while the same end frame is selected', () => {
+ const project = endProject();
+ expect(appendSceneTakes(project, 's1', [clipTake(project)]).scene.videoHistoryId).toBe('clip-1');
+ });
+
+ it('stays a candidate once a different end frame is selected', () => {
+ const project = endProject();
+ const input = clipTake(project);
+ project.scenes[0].endImageId = 'other-end.png';
+ const { scene } = appendSceneTakes(project, 's1', [input]);
+ expect(scene.videoHistoryId).toBeUndefined();
+ expect(scene.takes.at(-1).status).toBe('candidate');
+ });
+});
diff --git a/server/services/musicVideoSceneHooks.test.js b/server/services/musicVideoSceneHooks.test.js
index 93e8b63a90..4db2cf83a4 100644
--- a/server/services/musicVideoSceneHooks.test.js
+++ b/server/services/musicVideoSceneHooks.test.js
@@ -162,6 +162,19 @@ describe('music-video scene completion hooks → takes', () => {
expect(stored.takes.find((take) => take.assetId === 'clip-old')).toMatchObject({ sourceImageId: 'frame-a.png', dependencyState: { status: 'stale' } });
});
+ it('an end-frame render lands as an endImage take and fills only the end slot (#11173)', async () => {
+ await projects.updateScene(project.id, scene.sceneId, { referenceImageId: 'start.png' });
+ const job = imageJob(project.id, scene.sceneId, 'sketch.png');
+ job.params.musicVideo.slot = 'end';
+ mediaJobEvents.emit('completed', job);
+ await waitFor(() => emitted.length === 1);
+ const stored = await sceneOf(project.id, scene.sceneId);
+ expect(stored.referenceImageId).toBe('start.png');
+ expect(stored.endImageId).toBe('sketch.png');
+ expect(stored.takes.filter((t) => t.kind === 'endImage').map((t) => t.assetId)).toEqual(['sketch.png']);
+ expect(emitted[0]).toMatchObject({ event: 'scene-image', referenceImageId: 'start.png', endImageId: 'sketch.png' });
+ });
+
it('a late completion cannot resurrect a deleted scene or a deleted project', async () => {
const other = await projects.addProjectScene(project.id, { prompt: 'second scene' });
await projects.deleteScene(project.id, scene.sceneId);
diff --git a/server/services/musicVideoSceneImageHook.js b/server/services/musicVideoSceneImageHook.js
index 0652a2f73e..4398622f24 100644
--- a/server/services/musicVideoSceneImageHook.js
+++ b/server/services/musicVideoSceneImageHook.js
@@ -51,8 +51,10 @@ const hook = createMediaJobImageHook({
// older render is a candidate rather than something to drop.
describe: ({ projectId, sceneId }) => `${projectId}/${sceneId}`,
// A deleted project/scene 404s here, so a late completion can't resurrect it.
+ // A render tagged `slot: 'end'` (#11173) is a candidate for the scene's
+ // style-break end frame, never its start frame.
attach: ({ projectId, sceneId, filename, job }) => appendSceneTakes(projectId, sceneId, [{
- kind: 'image',
+ kind: job.params?.musicVideo?.slot === 'end' ? 'endImage' : 'image',
assetId: filename,
source: 'generated',
provider: 'portos',
@@ -64,6 +66,7 @@ const hook = createMediaJobImageHook({
projectId,
sceneId,
referenceImageId: scene.referenceImageId ?? null,
+ endImageId: scene.endImageId ?? null,
takes: scene.takes,
// A landed frame retires this lane's recorded failure (takes.js).
lastFailure: scene.lastFailure ?? null,
@@ -73,7 +76,9 @@ const hook = createMediaJobImageHook({
},
// A render that FAILED (a cancel is not a failure) is recorded on the scene
// so the board can say which scene failed and why, including after a reload.
- onTerminal: (ctx, status, job) => recordSceneLastFailure(ctx, status, job, 'image'),
+ // An end-frame render's failure is only toasted: the scene's failure chip
+ // retries the start frame, which is not what failed.
+ onTerminal: (ctx, status, job) => (job?.params?.musicVideo?.slot === 'end' ? undefined : recordSceneLastFailure(ctx, status, job, 'image')),
});
export function initMusicVideoSceneImageHook() {
diff --git a/server/services/sharing/peerSyncAssets.js b/server/services/sharing/peerSyncAssets.js
index 5ce631a3aa..595758c04c 100644
--- a/server/services/sharing/peerSyncAssets.js
+++ b/server/services/sharing/peerSyncAssets.js
@@ -587,6 +587,9 @@ export async function referenceMusicVideoAssetManifest(project, { linkedTrack }
const imageNames = [...new Set([
...scenes.map((s) => (isStr(s?.referenceImageId) ? s.referenceImageId : null)).filter(Boolean),
...takeIds('image'),
+ // Style-break end frames (#11173) are gallery stills too.
+ ...scenes.map((s) => (isStr(s?.endImageId) ? s.endImageId : null)).filter(Boolean),
+ ...takeIds('endImage'),
...scenes.flatMap((scene) => (scene.takes || []).flatMap((take) => [take.sourceImageId, ...(take.inputAssets || []).map((input) => input.assetId)]).filter(isStr)),
...specRefs.map((r) => (isStr(r?.imageId) ? r.imageId : null)).filter(Boolean),
...(Array.isArray(project?.styleReferences) ? project.styleReferences : []).map((r) => (isStr(r?.imageId) ? r.imageId : null)).filter(Boolean),
diff --git a/server/services/videoGen/submitJob.js b/server/services/videoGen/submitJob.js
index f83c030092..986ccb68d1 100644
--- a/server/services/videoGen/submitJob.js
+++ b/server/services/videoGen/submitJob.js
@@ -290,7 +290,9 @@ const submitValidatedVideoGenJob = async (body, uploads) => {
}
const { basename } = await import('path');
if (scene) {
- params.musicVideoDependencies = captureTakeDependencies(scene, prepared.sourceImagePath ? basename(prepared.sourceImagePath) : null);
+ // A style-break end frame (#11173) is a dependency too, so changing it stales the clip.
+ const endImageId = body.lastImageFile && body.lastImageFile === scene.endImageId ? scene.endImageId : null;
+ params.musicVideoDependencies = captureTakeDependencies(scene, prepared.sourceImagePath ? basename(prepared.sourceImagePath) : null, endImageId);
if (prepared.audio) params.musicVideoDependencies.references.push(...prepared.audio.audioDependencies.references);
}
// #10157: a board-started (manual or auto-review) fal clip records the