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

Remember the shot card's Render on pick, and put each frame's prompt and Render under it (#11268)

[._.]/fefc571e41b5
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index 1403752d08..1779ceaff2 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -3,7 +3,7 @@ import ShotActionInspector from './ShotActionInspector.jsx';
import SceneCameraControls from './SceneCameraControls.jsx';
import { MUSIC_VIDEO_MEDIUM_LABELS } from '../../../../server/lib/musicVideoMediumPlan.js';
import { useEffect, useRef, useState } from 'react';
-import { Trash2, Activity, ArrowUp, ArrowDown, ChevronRight, Image as ImageIcon, Video, Maximize2, AlertTriangle, ImagePlus, Clapperboard, SkipForward, Shuffle, ArrowRight } from 'lucide-react';
+import { Trash2, Activity, ArrowUp, ArrowDown, ChevronRight, Video, Maximize2, AlertTriangle, Clapperboard, Shuffle } from 'lucide-react';
import OverflowMenu from '../ui/OverflowMenu.jsx';
import SceneTakePicker from './SceneTakePicker.jsx';
import VideoStartTrimControl from '../media/VideoStartTrimControl.jsx';
@@ -12,7 +12,8 @@ import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';
import PerformanceEvidence from './PerformanceEvidence.jsx';
import { isPerformanceScene, planPerformanceRepair } from '../../lib/musicVideoShotTiming.js';
import SceneTakeStrip from './SceneTakeStrip.jsx';
-import SceneEndFrame, { sceneEndFramePlanFor } from './SceneEndFrame.jsx';
+import { sceneEndFramePlanFor } from './SceneEndFrame.jsx';
+import SceneFrames from './SceneFrames.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.
@@ -30,30 +31,9 @@ import SceneRenderProgress from './SceneRenderProgress.jsx';
import { COVERAGE_TOLERANCE_SEC, SCENE_ATTENTION_LABELS, sceneAttention } from '../../lib/musicVideoSceneAttention.js';
import { ShotLockButton, useShotLock } from './ShotLock.jsx';
import ScenePoster from './ScenePoster.jsx';
-import SceneRenderTarget, { renderTargetOverrides } from './SceneRenderTarget.jsx';
+import SceneRenderTarget, { lastRenderTarget, renderTargetOverrides } from './SceneRenderTarget.jsx';
import SceneFrameFit, { sceneFrameFit } from './SceneFrameFit.jsx';
-/** One of a shot's two frames: tap to work on it, the corner button to see it full size. */
-function FrameTile({ label, imageId, empty, active, onPick, onOpen, openLabel }) {
- return (
- <div className="relative min-w-0">
- <button type="button" onClick={onPick} aria-pressed={active} aria-label={`${label} frame${imageId ? '' : `: ${empty}`}`}
- className={`block w-full overflow-hidden rounded border ${active ? 'border-port-accent ring-2 ring-port-accent' : 'border-port-border'} focus:outline-none focus:ring-2 focus:ring-port-accent`}>
- {imageId
- ? <img src={`/data/images/${encodeURIComponent(imageId)}`} alt="" className="block aspect-video w-full bg-black object-cover" />
- : <span className="flex aspect-video w-full items-center justify-center border border-dashed border-transparent text-[11px] text-port-text-muted">{empty}</span>}
- <span className="port-media-overlay-strong absolute left-1 top-1 rounded px-1 text-[10px] leading-tight">{label}</span>
- </button>
- {imageId && (
- <button type="button" onClick={onOpen} aria-label={openLabel} title={openLabel}
- className="port-media-overlay-strong absolute right-1 top-1 flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1 sm:min-h-0 sm:min-w-0">
- <Maximize2 className="h-3 w-3" />
- </button>
- )}
- </div>
- );
-}
-
// The two timeline-bound scene fields rendered as identical number inputs.
const SCENE_TIME_FIELDS = [['Start', 'startSec'], ['End', 'endSec']];
@@ -153,13 +133,10 @@ export default function SceneCard({
// Source-clip length, read from the inline player's metadata and keyed to
// the clip it was measured from so a regenerated clip is re-measured.
const [speakerDirty, setSpeakerDirty] = useState(false);
- const [keepStillAsEnd, setKeepStillAsEnd] = useState(false);
const [speakerSaving, setSpeakerSaving] = useState(false);
const [clipMeta, setClipMeta] = useState(null);
// Which slot's "Swap from unused" picker is open: 'image', 'video' or null.
const [swapKind, setSwapKind] = useState(null);
- // Which of the shot's two frames the Frames section works on.
- const [frameSide, setFrameSide] = useState('start');
const clipSec = clipMeta && clipMeta.id === scene.videoHistoryId ? clipMeta.sec : null;
const clipSize = clipMeta && clipMeta.id === scene.videoHistoryId && clipMeta.width > 0 ? { width: clipMeta.width, height: clipMeta.height } : null;
// Pre-#8964 scenes have no `loop` key and keep the legacy loop-to-fill render.
@@ -174,9 +151,10 @@ export default function SceneCard({
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';
- // Where this shot's clip renders: the project's saved renderer unless the card picks another for this shot.
- const [renderPick, setRenderPick] = useState('');
- const [renderOptions, setRenderOptions] = useState({});
+ // Where this shot's clip renders: the last pick made on this device, else the project's saved renderer.
+ const [initialRender] = useState(() => lastRenderTarget({ performance: isPerformanceScene(scene), saved: falVideoSettings || {} }));
+ const [renderPick, setRenderPick] = useState(initialRender.pick);
+ const [renderOptions, setRenderOptions] = useState(initialRender.options);
const renderOverrides = renderTargetOverrides(renderPick, falVideoSettings || {}, renderOptions,
{ models: videoModels, defaultModel: defaultVideoModel, performance: isPerformanceScene(scene), scene });
const renderSettings = renderOverrides ? { ...falVideoSettings, ...renderOverrides } : falVideoSettings;
@@ -239,6 +217,129 @@ export default function SceneCard({
className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
/>
);
+ const shotSettings = (
+ <>
+ {/* What this shot's render covers and costs, and what blocks it, stays in view. */}
+ <SceneTimingPlan timing={timing} sceneId={scene.sceneId} lipSyncBackend={renderLane} onSplit={onSplit} onMergeNext={onMergeNext} />
+ {/* Everything set once and rarely revisited: timing, shot mode, layer, camera. */}
+ <details className="group/settings rounded border border-port-border">
+ <summary className="flex min-h-[44px] cursor-pointer items-center gap-2 px-2 text-xs marker:content-none sm:min-h-[32px] [&::-webkit-details-marker]:hidden">
+ <ChevronRight size={12} aria-hidden="true" className="shrink-0 transition-transform group-open/settings:rotate-90" />
+ <span className="shrink-0 font-medium">Shot settings</span>
+ <span className="min-w-0 truncate text-port-text-muted">· {settingsSummary}</span>
+ </summary>
+ <div className="space-y-2 p-2 pt-0">
+ <div className="flex flex-wrap gap-2 items-center text-xs">
+ {SCENE_TIME_FIELDS.map(([labelText, key]) => {
+ const toValue = (v) => (v === '' ? null : Number(v));
+ return (
+ <label key={key} className="flex items-center gap-1">{labelText}
+ <input type="number" min="0" step="0.1" value={scene[key] ?? ''} className="w-20 bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0"
+ onChange={(e) => onEditLocal(scene.sceneId, { [key]: toValue(e.target.value) })}
+ onBlur={(e) => onSave(scene.sceneId, { [key]: toValue(e.target.value) })} />
+ </label>
+ );
+ })}
+ <label className="flex items-center gap-1 min-h-[44px] sm:min-h-0">
+ <input type="checkbox" checked={!!scene.beatAligned}
+ onChange={(e) => { onEditLocal(scene.sceneId, { beatAligned: e.target.checked }); onSave(scene.sceneId, { beatAligned: e.target.checked }); }} />
+ Beat-aligned
+ </label>
+ <label className="flex items-center gap-1 min-h-[44px] sm:min-h-0" title="Repeat the generated clip to fill a span longer than the clip. Off: the shot must be covered by its clip (trim, continue, or replace it).">
+ <input type="checkbox" checked={loops} disabled={performance} onChange={(e) => applyPatch({ loop: e.target.checked })} />
+ Loop clip
+ </label>
+ </div>
+ <div className="flex flex-wrap gap-2 items-center text-xs">
+ <label htmlFor={fieldId('layer')}>Layer</label>
+ <select id={fieldId('layer')} value={layer} onChange={(e) => applyPatch({ visualLayer: e.target.value })}
+ className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
+ {MUSIC_VIDEO_VISUAL_LAYERS.map((value) => <option key={value} value={value}>{LAYER_LABELS[value]}</option>)}
+ </select>
+ {/* A performance is sung footage — only the footage layer offers it. */}
+ {layer === 'footage' && (
+ <>
+ <label htmlFor={shotModeId} className="flex items-center gap-1">Shot</label>
+ <select id={shotModeId} value={shotModeValue}
+ onChange={(e) => applyPatch(e.target.value === 'cutaway' ? { shotMode: 'cutaway' }
+ : e.target.value === 'music' ? { shotMode: 'performance', performanceStyle: 'music' }
+ // Clear the style only when one is stored, so a plain lip-sync switch stays one field.
+ : { shotMode: 'performance', ...(scene.performanceStyle ? { performanceStyle: null } : {}) })}
+ className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0"
+ title="Cutaway: any video lane animates the frame under the song. Lip-sync: a singer's mouth follows the song. Music-driven: the song slice drives the whole frame's motion (a drummer on the beat). Both need a source-audio provider.">
+ {Object.entries(SHOT_MODE_LABELS).map(([value, text]) => <option key={value} value={value}>{text}</option>)}
+ </select>
+ </>
+ )}
+ {layer === 'still' && (
+ <>
+ <label htmlFor={fieldId('move')}>Move</label>
+ <select id={fieldId('move')} value={scene.stillMove || 'hold'} onChange={(e) => applyPatch({ stillMove: e.target.value })}
+ disabled={!!scene.camera?.move} title={scene.camera?.move ? 'The planned camera move drives this still.' : undefined}
+ className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0 disabled:opacity-50">
+ {STILL_MOVE_LABELS.map(([value, text]) => <option key={value} value={value}>{text}</option>)}
+ </select>
+ </>
+ )}
+ {layer === 'card' && (
+ <>
+ <label htmlFor={fieldId('card-text')}>Card text</label>
+ <input id={fieldId('card-text')} type="text" maxLength={500} value={scene.cardText || ''}
+ placeholder="Title shown on the card"
+ onChange={(e) => onEditLocal(scene.sceneId, { cardText: e.target.value })}
+ onBlur={(e) => onSave(scene.sceneId, { cardText: e.target.value.trim() || null })}
+ className="min-w-0 flex-1 basis-40 bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0" />
+ <label htmlFor={fieldId('card-color')}>Background</label>
+ <input id={fieldId('card-color')} type="color" value={scene.cardColor || '#000000'}
+ onChange={(e) => onEditLocal(scene.sceneId, { cardColor: e.target.value })}
+ onBlur={(e) => onSave(scene.sceneId, { cardColor: e.target.value })}
+ className="h-8 w-10 min-h-[44px] sm:min-h-0 bg-port-bg border border-port-border rounded" />
+ </>
+ )}
+ {documentComposition && (
+ <>
+ <label htmlFor={fieldId('text-zone')}>Lyrics</label>
+ <select id={fieldId('text-zone')} value={scene.textZone || ''} onChange={(e) => applyPatch({ textZone: e.target.value || null })}
+ title="Where the lyric type may sit in this shot, so it stays off the subject"
+ className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
+ <option value="">Default zone</option>
+ {MUSIC_VIDEO_TEXT_ZONES.map((value) => <option key={value} value={value}>{TEXT_ZONE_LABELS[value]}</option>)}
+ </select>
+ <label htmlFor={fieldId('lyric-role')} className="sr-only">Lyric style</label>
+ <select id={fieldId('lyric-role')} value={scene.lyricRole || ''} onChange={(e) => applyPatch({ lyricRole: e.target.value || null })}
+ title="The lyric style of the lines sung over this shot"
+ className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
+ <option value="">Style from the lyric sheet</option>
+ {MUSIC_VIDEO_LYRIC_ROLES.map((value) => <option key={value} value={value}>{LYRIC_ROLE_LABELS[value]}</option>)}
+ </select>
+ </>
+ )}
+ </div>
+ {layer !== 'footage' && !layered && (
+ <p className="text-[11px] text-port-text-muted">
+ {LAYER_LABELS[layer]} sections render in composed or document mode — a plain render plays this scene&apos;s footage.
+ </p>
+ )}
+ {layer !== 'card' && <SceneCameraControls scene={scene} fieldId={fieldId} onEditLocal={onEditLocal} onSave={onSave} />}
+ </div>
+ </details>
+ {/* A music-driven shot follows the whole mix, not one voice; a lip-sync needs its singer before it renders. */}
+ {performance && scene.performanceStyle !== 'music' && (
+ <div className="flex flex-wrap items-center gap-2 text-xs">
+ <label htmlFor={fieldId('speaker')}>Speaker / singer</label>
+ <input id={fieldId('speaker')} value={scene.performanceSpeaker || ''} maxLength={120}
+ onChange={(e) => { setSpeakerDirty(true); onEditLocal(scene.sceneId, { performanceSpeaker: e.target.value }); }}
+ onBlur={(e) => {
+ setSpeakerSaving(true);
+ Promise.resolve(onSave(scene.sceneId, { performanceSpeaker: e.target.value || null }))
+ .then((saved) => setSpeakerDirty(saved === false), () => setSpeakerDirty(true))
+ .finally(() => setSpeakerSaving(false));
+ }}
+ className="bg-port-bg border border-port-border rounded px-2 py-1" placeholder="Intended singer" />
+ </div>
+ )}
+ </>
+ );
return (
<div className="min-w-0">
<details
@@ -248,14 +349,14 @@ export default function SceneCard({
onToggle={(e) => {
onToggleExpand?.(scene.sceneId, e.currentTarget.open);
}}
- className="group rounded-lg border border-port-border bg-port-card"
+ className="group relative rounded-lg border border-port-border bg-port-card"
>
<summary
onClick={() => onSeek?.(scene)}
- className="flex min-h-[44px] cursor-pointer select-none items-center gap-3 p-2 marker:content-none [&::-webkit-details-marker]:hidden"
+ className="flex min-h-[44px] cursor-pointer select-none items-center gap-3 p-2 marker:content-none group-open:pr-52 [&::-webkit-details-marker]:hidden"
>
<ChevronRight size={14} aria-hidden="true" className="shrink-0 text-port-text-muted transition-transform group-open:rotate-90" />
- <ScenePoster scene={scene} iconSize={14} className="aspect-video w-16 shrink-0 rounded border border-port-border sm:w-20" />
+ <ScenePoster scene={scene} iconSize={14} className="aspect-video w-16 shrink-0 rounded border border-port-border sm:w-20 max-sm:group-open:hidden" />
<div className="min-w-0 flex-1">
<div className="truncate text-sm font-medium">
{[shotNumber ? `Shot ${shotNumber}` : null, scene.sectionLabel || scene.label].filter(Boolean).join(' · ') || `Scene ${scene.order + 1}`}
@@ -288,20 +389,20 @@ export default function SceneCard({
<SceneRenderProgress kind="Frame" generating={generatingFrame} progress={frameProgress} />
<SceneRenderProgress kind="Video" generating={generatingVideo} progress={videoProgress} />
</summary>
+ {/* The open card's lock and "…" menu sit in its top-right corner. A move swaps this
+ shot with its neighbor; the song timing and lyric stay with the slot. */}
+ <div className="absolute right-2 top-2 z-10 flex items-center gap-1">
+ <ShotLockButton scene={scene} />
+ <OverflowMenu label="Shot actions" items={[
+ { id: 'earlier', label: 'Move earlier', icon: ArrowUp, onSelect: () => onMove(index, -1), disabled: index === 0 || documentComposition },
+ { id: 'later', label: 'Move later', icon: ArrowDown, onSelect: () => onMove(index, 1), disabled: isLast || documentComposition },
+ { id: 'delete', label: 'Delete shot', icon: Trash2, tone: 'danger', onSelect: () => onDelete(scene.sceneId) },
+ ]} />
+ </div>
<div className="space-y-3 p-3 pt-0">
- {/* Locks first; reorder and delete wait behind the overflow menu. A move swaps this
- shot with its neighbor; the song timing and lyric stay with the slot. */}
- <div className="flex items-center gap-2">
- <ShotLockButton scene={scene} className="mr-auto" />
- {documentComposition && (
- <span className="mr-auto text-[11px] text-gray-400">Shot order comes from the composition document, so it can't be reordered here.</span>
- )}
- <OverflowMenu label="Shot actions" items={[
- { id: 'earlier', label: 'Move earlier', icon: ArrowUp, onSelect: () => onMove(index, -1), disabled: index === 0 || documentComposition },
- { id: 'later', label: 'Move later', icon: ArrowDown, onSelect: () => onMove(index, 1), disabled: isLast || documentComposition },
- { id: 'delete', label: 'Delete shot', icon: Trash2, tone: 'danger', onSelect: () => onDelete(scene.sceneId) },
- ]} />
- </div>
+ {documentComposition && (
+ <p className="text-[11px] text-port-text-muted">Shot order comes from the composition document, so it can&apos;t be reordered here.</p>
+ )}
{songChange && !songChange.resolved && songChange.status !== 'kept' && (
<p className="break-words text-[11px] text-port-warning">{songChange.status === 'new' ? 'New shot for lines the revised song added.' : `Before the song revision: ${songChange.previousLyricText ? `♪ ${songChange.previousLyricText}` : 'instrumental'}`}</p>
)}
@@ -331,94 +432,14 @@ export default function SceneCard({
</p>
) : (
<div className="grid gap-3 @3xl:grid-cols-2">
- {/* Frames: the still this shot starts from (Phase 1b) and, optionally, the one it ends on
- (#11173). Tap a frame to work on it; its takes and actions follow. */}
- <section aria-label="Still" className="min-w-0 space-y-2">
- <h4 className="text-xs font-medium">{endFrames ? 'Frames' : 'Still'}</h4>
- {endFrames ? (
- <div className="grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-1" role="group" aria-label="Start and end frames">
- <FrameTile label="Start" imageId={scene.referenceImageId} empty="No still yet" active={frameSide === 'start'}
- onPick={() => setFrameSide('start')} onOpen={() => onOpenPreview?.(`image:${scene.referenceImageId}`)}
- openLabel={`View scene ${index + 1} reference frame full size`} />
- <ArrowRight size={14} aria-hidden="true" className="text-port-text-muted" />
- <FrameTile label="End" imageId={scene.endImageId} empty="Optional" active={frameSide === 'end'}
- onPick={() => setFrameSide('end')} onOpen={() => onOpenPreview?.(`image:${scene.endImageId}`)}
- openLabel={`View scene ${index + 1} end frame full size`} />
- </div>
- ) : scene.referenceImageId ? (
- <button type="button" onClick={() => onOpenPreview?.(`image:${scene.referenceImageId}`)}
- aria-label={`View scene ${index + 1} reference frame full size`} title={`View scene ${index + 1} reference frame full size`}
- className="block w-full overflow-hidden rounded border border-port-border focus:outline-none focus:ring-2 focus:ring-port-accent">
- <img src={`/data/images/${scene.referenceImageId}`} alt="" className="block aspect-video w-full bg-black object-cover" />
- </button>
- ) : (
- <div className="flex aspect-video w-full items-center justify-center rounded border border-dashed border-port-border text-xs text-port-text-muted">No still yet</div>
- )}
- {endFrames && frameSide === 'end' ? (
- <SceneEndFrame scene={scene} index={index} generating={!!generatingEndFrame} onGenerate={onGenerateEndFrame}
- onEditLocal={onEditLocal} onSave={onSave} onOpenPreview={onOpenPreview} takeBusy={takeBusy}
- onSelectTake={onSelectTake} onReviewTake={onReviewTake} disabled={shotLock?.clip === 'locked'}
- onSwap={onPlacePoolItem ? () => setSwapKind('endImage') : null} />
- ) : (
- <>
- <div className="flex flex-wrap gap-2">
- <button onClick={() => onGenerateFrame(scene)} disabled={!!generatingFrame}
- className={PRIMARY_BUTTON}
- title={scene.referenceImageId
- ? 'Render another candidate frame — your selected frame stays until you pick a new one'
- : 'Generate a still reference frame for this scene'}>
- {generatingFrame ? <Activity size={14} className="animate-spin" /> : <ImageIcon size={14} />}
- {generatingFrame ? 'Generating frame…' : (scene.referenceImageId ? 'New frame take' : 'Generate frame')}
- </button>
- {onPlacePoolItem && (
- <button type="button" onClick={() => setSwapKind('image')} disabled={takeBusy || shotLock?.clip === 'locked'} className={SECONDARY_BUTTON}
- title={shotLock?.clip === 'locked' ? 'Video locked. Unlock the video to change it.' : "Pick a still made for this video that no shot uses: this shot's other takes, other shots', or the floor"}>
- <Shuffle size={14} /> Swap from unused
- </button>
- )}
- {onImportTake && (
- <button type="button" onClick={() => onImportTake(scene)} disabled={takeBusy} className={SECONDARY_BUTTON}
- title="Add a frame from the gallery or an upload (e.g. made in an external tool) as a take">
- <ImagePlus size={14} /> Import take
- </button>
- )}
- {onContinueFromPrevious && layer === 'footage' && index > 0 && (
- <button type="button" onClick={() => onContinueFromPrevious(scene, { keepStillAsEnd: keepStillAsEnd && Boolean(scene.referenceImageId) })}
- disabled={takeBusy || !previousHasClip} className={SECONDARY_BUTTON}
- title={previousHasClip ? 'Start this shot from the last frame the previous shot shows in the cut' : 'The previous shot needs a clip first'}>
- <SkipForward size={14} /> From previous shot
- </button>
- )}
- </div>
- {onContinueFromPrevious && layer === 'footage' && index > 0 && scene.referenceImageId && (
- <label htmlFor={`mv-scene-${scene.sceneId}-keep-still-end`} className="flex items-center gap-1 text-[11px] text-port-text-muted min-h-[44px] sm:min-h-0">
- <input id={`mv-scene-${scene.sceneId}-keep-still-end`} type="checkbox" checked={keepStillAsEnd}
- onChange={(e) => setKeepStillAsEnd(e.target.checked)} />
- From previous shot: keep this frame as the end frame
- </label>
- )}
- <SceneTakeStrip scene={scene} kind="image" busy={takeBusy}
- onSelect={(take) => onSelectTake?.(scene, take)}
- onReview={(take, review) => onReviewTake?.(scene, take, review)}
- onOpenPreview={onOpenPreview} />
- <details className="group/prompt">
- <summary className="flex min-h-[44px] cursor-pointer items-center gap-1 text-[11px] text-port-text-muted marker:content-none sm:min-h-0 [&::-webkit-details-marker]:hidden">
- <ChevronRight size={12} aria-hidden="true" className="shrink-0 transition-transform group-open/prompt:rotate-90" />
- <span className="shrink-0">Still prompt</span>
- <span className="min-w-0 truncate">{scene.framePrompt ? `· ${scene.framePrompt}` : '· from the shot prompt'}</span>
- </summary>
- <textarea
- aria-label="Reference frame prompt"
- value={scene.framePrompt || ''} rows={4}
- onChange={(e) => onEditLocal(scene.sceneId, { framePrompt: e.target.value })}
- onBlur={(e) => onSave(scene.sceneId, { framePrompt: e.target.value || null })}
- placeholder="Reference frame prompt — the still that seeds this shot (defaults to the shot prompt)"
- className="mt-1 w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
- />
- </details>
- </>
- )}
- </section>
+ {/* Frames: the still this shot starts from and, optionally, the one it ends on (#11173),
+ each with its prompt and Render under it, then the tapped frame's takes. */}
+ <SceneFrames scene={scene} index={index} endFrames={endFrames} generatingFrame={!!generatingFrame} generatingEndFrame={!!generatingEndFrame}
+ onGenerateFrame={onGenerateFrame} onGenerateEndFrame={onGenerateEndFrame} onEditLocal={onEditLocal} onSave={onSave}
+ onOpenPreview={onOpenPreview} takeBusy={takeBusy} onSelectTake={onSelectTake} onReviewTake={onReviewTake}
+ onSwap={onPlacePoolItem ? setSwapKind : null} onImportTake={onImportTake}
+ onContinueFromPrevious={layer === 'footage' && index > 0 ? onContinueFromPrevious : null} previousHasClip={previousHasClip}
+ clipLocked={shotLock?.clip === 'locked'} />
{/* Clip: the motion prompt, where this shot renders and what it costs, then its clip (Phase 1). */}
<section aria-label="Render" className="min-w-0 space-y-2">
<h4 className="text-xs font-medium">Clip</h4>
@@ -529,132 +550,16 @@ export default function SceneCard({
{shotLock && shotLock.still !== 'locked' && lockBlocked && <ShotLockButton scene={scene} />}
</div>
)}
- <SceneTakeStrip scene={scene} kind="video" busy={takeBusy}
+ <SceneTakeStrip scene={scene} kind="video" busy={takeBusy} grid
onSelect={(take) => onSelectTake?.(scene, take)}
onReview={(take, review) => onReviewTake?.(scene, take, review)}
onOpenPreview={onOpenPreview} />
+ {/* The render's settings sit with the render: what it covers and costs, then timing, shot mode, layer and camera. */}
+ {shotSettings}
</section>
</div>
)}
- {/* What this shot's render covers and costs, and what blocks it, stays in view. */}
- <SceneTimingPlan timing={timing} sceneId={scene.sceneId} lipSyncBackend={renderLane} onSplit={onSplit} onMergeNext={onMergeNext} />
- {/* Everything set once and rarely revisited: timing, shot mode, layer, camera. */}
- <details className="group/settings rounded border border-port-border">
- <summary className="flex min-h-[44px] cursor-pointer items-center gap-2 px-2 text-xs marker:content-none sm:min-h-[32px] [&::-webkit-details-marker]:hidden">
- <ChevronRight size={12} aria-hidden="true" className="shrink-0 transition-transform group-open/settings:rotate-90" />
- <span className="shrink-0 font-medium">Shot settings</span>
- <span className="min-w-0 truncate text-port-text-muted">· {settingsSummary}</span>
- </summary>
- <div className="space-y-2 p-2 pt-0">
- <div className="flex flex-wrap gap-2 items-center text-xs">
- {SCENE_TIME_FIELDS.map(([labelText, key]) => {
- const toValue = (v) => (v === '' ? null : Number(v));
- return (
- <label key={key} className="flex items-center gap-1">{labelText}
- <input type="number" min="0" step="0.1" value={scene[key] ?? ''} className="w-20 bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0"
- onChange={(e) => onEditLocal(scene.sceneId, { [key]: toValue(e.target.value) })}
- onBlur={(e) => onSave(scene.sceneId, { [key]: toValue(e.target.value) })} />
- </label>
- );
- })}
- <label className="flex items-center gap-1 min-h-[44px] sm:min-h-0">
- <input type="checkbox" checked={!!scene.beatAligned}
- onChange={(e) => { onEditLocal(scene.sceneId, { beatAligned: e.target.checked }); onSave(scene.sceneId, { beatAligned: e.target.checked }); }} />
- Beat-aligned
- </label>
- <label className="flex items-center gap-1 min-h-[44px] sm:min-h-0" title="Repeat the generated clip to fill a span longer than the clip. Off: the shot must be covered by its clip (trim, continue, or replace it).">
- <input type="checkbox" checked={loops} disabled={performance} onChange={(e) => applyPatch({ loop: e.target.checked })} />
- Loop clip
- </label>
- </div>
- <div className="flex flex-wrap gap-2 items-center text-xs">
- <label htmlFor={fieldId('layer')}>Layer</label>
- <select id={fieldId('layer')} value={layer} onChange={(e) => applyPatch({ visualLayer: e.target.value })}
- className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
- {MUSIC_VIDEO_VISUAL_LAYERS.map((value) => <option key={value} value={value}>{LAYER_LABELS[value]}</option>)}
- </select>
- {/* A performance is sung footage — only the footage layer offers it. */}
- {layer === 'footage' && (
- <>
- <label htmlFor={shotModeId} className="flex items-center gap-1">Shot</label>
- <select id={shotModeId} value={shotModeValue}
- onChange={(e) => applyPatch(e.target.value === 'cutaway' ? { shotMode: 'cutaway' }
- : e.target.value === 'music' ? { shotMode: 'performance', performanceStyle: 'music' }
- // Clear the style only when one is stored, so a plain lip-sync switch stays one field.
- : { shotMode: 'performance', ...(scene.performanceStyle ? { performanceStyle: null } : {}) })}
- className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0"
- title="Cutaway: any video lane animates the frame under the song. Lip-sync: a singer's mouth follows the song. Music-driven: the song slice drives the whole frame's motion (a drummer on the beat). Both need a source-audio provider.">
- {Object.entries(SHOT_MODE_LABELS).map(([value, text]) => <option key={value} value={value}>{text}</option>)}
- </select>
- </>
- )}
- {layer === 'still' && (
- <>
- <label htmlFor={fieldId('move')}>Move</label>
- <select id={fieldId('move')} value={scene.stillMove || 'hold'} onChange={(e) => applyPatch({ stillMove: e.target.value })}
- disabled={!!scene.camera?.move} title={scene.camera?.move ? 'The planned camera move drives this still.' : undefined}
- className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0 disabled:opacity-50">
- {STILL_MOVE_LABELS.map(([value, text]) => <option key={value} value={value}>{text}</option>)}
- </select>
- </>
- )}
- {layer === 'card' && (
- <>
- <label htmlFor={fieldId('card-text')}>Card text</label>
- <input id={fieldId('card-text')} type="text" maxLength={500} value={scene.cardText || ''}
- placeholder="Title shown on the card"
- onChange={(e) => onEditLocal(scene.sceneId, { cardText: e.target.value })}
- onBlur={(e) => onSave(scene.sceneId, { cardText: e.target.value.trim() || null })}
- className="min-w-0 flex-1 basis-40 bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0" />
- <label htmlFor={fieldId('card-color')}>Background</label>
- <input id={fieldId('card-color')} type="color" value={scene.cardColor || '#000000'}
- onChange={(e) => onEditLocal(scene.sceneId, { cardColor: e.target.value })}
- onBlur={(e) => onSave(scene.sceneId, { cardColor: e.target.value })}
- className="h-8 w-10 min-h-[44px] sm:min-h-0 bg-port-bg border border-port-border rounded" />
- </>
- )}
- {documentComposition && (
- <>
- <label htmlFor={fieldId('text-zone')}>Lyrics</label>
- <select id={fieldId('text-zone')} value={scene.textZone || ''} onChange={(e) => applyPatch({ textZone: e.target.value || null })}
- title="Where the lyric type may sit in this shot, so it stays off the subject"
- className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
- <option value="">Default zone</option>
- {MUSIC_VIDEO_TEXT_ZONES.map((value) => <option key={value} value={value}>{TEXT_ZONE_LABELS[value]}</option>)}
- </select>
- <label htmlFor={fieldId('lyric-role')} className="sr-only">Lyric style</label>
- <select id={fieldId('lyric-role')} value={scene.lyricRole || ''} onChange={(e) => applyPatch({ lyricRole: e.target.value || null })}
- title="The lyric style of the lines sung over this shot"
- className="bg-port-bg border border-port-border rounded px-1 py-1 min-h-[44px] sm:min-h-0">
- <option value="">Style from the lyric sheet</option>
- {MUSIC_VIDEO_LYRIC_ROLES.map((value) => <option key={value} value={value}>{LYRIC_ROLE_LABELS[value]}</option>)}
- </select>
- </>
- )}
- </div>
- {layer !== 'footage' && !layered && (
- <p className="text-[11px] text-port-text-muted">
- {LAYER_LABELS[layer]} sections render in composed or document mode — a plain render plays this scene&apos;s footage.
- </p>
- )}
- {layer !== 'card' && <SceneCameraControls scene={scene} fieldId={fieldId} onEditLocal={onEditLocal} onSave={onSave} />}
- </div>
- </details>
- {/* A music-driven shot follows the whole mix, not one voice; a lip-sync needs its singer before it renders. */}
- {performance && scene.performanceStyle !== 'music' && (
- <div className="flex flex-wrap items-center gap-2 text-xs">
- <label htmlFor={fieldId('speaker')}>Speaker / singer</label>
- <input id={fieldId('speaker')} value={scene.performanceSpeaker || ''} maxLength={120}
- onChange={(e) => { setSpeakerDirty(true); onEditLocal(scene.sceneId, { performanceSpeaker: e.target.value }); }}
- onBlur={(e) => {
- setSpeakerSaving(true);
- Promise.resolve(onSave(scene.sceneId, { performanceSpeaker: e.target.value || null }))
- .then((saved) => setSpeakerDirty(saved === false), () => setSpeakerDirty(true))
- .finally(() => setSpeakerSaving(false));
- }}
- className="bg-port-bg border border-port-border rounded px-2 py-1" placeholder="Intended singer" />
- </div>
- )}
+ {codeShot && shotSettings}
{(scene.visualIntent || scene.direction || scene.direction?.actionContract) && (
<details className="group/direction rounded border border-port-border">
<summary className="flex min-h-[44px] cursor-pointer items-center gap-2 px-2 text-xs marker:content-none sm:min-h-[32px] [&::-webkit-details-marker]:hidden">
diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsx
index 88c8e2a5d5..f2179ff43a 100644
--- a/client/src/components/musicVideo/SceneCard.test.jsx
+++ b/client/src/components/musicVideo/SceneCard.test.jsx
@@ -1,11 +1,13 @@
import { useState } from 'react';
-import { describe, expect, it, vi } from 'vitest';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
vi.mock('../../hooks/useVideoFileSrc.js', () => ({ useVideoFileSrc: () => ({}) }));
import SceneCard from './SceneCard.jsx';
import { GROK_VIDEO_DURATIONS } from '../../lib/grokVideoClip.js';
const GROK_MAX = GROK_VIDEO_DURATIONS.at(-1);
+// A card opens on the last Render on pick, so each test starts from the project setting.
+beforeEach(() => localStorage.clear());
describe('code shot (#10297)', () => {
it('offers no frame or clip generation for a code shot in a layered composition', () => {
@@ -349,18 +351,30 @@ describe('Render follows the shot locks', () => {
});
describe('start and end frames', () => {
- // Uniquely catches the end frame hiding behind a collapsed row, losing its own actions, or the Render section not saying which renderer ends on it.
- it('shows the start and end frames as a pair, works on the tapped one, and says which renderer ends on the end frame', () => {
- const scene = { sceneId: 's1', prompt: 'She looks into the lens', referenceImageId: 'start.png', endImageId: 'end.png', startSec: 0, endSec: 4,
+ // Uniquely catches a frame's prompt or Render hiding away from its picture, a frame reference not reaching the render, or the Render section not saying which renderer ends on the end frame.
+ it('shows each frame with its prompt and Render, renders from a picked frame, and shows the tapped frame\'s takes', () => {
+ const scene = { sceneId: 's1', prompt: 'She looks into the lens', referenceImageId: 'start.png', endImageId: 'end.png', endFramePrompt: 'Head thrown back', startSec: 0, endSec: 4,
takes: [{ takeId: 't1', kind: 'image', assetId: 'start.png', status: 'selected' }, { takeId: 't2', kind: 'endImage', assetId: 'end.png', status: 'selected' }] };
- render(<SceneCard scene={scene} index={0} expanded onEditLocal={() => {}} onSave={() => {}} onGenerateEndFrame={() => {}} onPlacePoolItem={() => {}}
- falVideoSettings={{ backend: 'local' }} />);
+ const onGenerateFrame = vi.fn();
+ const onGenerateEndFrame = vi.fn();
+ render(<SceneCard scene={scene} index={0} expanded onEditLocal={() => {}} onSave={() => {}} onGenerateFrame={onGenerateFrame} onGenerateEndFrame={onGenerateEndFrame}
+ onPlacePoolItem={() => {}} falVideoSettings={{ backend: 'local' }} />);
const pair = screen.getByRole('group', { name: 'Start and end frames' });
- expect(within(pair).getByRole('button', { name: 'Start frame' }).getAttribute('aria-pressed')).toBe('true');
- expect(screen.queryByLabelText('End frame prompt')).toBeNull();
+ expect(within(pair).getByLabelText('Reference frame prompt')).toBeTruthy();
+ expect(within(pair).getByLabelText('End frame prompt').value).toBe('Head thrown back');
+
+ // The end frame renders from the start frame unless another frame is picked; the start frame from its prompt.
+ fireEvent.click(within(pair).getByRole('button', { name: 'New end frame take' }));
+ expect(onGenerateEndFrame).toHaveBeenLastCalledWith(scene, { referenceImageId: 'start.png' });
+ fireEvent.change(screen.getByLabelText('From', { selector: '#mv-scene-s1-start-from' }), { target: { value: 'end' } });
+ fireEvent.click(within(pair).getByRole('button', { name: 'New frame take' }));
+ expect(onGenerateFrame).toHaveBeenLastCalledWith(scene, { referenceImageId: 'end.png' });
+
+ expect(screen.getByRole('list', { name: /^Frame takes/ })).toBeTruthy();
fireEvent.click(within(pair).getByRole('button', { name: 'End frame' }));
- expect(screen.getByLabelText('End frame prompt')).toBeTruthy();
+ expect(screen.getByRole('list', { name: /^End frame takes/ })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Clear scene 1 end frame' })).toBeTruthy();
+
expect(screen.getByTestId('end-frame-plan').textContent).toMatch(/animates from the start frame only/);
const pick = screen.getByLabelText('Render on');
expect(within(pick).getByRole('option', { name: /Kling v3 Pro.*ends on end frame/ })).toBeTruthy();
@@ -369,6 +383,28 @@ describe('start and end frames', () => {
});
});
+describe('Render on remembers the last pick', () => {
+ // Uniquely catches a new card falling back to the project setting (a paid fal render) after the director picked local.
+ it('opens the next card on the last pick made on this device, and falls back where the shot cannot use it', () => {
+ const scene = { sceneId: 's1', prompt: 'She turns away', referenceImageId: 'start.png', startSec: 0, endSec: 4,
+ takes: [{ takeId: 't1', kind: 'image', assetId: 'start.png', status: 'selected' }] };
+ const saved = { backend: 'fal' };
+ const first = render(<SceneCard scene={scene} index={0} expanded onEditLocal={() => {}} onSave={() => {}} falVideoSettings={saved} />);
+ expect(screen.getByLabelText('Render on').value).toBe('');
+ fireEvent.change(screen.getByLabelText('Render on'), { target: { value: 'local' } });
+ first.unmount();
+
+ const second = render(<SceneCard scene={{ ...scene, sceneId: 's2' }} index={1} expanded onEditLocal={() => {}} onSave={() => {}} falVideoSettings={saved} />);
+ expect(screen.getByLabelText('Render on').value).toBe('local');
+ fireEvent.change(screen.getByLabelText('Render on'), { target: { value: 'grok' } });
+ second.unmount();
+
+ // Grok renders cutaways only, so a lip-synced shot opens on the project setting.
+ render(<SceneCard scene={{ ...scene, sceneId: 's3', shotMode: 'performance' }} index={2} expanded onEditLocal={() => {}} onSave={() => {}} falVideoSettings={saved} />);
+ expect(screen.getByLabelText('Render on').value).toBe('');
+ });
+});
+
describe('frame fit for an off-shape clip', () => {
// Uniquely catches the fit choice hiding on a 3:2 clip in a 16:9 video (or
// cluttering a matching one), and the pick not reaching the saved shot.
diff --git a/client/src/components/musicVideo/SceneEndFrame.jsx b/client/src/components/musicVideo/SceneEndFrame.jsx
index efce6a55d4..6a2ae5e7f9 100644
--- a/client/src/components/musicVideo/SceneEndFrame.jsx
+++ b/client/src/components/musicVideo/SceneEndFrame.jsx
@@ -1,10 +1,6 @@
-import { Activity, Shuffle, Wand2, X } from 'lucide-react';
-import SceneTakeStrip from './SceneTakeStrip.jsx';
import { sceneEndFramePlan } from '../../../../server/lib/musicVideoEndFrame.js';
import { falSceneTake } from '../../lib/musicVideoShotTiming.js';
-const BUTTON = 'flex items-center gap-1 bg-port-bg border border-port-border hover:bg-port-border/40 disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0 whitespace-nowrap';
-
/**
* Whether a clip rendered with `settings` (the project's saved renderer, or a
* scene card's Render on pick merged over it) ends on the scene's end frame:
@@ -21,60 +17,3 @@ export function sceneEndFramePlanFor(scene, settings = {}, { models = [], defaul
: null;
return sceneEndFramePlan(scene, { backend: settings.backend || null, falModelId, mode, localRuntime });
}
-
-/**
- * A shot's end frame (#11173): the still its clip moves into from the start
- * frame, such as her head thrown back for a possession beat, or a pencil-sketch
- * rotoscope of the same frame. The director describes it and renders it from
- * the start frame, swaps one in from the unused stills, and picks among its
- * takes like any frame. Only renderers that take an end frame use it; the
- * Render section says whether the current pick does.
- */
-export default function SceneEndFrame({
- scene, index, generating = false, onGenerate, onEditLocal, onSave, onOpenPreview,
- takeBusy = false, onSelectTake, onReviewTake, onSwap = null, disabled = false,
-}) {
- const promptId = `mv-scene-${scene.sceneId}-end-frame-prompt`;
- const clear = () => { onEditLocal(scene.sceneId, { endImageId: null }); onSave(scene.sceneId, { endImageId: null }); };
- return (
- <div className="space-y-2">
- <label htmlFor={promptId} className="block text-[11px] text-port-text-muted">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="Where the shot ends, e.g. her head thrown back, eyes white, lit from below"
- className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
- />
- <div className="flex flex-wrap gap-2">
- <button type="button" onClick={() => onGenerate?.(scene)}
- disabled={disabled || generating || !scene.referenceImageId || !scene.endFramePrompt?.trim()}
- title={!scene.referenceImageId ? 'Generate a start frame first'
- : !scene.endFramePrompt?.trim() ? 'Describe the end frame first'
- : "Render the end frame from this shot's 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>
- {onSwap && (
- <button type="button" onClick={onSwap} disabled={disabled || takeBusy} className={BUTTON}
- title="Use a still made for this video that no shot uses as the end frame">
- <Shuffle size={14} /> Swap from unused
- </button>
- )}
- {scene.endImageId && (
- <button type="button" onClick={clear} disabled={disabled} className={BUTTON}
- aria-label={`Clear scene ${index + 1} end frame`} title="The clip ends where the model takes it; the end frame's takes stay">
- <X size={14} /> No end frame
- </button>
- )}
- </div>
- <p className="text-[11px] text-port-text-muted">The clip ends here on a fal.ai model marked &quot;ends on end frame&quot; under Render on.</p>
- <SceneTakeStrip scene={scene} kind="endImage" busy={takeBusy}
- onSelect={(take) => onSelectTake?.(scene, take)}
- onReview={(take, review) => onReviewTake?.(scene, take, review)}
- onOpenPreview={onOpenPreview} />
- </div>
- );
-}
diff --git a/client/src/components/musicVideo/SceneFrames.jsx b/client/src/components/musicVideo/SceneFrames.jsx
new file mode 100644
index 0000000000..35509af34c
--- /dev/null
+++ b/client/src/components/musicVideo/SceneFrames.jsx
@@ -0,0 +1,146 @@
+import { useState } from 'react';
+import { Activity, ArrowRight, Image as ImageIcon, ImagePlus, Maximize2, Shuffle, SkipForward, Wand2, X } from 'lucide-react';
+import SceneTakeStrip from './SceneTakeStrip.jsx';
+
+const PRIMARY_BUTTON = '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';
+const SECONDARY_BUTTON = 'flex items-center gap-1 bg-port-bg border border-port-border hover:bg-port-border/40 disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0 whitespace-nowrap';
+const SELECT = 'min-w-0 bg-port-bg border border-port-border rounded px-1 py-1 text-xs min-h-[44px] sm:min-h-0 disabled:opacity-50';
+
+/** One of a shot's two frames: tap to work on its takes, the corner button to see it full size. */
+function FrameTile({ label, imageId, empty, active, onPick, onOpen, openLabel }) {
+ return (
+ <div className="relative min-w-0">
+ <button type="button" onClick={onPick} aria-pressed={active} aria-label={`${label} frame${imageId ? '' : `: ${empty}`}`}
+ className={`block w-full overflow-hidden rounded border ${active ? 'border-port-accent ring-2 ring-port-accent' : 'border-port-border'} focus:outline-none focus:ring-2 focus:ring-port-accent`}>
+ {imageId
+ ? <img src={`/data/images/${encodeURIComponent(imageId)}`} alt="" className="block aspect-video w-full bg-black object-cover" />
+ : <span className="flex aspect-video w-full items-center justify-center text-[11px] text-port-text-muted">{empty}</span>}
+ <span className="port-media-overlay-strong absolute left-1 top-1 rounded px-1 text-[10px] leading-tight">{label}</span>
+ </button>
+ {imageId && (
+ <button type="button" onClick={onOpen} aria-label={openLabel} title={openLabel}
+ className="port-media-overlay-strong absolute right-1 top-1 flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1 sm:min-h-0 sm:min-w-0">
+ <Maximize2 className="h-3 w-3" />
+ </button>
+ )}
+ </div>
+ );
+}
+
+const REFERENCE_LABELS = { '': 'Prompt only', start: 'Start frame', end: 'End frame' };
+
+/**
+ * A shot's frames: the still its clip starts from and, for footage, the
+ * optional one it ends on (#11173). Each frame shows its prompt and its own
+ * Render right under the picture, and can render from the start or end frame
+ * as an image reference (`onGenerateFrame` / `onGenerateEndFrame` take
+ * `{ referenceImageId }`, null for prompt only). Tapping a frame picks whose
+ * takes show below, as a grid, with that frame's swap and import actions.
+ */
+export default function SceneFrames({
+ scene, index, endFrames, generatingFrame = false, generatingEndFrame = false, onGenerateFrame, onGenerateEndFrame,
+ onEditLocal, onSave, onOpenPreview, takeBusy = false, onSelectTake, onReviewTake, onSwap = null, onImportTake = null,
+ onContinueFromPrevious = null, previousHasClip = false, clipLocked = false,
+}) {
+ const [side, setSide] = useState('start');
+ const [keepStillAsEnd, setKeepStillAsEnd] = useState(false);
+ // Which frame each render starts from: the start frame renders from its prompt, the end frame from the start frame.
+ const [refs, setRefs] = useState({ start: '', end: 'start' });
+ const frames = { start: scene.referenceImageId || null, end: endFrames ? scene.endImageId || null : null };
+ const refOf = (which) => (frames[refs[which]] ? refs[which] : '');
+ const lockedTitle = 'Video locked. Unlock the video to change it.';
+ const id = (name) => `mv-scene-${scene.sceneId}-${name}`;
+ const activeSide = endFrames ? side : 'start';
+
+ const column = (which) => {
+ const start = which === 'start';
+ const label = start ? (endFrames ? 'Start' : 'Still') : 'End';
+ const field = start ? 'framePrompt' : 'endFramePrompt';
+ const generating = start ? generatingFrame : generatingEndFrame;
+ const imageId = frames[which];
+ const ref = refOf(which);
+ const refChoices = ['', ...['start', 'end'].filter((key) => frames[key])];
+ const needsPrompt = !start && !scene.endFramePrompt?.trim();
+ const render = () => (start ? onGenerateFrame : onGenerateEndFrame)?.(scene, { referenceImageId: ref ? frames[ref] : null });
+ return (
+ <div key={which} className="min-w-0 space-y-1.5">
+ <FrameTile label={label} imageId={imageId} empty={start ? 'No still yet' : 'Optional'} active={endFrames && activeSide === which}
+ onPick={() => setSide(which)} onOpen={() => onOpenPreview?.(`image:${imageId}`)}
+ openLabel={`View scene ${index + 1} ${start ? 'reference' : 'end'} frame full size`} />
+ <label htmlFor={id(`${which}-prompt`)} className="sr-only">{start ? 'Reference frame prompt' : 'End frame prompt'}</label>
+ <textarea id={id(`${which}-prompt`)} value={scene[field] || ''} rows={3}
+ onChange={(e) => onEditLocal(scene.sceneId, { [field]: e.target.value })}
+ onBlur={(e) => onSave(scene.sceneId, { [field]: e.target.value || null })}
+ placeholder={start ? 'Start frame prompt (defaults to the shot prompt)' : 'Where the shot ends, e.g. her head thrown back, eyes white'}
+ className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm" />
+ <div className="flex flex-wrap items-center gap-2">
+ <button type="button" onClick={render} disabled={!!generating || needsPrompt || (!start && clipLocked)} className={PRIMARY_BUTTON}
+ title={needsPrompt ? 'Describe the end frame first' : ref ? `Render from the ${REFERENCE_LABELS[ref].toLowerCase()} with this prompt` : 'Render from this prompt'}>
+ {generating ? <Activity size={14} className="animate-spin" /> : start ? <ImageIcon size={14} /> : <Wand2 size={14} />}
+ {generating ? 'Generating…' : start ? (imageId ? 'New frame take' : 'Generate frame') : (imageId ? 'New end frame take' : 'Generate end frame')}
+ </button>
+ {refChoices.length > 1 && (
+ <span className="flex min-w-0 items-center gap-1">
+ <label htmlFor={id(`${which}-from`)} className="text-xs text-port-text-muted">From</label>
+ <select id={id(`${which}-from`)} value={ref} onChange={(e) => setRefs((prev) => ({ ...prev, [which]: e.target.value }))}
+ disabled={!!generating} className={SELECT} title="Use a frame as the image reference for this render">
+ {refChoices.map((key) => <option key={key} value={key}>{REFERENCE_LABELS[key]}</option>)}
+ </select>
+ </span>
+ )}
+ </div>
+ </div>
+ );
+ };
+
+ return (
+ <section aria-label="Still" className="@container min-w-0 space-y-2">
+ <h4 className="text-xs font-medium">{endFrames ? 'Frames' : 'Still'}</h4>
+ {endFrames ? (
+ <div role="group" aria-label="Start and end frames" className="grid gap-3 @sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]">
+ {column('start')}
+ <ArrowRight size={14} aria-hidden="true" className="hidden self-start text-port-text-muted @sm:mt-12 @sm:block" />
+ {column('end')}
+ </div>
+ ) : column('start')}
+ <div className="flex flex-wrap gap-2">
+ {onSwap && (
+ <button type="button" onClick={() => onSwap(activeSide === 'end' ? 'endImage' : 'image')} disabled={takeBusy || clipLocked} className={SECONDARY_BUTTON}
+ title={clipLocked ? lockedTitle : `Pick a still made for this video that no shot uses as the ${activeSide === 'end' ? 'end' : 'start'} frame`}>
+ <Shuffle size={14} /> Swap from unused
+ </button>
+ )}
+ {activeSide === 'start' && onImportTake && (
+ <button type="button" onClick={() => onImportTake(scene)} disabled={takeBusy} className={SECONDARY_BUTTON}
+ title="Add a frame from the gallery or an upload (e.g. made in an external tool) as a take">
+ <ImagePlus size={14} /> Import take
+ </button>
+ )}
+ {activeSide === 'start' && onContinueFromPrevious && (
+ <button type="button" onClick={() => onContinueFromPrevious(scene, { keepStillAsEnd: keepStillAsEnd && Boolean(scene.referenceImageId) })}
+ disabled={takeBusy || !previousHasClip} className={SECONDARY_BUTTON}
+ title={previousHasClip ? 'Start this shot from the last frame the previous shot shows in the cut' : 'The previous shot needs a clip first'}>
+ <SkipForward size={14} /> From previous shot
+ </button>
+ )}
+ {activeSide === 'end' && scene.endImageId && (
+ <button type="button" onClick={() => { onEditLocal(scene.sceneId, { endImageId: null }); onSave(scene.sceneId, { endImageId: null }); }}
+ disabled={clipLocked} className={SECONDARY_BUTTON}
+ aria-label={`Clear scene ${index + 1} end frame`} title="The clip ends where the model takes it; the end frame's takes stay">
+ <X size={14} /> No end frame
+ </button>
+ )}
+ </div>
+ {activeSide === 'start' && onContinueFromPrevious && scene.referenceImageId && (
+ <label htmlFor={id('keep-still-end')} className="flex items-center gap-1 text-[11px] text-port-text-muted min-h-[44px] sm:min-h-0">
+ <input id={id('keep-still-end')} type="checkbox" checked={keepStillAsEnd} onChange={(e) => setKeepStillAsEnd(e.target.checked)} />
+ From previous shot: keep this frame as the end frame
+ </label>
+ )}
+ <SceneTakeStrip scene={scene} kind={activeSide === 'end' ? 'endImage' : 'image'} busy={takeBusy} grid
+ onSelect={(take) => onSelectTake?.(scene, take)}
+ onReview={(take, review) => onReviewTake?.(scene, take, review)}
+ onOpenPreview={onOpenPreview} />
+ </section>
+ );
+}
diff --git a/client/src/components/musicVideo/SceneRenderTarget.jsx b/client/src/components/musicVideo/SceneRenderTarget.jsx
index 3067a3c53e..6e7849bfe6 100644
--- a/client/src/components/musicVideo/SceneRenderTarget.jsx
+++ b/client/src/components/musicVideo/SceneRenderTarget.jsx
@@ -5,6 +5,7 @@ import { GROK_VIDEO_DURATIONS } from '../../lib/grokVideoClip.js';
import { grokCoverage } from '../../lib/musicVideoShotTiming.js';
import { localMusicVideoModels } from '../../../../server/lib/musicVideoLocalModels.js';
import { frameOptionsForModel } from '../../lib/videoGenParams.js';
+import { safeReadJsonStorage, safeWriteJsonStorage } from '../../lib/safeStorage.js';
/**
* Where one shot's clip renders, picked on its card: the project's saved
@@ -20,6 +21,9 @@ import { frameOptionsForModel } from '../../lib/videoGenParams.js';
* resolutions. Each length defaults to the shortest one that covers the shot.
* `options` holds only what the director changed: `{ modelId, numFrames,
* grokDuration, falDuration, falResolution }`.
+ *
+ * A card opens on the last pick made on this device (lastRenderTarget), with
+ * its local model or fal size; lengths stay sized to each shot.
*/
const BACKEND_LABELS = { local: 'Local LTX', grok: 'Grok', fal: 'fal.ai' };
// The local render's frame rate when the request names none (generateVideo's default).
@@ -45,6 +49,29 @@ export function renderTargetOptions({ performance, saved, endFrame = false }) {
];
}
+const LAST_PICK_KEY = 'portos.musicVideo.lastRenderOn';
+
+/** Remember a card's pick for the next card opened on this device. */
+export function rememberRenderTarget(pick, options = {}) {
+ safeWriteJsonStorage(LAST_PICK_KEY, { pick, modelId: options.modelId || null, falResolution: options.falResolution || null });
+}
+
+/**
+ * The pick and options a card opens on: the last pick made on this device,
+ * when this shot offers it (a lip-synced shot has one fal choice and no Grok),
+ * else the project setting.
+ */
+export function lastRenderTarget({ performance, saved }) {
+ const last = safeReadJsonStorage(LAST_PICK_KEY, null);
+ let pick = typeof last?.pick === 'string' ? last.pick : '';
+ if (performance && pick.startsWith('fal:')) pick = 'fal';
+ if (!renderTargetOptions({ performance, saved }).some((option) => option.value === pick && !option.disabled)) pick = '';
+ const falModel = pick.startsWith('fal:') ? getFalVideoModel(pick.slice(4)) : null;
+ const options = pick === 'local' && last.modelId ? { modelId: last.modelId }
+ : falModel && falVideoResolutions(falModel).includes(last.falResolution) ? { falResolution: last.falResolution } : {};
+ return { pick, options };
+}
+
const isLtx25 = (model) => /^ltx25/.test(model?.runtime || '');
/**
@@ -92,7 +119,10 @@ export function renderTargetOverrides(value, saved, options = {}, context = {})
if (!value) return null;
const spanSec = shotSpan(context.scene);
if (value === 'local') {
- const modelId = options.modelId || defaultLocalModelId({ ...context, saved });
+ // A remembered model this shot can't use (a non-lip-sync model on a lip-synced shot) falls back to the default.
+ const choices = localModelChoices(context.models || [], context.performance);
+ const picked = options.modelId && (!choices.length || choices.some((m) => m.id === options.modelId)) ? options.modelId : null;
+ const modelId = picked || defaultLocalModelId({ ...context, saved });
const model = (context.models || []).find((m) => m.id === modelId);
const numFrames = context.performance ? null : options.numFrames || (model ? coveringFrames(model, spanSec) : null);
return { backend: 'local', ...(modelId ? { modelId } : {}), ...(numFrames ? { numFrames } : {}) };
@@ -127,7 +157,11 @@ function OptionSelect({ id, label, value, onChange, disabled, children }) {
export default function SceneRenderTarget({
id, value, onChange, options = {}, onOptionsChange, performance, saved, scene = null, models = [], defaultModel = '', disabled = false,
}) {
- const set = (patch) => onOptionsChange?.({ ...options, ...patch });
+ const set = (patch) => {
+ const next = { ...options, ...patch };
+ onOptionsChange?.(next);
+ rememberRenderTarget(value, next);
+ };
const spanSec = shotSpan(scene);
const overrides = renderTargetOverrides(value, saved, options, { models, defaultModel, performance, scene });
const localChoices = localModelChoices(models, performance);
@@ -138,7 +172,7 @@ export default function SceneRenderTarget({
<>
<span className="flex min-w-0 flex-1 basis-48 items-center gap-1 sm:flex-none">
<label htmlFor={id} className="text-xs">Render on</label>
- <select id={id} value={value} onChange={(e) => { onChange(e.target.value); onOptionsChange?.({}); }} disabled={disabled}
+ <select id={id} value={value} onChange={(e) => { onChange(e.target.value); onOptionsChange?.({}); rememberRenderTarget(e.target.value); }} disabled={disabled}
title="Where this shot's clip renders. Only this shot; the project setting stays as it is."
className={`${SELECT} flex-1 sm:flex-none`}>
{renderTargetOptions({ performance, saved, endFrame: Boolean(scene?.endImageId) }).map((option) => (
diff --git a/client/src/components/musicVideo/SceneRenderTarget.test.jsx b/client/src/components/musicVideo/SceneRenderTarget.test.jsx
index a2d7b02045..39776deb1c 100644
--- a/client/src/components/musicVideo/SceneRenderTarget.test.jsx
+++ b/client/src/components/musicVideo/SceneRenderTarget.test.jsx
@@ -1,6 +1,7 @@
-import { describe, expect, it } from 'vitest';
+import { beforeEach, describe, expect, it } from 'vitest';
import { render, screen, within } from '@testing-library/react';
-import SceneRenderTarget from './SceneRenderTarget.jsx';
+import SceneRenderTarget, { lastRenderTarget, rememberRenderTarget, renderTargetOverrides } from './SceneRenderTarget.jsx';
+import { FAL_IMAGE_VIDEO_MODELS, falVideoResolutions } from '../../lib/falVideoModels.js';
const models = [
{ id: 'ltx25_example', name: 'LTX-2.5 Example', runtime: 'ltx25', supportedModes: ['text', 'image', 'fflf', 'a2v'] },
@@ -23,3 +24,22 @@ describe('the shot card local model picker', () => {
expect(modelNames(true)).toEqual(['LTX-2.5 Example', 'Ref2VA Example']);
});
});
+
+describe('a remembered Render on pick', () => {
+ beforeEach(() => localStorage.clear());
+
+ // Uniquely catches a remembered non-lip-sync local model reaching a lip-synced render, or a fal size the model lacks.
+ it('renders a lip-synced shot on the default lip-sync model, and carries a fal size only to a model that has it', () => {
+ rememberRenderTarget('local', { modelId: 'wan_example' });
+ const { pick, options } = lastRenderTarget({ performance: true, saved: {} });
+ expect(renderTargetOverrides(pick, {}, options, { models, performance: true })).toMatchObject({ backend: 'local', modelId: 'ltx25_example' });
+ expect(renderTargetOverrides(pick, {}, options, { models, performance: false })).toMatchObject({ modelId: 'wan_example' });
+
+ const sized = FAL_IMAGE_VIDEO_MODELS.find((model) => falVideoResolutions(model).length > 1);
+ const size = falVideoResolutions(sized).at(-1);
+ rememberRenderTarget(`fal:${sized.id}`, { falResolution: size });
+ expect(lastRenderTarget({ performance: false, saved: {} })).toEqual({ pick: `fal:${sized.id}`, options: { falResolution: size } });
+ rememberRenderTarget(`fal:${sized.id}`, { falResolution: '9999p' });
+ expect(lastRenderTarget({ performance: false, saved: {} }).options).toEqual({});
+ });
+});
diff --git a/client/src/components/musicVideo/SceneTakeStrip.jsx b/client/src/components/musicVideo/SceneTakeStrip.jsx
index ca296033fb..aef929b63b 100644
--- a/client/src/components/musicVideo/SceneTakeStrip.jsx
+++ b/client/src/components/musicVideo/SceneTakeStrip.jsx
@@ -14,10 +14,11 @@ const KIND_LABEL = { image: 'Frame takes', video: 'Clip takes', endImage: 'End f
* larger size in the project contact sheet.
*
* A legacy take (a pre-takes selection the server hasn't materialized yet) is
- * shown but has no actions — it has no take id to address.
+ * shown but has no actions — it has no take id to address. `grid` lays the
+ * takes out in rows that fit the width instead of one scrolling row.
*/
export default function SceneTakeStrip({
- scene, kind, busy = false, large = false, onSelect, onReview, onOpenPreview,
+ scene, kind, busy = false, large = false, grid = false, onSelect, onReview, onOpenPreview,
}) {
const [noteFor, setNoteFor] = useState(null);
const [noteDraft, setNoteDraft] = useState('');
@@ -31,7 +32,7 @@ export default function SceneTakeStrip({
setNoteFor(null);
if ((take.note || '') !== noteDraft.trim()) onReview?.(take, { note: noteDraft.trim() || null });
};
- const thumbClass = large ? 'w-40' : 'w-24';
+ const thumbClass = grid ? 'min-w-0' : `${large ? 'w-40' : 'w-24'} shrink-0`;
const noteInputId = (take) => `mv-take-note-${scene.sceneId}-${take.takeId}`;
return (
@@ -39,7 +40,7 @@ export default function SceneTakeStrip({
<div className="text-[11px] text-port-text-muted">
{KIND_LABEL[kind]} ({takes.length})
</div>
- <ul className="flex gap-2 overflow-x-auto pb-1" aria-label={`${KIND_LABEL[kind]} for ${scene.label || `scene ${scene.order + 1}`}`}>
+ <ul className={grid ? 'grid grid-cols-[repeat(auto-fill,minmax(6rem,1fr))] gap-2' : 'flex gap-2 overflow-x-auto pb-1'} aria-label={`${KIND_LABEL[kind]} for ${scene.label || `scene ${scene.order + 1}`}`}>
{takes.map((take) => {
const isSelected = take.assetId === selected;
const rejected = take.status === 'rejected';
@@ -47,7 +48,7 @@ export default function SceneTakeStrip({
const playKey = take.takeId || take.assetId;
const playing = kind === 'video' && playingId === playKey;
return (
- <li key={take.takeId || `legacy-${take.assetId}`} className={`${thumbClass} shrink-0 space-y-1`}>
+ <li key={take.takeId || `legacy-${take.assetId}`} className={`${thumbClass} space-y-1`}>
<button
type="button"
data-take-focus=""
diff --git a/client/src/hooks/useMusicVideoSceneMedia.js b/client/src/hooks/useMusicVideoSceneMedia.js
index 7b4187dbdf..212745ee66 100644
--- a/client/src/hooks/useMusicVideoSceneMedia.js
+++ b/client/src/hooks/useMusicVideoSceneMedia.js
@@ -222,18 +222,21 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
* tracking it (a batch registers the job there, so a terminal event that raced
* ahead of the kickoff is still attributed to it).
*/
- const generateFrame = (scene, { revisionId, onJob } = {}) => {
+ const generateFrame = (scene, { revisionId, onJob, referenceImageId = null } = {}) => {
const conditioning = conditioningReferences(project, scene);
const problem = shotActionContractProblem(scene.direction?.actionContract, scene);
if (problem) { toast.error(problem); return Promise.resolve({ ok: false }); }
- const prompt = buildFramePrompt(scene);
- if (!prompt) { toast.error('Add a frame prompt or shot prompt first'); return Promise.resolve({ ok: false }); }
+ const framePrompt = buildFramePrompt(scene);
+ if (!framePrompt) { toast.error('Add a frame prompt or shot prompt first'); return Promise.resolve({ ok: false }); }
+ // A frame picked on the card (its start or end frame) leads the references, as the image this render reworks.
+ const prompt = referenceImageId ? `${framePrompt}\nStart from the first reference image and rework it to match this prompt.` : framePrompt;
+ const references = [...(referenceImageId ? [referenceImageId] : []), ...conditioning.map((ref) => ref.imageId).filter((id) => id !== referenceImageId)];
const projectId = project.id;
frameLane.startScene(scene.sceneId);
return generateImage({
prompt,
...musicVideoFrameGenSize(project),
- ...(conditioning.length ? { referenceImageFiles: conditioning.map((ref) => ref.imageId) } : {}),
+ ...(references.length ? { referenceImageFiles: references } : {}),
musicVideo: { projectId, sceneId: scene.sceneId, ...(revisionId ? { revisionId } : {}) },
}, { silent: true })
.then((res) => {
@@ -278,16 +281,18 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
* `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 generateEndFrame = (scene, { referenceImageId = scene.referenceImageId } = {}) => {
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.`,
+ // From a frame, keep its shot and change what the prompt asks; prompt only, render it like a start frame.
+ prompt: referenceImageId
+ ? `${endPrompt}. Keep the reference image's composition, subject and framing; change only what this prompt describes.`
+ : [endPrompt, style, direction].filter(Boolean).join(', '),
...musicVideoFrameGenSize(project),
- referenceImageFiles: [scene.referenceImageId],
+ ...(referenceImageId ? { referenceImageFiles: [referenceImageId] } : {}),
musicVideo: { projectId, sceneId: scene.sceneId, slot: 'end' },
}, { silent: true })
.then((res) => {
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index d878f840f0..c91536bd48 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -2500,6 +2500,17 @@ describe('MusicVideo visual spec, takes and handoff (#8965)', () => {
}), { silent: true }));
});
+ // Uniquely catches a frame picked as the render's image reference not reaching the request, or not leading the references.
+ it('renders a new frame take from the shot\'s own start frame when it is picked as the reference', async () => {
+ await openProject({ ...SPEC_PROJECT, scenes: [{ ...SPEC_PROJECT.scenes[0], referenceImageId: 'start.png' }] }, 'produce');
+ fireEvent.change(screen.getByLabelText('From', { selector: '#mv-scene-s1-start-from' }), { target: { value: 'start' } });
+ fireEvent.click(screen.getByRole('button', { name: /^New frame take$/ }));
+ await waitFor(() => expect(generateImage).toHaveBeenCalledWith(expect.objectContaining({
+ prompt: expect.stringContaining('Start from the first reference image'),
+ referenceImageFiles: ['start.png', 'mood.png'],
+ }), { silent: true }));
+ });
+
// Uniquely catches a trimmed clip landing only in Video Gen history, never as this shot's take, or not becoming the shot's clip.
it('trims the shot clip to a later start frame and makes it the shot\'s selected clip take', async () => {
const scene = { sceneId: 's1', order: 0, prompt: 'waves', referenceImageId: 'img1', videoHistoryId: 'h1',