Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: isolate music-video scene timing and provider plans (#11046)
Adam Eivye857a0fb9f13
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsxindex 7da2ed6742..7769b3fb87 100644--- a/client/src/components/musicVideo/SceneCard.jsx+++ b/client/src/components/musicVideo/SceneCard.jsx@@ -3,8 +3,8 @@ 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, Merge, Scissors } from 'lucide-react';-import { formatDurationSec, formatUsd } from '../../utils/formatters.js';+import { Trash2, Activity, ArrowUp, ArrowDown, ChevronRight, Image as ImageIcon, Video, Maximize2, AlertTriangle, ImagePlus, Clapperboard } from 'lucide-react';+import { formatDurationSec } from '../../utils/formatters.js';import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';import PerformanceEvidence from './PerformanceEvidence.jsx';import { planPerformanceRepair } from '../../lib/musicVideoShotTiming.js';@@ -17,17 +17,11 @@ const STILL_MOVE_LABELS = [['hold', 'Hold'], ['push', 'Push in'], ['pan', 'Pan']// #10583: the shared lyric type's zone and style for this shot (composition documents).const TEXT_ZONE_LABELS = { 'lower-left': 'Lower left', 'upper-right': 'Upper right', upper: 'Upper centre', lower: 'Lower centre', center: 'Centre', none: 'No lyrics' };const LYRIC_ROLE_LABELS = { line: 'Sung line', hook: 'Hook slam', stamp: 'Stamp', data: 'Data caption' };-import {- falSceneTake, grokCoverage, isPerformanceScene, performanceBlockedReason, performanceCapability, planPerformanceWindow, shotSplitLimit,-} from '../../lib/musicVideoShotTiming.js';+import { buildSceneTimingPresentation } from '../../lib/musicVideoSceneTiming.js';+import SceneTimingPlan from './SceneTimingPlan.jsx';import SceneRenderProgress from './SceneRenderProgress.jsx';-import { getFalVideoModel } from '../../lib/falVideoModels.js';import { COVERAGE_TOLERANCE_SEC, SCENE_ATTENTION_LABELS, sceneAttention } from '../../lib/musicVideoSceneAttention.js';-// "est. $0.81 (5.05s at 1080P)" — or null when the take cannot be priced.-const falEstimate = (take) => (take?.costUsd == null ? null- : `est. ${formatUsd(take.costUsd)} (${take.seconds}s${take.resolution ? ` at ${take.resolution}` : ''})`);-// The two timeline-bound scene fields rendered as identical number inputs.const SCENE_TIME_FIELDS = [['Start', 'startSec'], ['End', 'endSec']];@@ -122,28 +116,11 @@ 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';- const performance = isPerformanceScene(scene);- const capability = performance ? performanceCapability(lipSyncBackend) : null;- const timedSpan = typeof scene.startSec === 'number' && typeof scene.endSec === 'number' && scene.endSec > scene.startSec- ? scene.endSec - scene.startSec- : null;- const plan = capability- ? planPerformanceWindow({ startSec: scene.startSec, endSec: scene.endSec, songDurationSec: songDurationSec ?? Infinity, capability })- : null;- const performanceBlocked = performance- ? (capability ? (plan.ok ? null : plan.message) : performanceBlockedReason(lipSyncBackend))- : null;- const grokPlan = !performance && lipSyncBackend === 'grok' && timedSpan != null ? grokCoverage(timedSpan) : null;- const falTake = lipSyncBackend === 'fal' && layer === 'footage'- ? falSceneTake({ scene, videoSettings: falVideoSettings || {}, songDurationSec })- : null;- const falCost = falEstimate(falTake);- const performanceCost = falTake?.performance ? (falCost || capability?.costLabel) : capability?.costLabel;- const splitLimit = layer === 'footage' ? shotSplitLimit(scene, lipSyncBackend) : null;- const canSplit = splitLimit != null && timedSpan != null && timedSpan > splitLimit + 1e-6;- const mergedSpan = typeof scene.startSec === 'number' && typeof nextEndSec === 'number' ? nextEndSec - scene.startSec : null;- const canMerge = !!onMergeNext && !isLast && !documentComposition- && (splitLimit == null || (mergedSpan != null && mergedSpan <= splitLimit + 1e-6));+ const timing = buildSceneTimingPresentation({+ scene, layer, lipSyncBackend, songDurationSec, falVideoSettings,+ nextEndSec, isLast, documentComposition, hasMergeNext: !!onMergeNext,+ });+ const { performance, capability, performanceBlocked, performanceCost } = timing;const instruction = scene.takes?.find((take) => take.kind === 'video' && take.assetId === scene.videoHistoryId)?.shotInstruction;const repairPlan = planPerformanceRepair({ scene, temporal: performanceReview?.shot,excerptStartSec: performanceReview?.excerptStartSec, backend: lipSyncBackend, videoSettings: falVideoSettings || {} });@@ -363,44 +340,7 @@ export default function SceneCard({Set a start and end — a {{ card: 'title card', code: 'code-drawn shot' }[layer] || 'still'} runs for exactly its span.</p>)}- {performance && performanceBlocked && (- <div role="alert" className="flex items-start gap-2 rounded border border-port-warning/40 bg-port-warning/10 px-2 py-1.5 text-xs text-port-warning">- <AlertTriangle size={13} className="shrink-0 mt-0.5" />- <span className="min-w-0 break-words">{performanceBlocked}</span>- </div>- )}- {performance && !performanceBlocked && (- <p className="text-[11px] text-port-text-muted break-words" data-testid="performance-plan">- Lip-sync via {capability.label} ({capability.modelId}) · song {formatDurationSec(plan.windowStartSec)}–{formatDurationSec(plan.windowEndSec)}- {plan.editInSec > 0 ? ` · shot starts ${plan.editInSec.toFixed(2)}s into the take` : ''} · {performanceCost}- </p>- )}- {falTake && !falTake.performance && (- <p className="text-[11px] text-port-text-muted break-words" data-testid="fal-cutaway-plan">- fal.ai renders {falTake.seconds != null ? `a ${falTake.seconds}s ` : 'a '}clip on {getFalVideoModel(falTake.modelId)?.label || falTake.modelId}- {' · '}{falCost || 'cost unknown — billed to your fal.ai account'}- </p>- )}- {grokPlan && (- <p className={`text-[11px] break-words ${grokPlan.needsSplit ? 'text-port-warning' : 'text-port-text-muted'}`}>- Grok renders a {grokPlan.requestSec}s clip for this {timedSpan.toFixed(1)}s cutaway- {grokPlan.needsSplit ? ` — ${grokPlan.uncoveredSec.toFixed(1)}s uncovered; split the scene rather than loop it` : ''}. Motion timing in the prompt is approximate.- </p>- )}- {canSplit && onSplit && (- <button type="button" onClick={() => onSplit(scene.sceneId, lipSyncBackend || null)}- className="inline-flex items-center gap-1 rounded bg-port-bg border border-port-border hover:bg-port-border/40 px-2 py-1 text-xs min-h-[44px] sm:min-h-0"- title={`Cut this ${timedSpan.toFixed(1)}s shot into scenes of at most ${splitLimit.toFixed(2)}s at lyric pauses or phrase boundaries — nothing is looped or stretched`}>- <Scissors size={13} /> Split on lyric boundaries- </button>- )}- {canMerge && (- <button type="button" onClick={() => onMergeNext(scene.sceneId, lipSyncBackend || null)}- className="inline-flex items-center gap-1 rounded bg-port-bg border border-port-border hover:bg-port-border/40 px-2 py-1 text-xs min-h-[44px] sm:min-h-0"- title="Join this shot with the next one into a single shot — the inverse of split">- <Merge size={13} /> Merge with next- </button>- )}+ <SceneTimingPlan timing={timing} sceneId={scene.sceneId} lipSyncBackend={lipSyncBackend} onSplit={onSplit} onMergeNext={onMergeNext} />{underCovered && (<div role="alert" className="flex flex-wrap items-center gap-2 rounded border border-port-warning/40 bg-port-warning/10 px-2 py-1.5 text-xs text-port-warning"><AlertTriangle size={13} className="shrink-0" />diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsxindex 9bd7e7de52..e5248c5db2 100644--- a/client/src/components/musicVideo/SceneCard.test.jsx+++ b/client/src/components/musicVideo/SceneCard.test.jsx@@ -161,3 +161,85 @@ describe('Merge with next (#10810)', () => {expect(screen.queryByRole('button', { name: /Merge with next/ })).toBeNull();});});++describe('scene timing and provider presentation (#11046)', () => {+ const scene = { sceneId: 'timing', startSec: 10, endSec: 12, referenceImageId: 'frame.png', takes: [] };+ const props = { index: 0, expanded: true, onEditLocal: vi.fn(), onSave: vi.fn() };++ it('shows the supported song window, edit offset and saved resolution cost, including a zero offset and unknown song duration', () => {+ const performance = { ...scene, shotMode: 'performance' };+ const { rerender } = render(<SceneCard {...props} scene={performance} lipSyncBackend="fal" songDurationSec={30} />);+ const plan = () => screen.getByTestId('performance-plan').textContent;+ expect(plan()).toContain('Lip-sync via fal.ai MiniMax H3 lip-sync (minimax/h3-max/lip-sync/image-to-video)');+ expect(plan()).toContain('song 0:08–0:13');+ expect(plan()).toContain('shot starts 1.52s into the take');+ expect(plan()).toContain('est. $0.81 (5.05s at 1080P)');+ expect(screen.getByRole('button', { name: 'Generate video' }).title).toContain('est. $0.81');+ rerender(<SceneCard {...props} scene={{ ...performance, startSec: 0, endSec: 6 }} lipSyncBackend="fal"+ falVideoSettings={{ falLipSyncResolution: '768P' }} songDurationSec={null} />);+ expect(plan()).toContain('song 0:00–0:06');+ expect(plan()).not.toContain('shot starts');+ expect(plan()).toContain('est. $0.48 (6s at 768P)');+ expect(screen.getByRole('button', { name: 'Generate video' }).disabled).toBe(false);+ rerender(<SceneCard {...props} scene={{ ...performance, startSec: 0, endSec: 6 }} lipSyncBackend="fal" />);+ expect(screen.getByRole('button', { name: 'Generate video' }).disabled).toBe(false);+ rerender(<SceneCard {...props} scene={performance} lipSyncBackend="fal" songDurationSec={11} />);+ expect(screen.getByText('The performance shot runs past the end of the song.')).toBeTruthy();+ expect(screen.getByRole('button', { name: 'Generate video' }).disabled).toBe(true);+ });++ it('blocks unsupported performance generation and keeps the blocker on the generation control', () => {+ render(<SceneCard {...props} scene={{ ...scene, shotMode: 'performance' }} lipSyncBackend="grok" />);+ const blocker = screen.getByText(/Grok video is cutaway-only/);+ expect(blocker.closest('[role="alert"]')).toBeTruthy();+ expect(screen.queryByTestId('performance-plan')).toBeNull();+ const generate = screen.getByRole('button', { name: 'Generate video' });+ expect(generate.disabled).toBe(true);+ expect(generate.title).toBe(blocker.textContent);+ });++ it('shows the fal cutaway model and cost, preserves unknown model pricing, and distinguishes layer from render mode', () => {+ const { rerender } = render(<SceneCard {...props} scene={scene} lipSyncBackend="fal" />);+ expect(screen.getByTestId('fal-cutaway-plan').textContent).toContain('fal.ai renders a 6s clip on MiniMax Hailuo-02 Standard (image)');+ expect(screen.getByTestId('fal-cutaway-plan').textContent).toContain('est. $0.27 (6s at 768P)');+ rerender(<SceneCard {...props} scene={scene} lipSyncBackend="fal" falVideoSettings={{ falModelId: 'example/unpriced' }} />);+ expect(screen.getByTestId('fal-cutaway-plan').textContent).toContain('fal.ai renders a clip on example/unpriced');+ expect(screen.getByTestId('fal-cutaway-plan').textContent).toContain('cost unknown — billed to your fal.ai account');+ rerender(<SceneCard {...props} scene={{ ...scene, visualLayer: 'still', shotMode: 'performance' }} lipSyncBackend="fal" layered />);+ expect(screen.queryByTestId('fal-cutaway-plan')).toBeNull();+ expect(screen.queryByTestId('performance-plan')).toBeNull();+ rerender(<SceneCard {...props} scene={{ ...scene, visualLayer: 'still', shotMode: 'performance' }} lipSyncBackend="fal" />);+ expect(screen.queryByTestId('fal-cutaway-plan')).toBeNull();+ expect(screen.getByRole('button', { name: 'Generate video' }).disabled).toBe(false);+ });++ it('warns about uncovered Grok time and splits with the original scene/backend arguments only beyond the epsilon', () => {+ const onSplit = vi.fn();+ const { rerender } = render(<SceneCard {...props} scene={{ ...scene, startSec: 0, endSec: 13 }} lipSyncBackend="grok" onSplit={onSplit} />);+ expect(screen.getByText(/Grok renders a 10s clip for this 13.0s cutaway/).textContent).toContain('3.0s uncovered; split the scene rather than loop it');+ fireEvent.click(screen.getByRole('button', { name: 'Split on lyric boundaries' }));+ expect(onSplit).toHaveBeenCalledWith('timing', 'grok');+ rerender(<SceneCard {...props} scene={{ ...scene, startSec: 0, endSec: 10 + 1e-6 }} lipSyncBackend="grok" onSplit={onSplit} />);+ expect(screen.queryByRole('button', { name: 'Split on lyric boundaries' })).toBeNull();+ rerender(<SceneCard {...props} scene={{ ...scene, startSec: 0, endSec: 10 + 2e-6 }} lipSyncBackend="grok" onSplit={onSplit} />);+ expect(screen.getByRole('button', { name: 'Split on lyric boundaries' })).toBeTruthy();+ rerender(<SceneCard {...props} scene={{ ...scene, endSec: null }} lipSyncBackend="grok" onSplit={onSplit} />);+ expect(screen.queryByText(/Grok renders/)).toBeNull();+ expect(screen.queryByRole('button', { name: 'Split on lyric boundaries' })).toBeNull();+ });++ it('merges at the provider limit including its epsilon, requires the next span for bounded providers, and preserves default-backend arguments', () => {+ const onMergeNext = vi.fn();+ const current = { ...scene, startSec: 0, endSec: 4 };+ const { rerender } = render(<SceneCard {...props} scene={current} lipSyncBackend="grok" nextEndSec={10 + 1e-6} onMergeNext={onMergeNext} />);+ fireEvent.click(screen.getByRole('button', { name: 'Merge with next' }));+ expect(onMergeNext).toHaveBeenLastCalledWith('timing', 'grok');+ rerender(<SceneCard {...props} scene={current} lipSyncBackend="grok" nextEndSec={10 + 2e-6} onMergeNext={onMergeNext} />);+ expect(screen.queryByRole('button', { name: 'Merge with next' })).toBeNull();+ rerender(<SceneCard {...props} scene={current} lipSyncBackend="grok" onMergeNext={onMergeNext} />);+ expect(screen.queryByRole('button', { name: 'Merge with next' })).toBeNull();+ rerender(<SceneCard {...props} scene={current} onMergeNext={onMergeNext} />);+ fireEvent.click(screen.getByRole('button', { name: 'Merge with next' }));+ expect(onMergeNext).toHaveBeenLastCalledWith('timing', null);+ });+});diff --git a/client/src/components/musicVideo/SceneTimingPlan.jsx b/client/src/components/musicVideo/SceneTimingPlan.jsxnew file mode 100644index 0000000000..b5fe2ab960--- /dev/null+++ b/client/src/components/musicVideo/SceneTimingPlan.jsx@@ -0,0 +1,53 @@+import { AlertTriangle, Merge, Scissors } from 'lucide-react';+import { formatDurationSec } from '../../utils/formatters.js';+import { getFalVideoModel } from '../../lib/falVideoModels.js';++/** Stateless provider plan and scene split/merge controls, without wrapper DOM. */+export default function SceneTimingPlan({ timing, sceneId, lipSyncBackend, onSplit, onMergeNext }) {+ const {+ performance, performanceBlocked, capability, plan, performanceCost,+ falTake, falCost, grokPlan, timedSpan, canSplit, splitLimit, canMerge,+ } = timing;+ return (+ <>+ {performance && performanceBlocked && (+ <div role="alert" className="flex items-start gap-2 rounded border border-port-warning/40 bg-port-warning/10 px-2 py-1.5 text-xs text-port-warning">+ <AlertTriangle size={13} className="shrink-0 mt-0.5" />+ <span className="min-w-0 break-words">{performanceBlocked}</span>+ </div>+ )}+ {performance && !performanceBlocked && (+ <p className="text-[11px] text-port-text-muted break-words" data-testid="performance-plan">+ Lip-sync via {capability.label} ({capability.modelId}) · song {formatDurationSec(plan.windowStartSec)}–{formatDurationSec(plan.windowEndSec)}+ {plan.editInSec > 0 ? ` · shot starts ${plan.editInSec.toFixed(2)}s into the take` : ''} · {performanceCost}+ </p>+ )}+ {falTake && !falTake.performance && (+ <p className="text-[11px] text-port-text-muted break-words" data-testid="fal-cutaway-plan">+ fal.ai renders {falTake.seconds != null ? `a ${falTake.seconds}s ` : 'a '}clip on {getFalVideoModel(falTake.modelId)?.label || falTake.modelId}+ {' · '}{falCost || 'cost unknown — billed to your fal.ai account'}+ </p>+ )}+ {grokPlan && (+ <p className={`text-[11px] break-words ${grokPlan.needsSplit ? 'text-port-warning' : 'text-port-text-muted'}`}>+ Grok renders a {grokPlan.requestSec}s clip for this {timedSpan.toFixed(1)}s cutaway+ {grokPlan.needsSplit ? ` — ${grokPlan.uncoveredSec.toFixed(1)}s uncovered; split the scene rather than loop it` : ''}. Motion timing in the prompt is approximate.+ </p>+ )}+ {canSplit && onSplit && (+ <button type="button" onClick={() => onSplit(sceneId, lipSyncBackend || null)}+ className="inline-flex items-center gap-1 rounded bg-port-bg border border-port-border hover:bg-port-border/40 px-2 py-1 text-xs min-h-[44px] sm:min-h-0"+ title={`Cut this ${timedSpan.toFixed(1)}s shot into scenes of at most ${splitLimit.toFixed(2)}s at lyric pauses or phrase boundaries — nothing is looped or stretched`}>+ <Scissors size={13} /> Split on lyric boundaries+ </button>+ )}+ {canMerge && (+ <button type="button" onClick={() => onMergeNext(sceneId, lipSyncBackend || null)}+ className="inline-flex items-center gap-1 rounded bg-port-bg border border-port-border hover:bg-port-border/40 px-2 py-1 text-xs min-h-[44px] sm:min-h-0"+ title="Join this shot with the next one into a single shot — the inverse of split">+ <Merge size={13} /> Merge with next+ </button>+ )}+ </>+ );+}diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 9b689f9b4e..198fda915a 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -66,6 +66,7 @@ grep -i "what you want to do" client/src/lib/README.md| `musicVideoTakes.js` | Music-video scene takes view helpers (#8965): `sceneTakeList(scene, kind)` lists a scene's image/video takes with an un-materialized pre-takes selection appended as a read-only `legacy` take; `takePreviewKey`, `takeThumbUrl`, `takeClipUrl` (hover-preview clip), `sceneHasPendingDecision` (contact-sheet filter), `takeProvenance`; `TAKE_SLOT` maps a take kind to its selection field. Used by `components/musicVideo/SceneTakeStrip.jsx` and `pages/MusicVideo.jsx`. || `musicVideoSceneAttention.js` | Music Video per-scene attention model (#10152): `sceneAttention(scene, ctx)` returns the codes (`missing-frame`, `missing-clip`, `under-covered`, `contract-problem`, `perf-blocked`, `candidates-pending`, `plate-unverified`, `no-span`, `last-failure`) behind the collapsed scene-row chips, the Board `?scenes=attention\|missing\|all` filter (`parseSceneFilter`, `sceneMatchesFilter`) and the Produce per-shot strip; `SCENE_ATTENTION_LABELS`. Used by `components/musicVideo/SceneCard.jsx`, `stages/BoardStage.jsx` and `stages/ProduceStage.jsx`. || `musicVideoCoverOverlay.js` | Cover-art lettering preview (#10345): re-export of `server/lib/musicVideoCoverOverlay.js` (the design vocabulary, `normalizeCoverDesign`, `coverOverlaySvg`) plus `canvasCoverWidths(design, texts, fonts)`, which measures text with a canvas so the live preview wraps and sizes the title the way the server's measured render does. |+| `musicVideoSceneTiming.js` | `buildSceneTimingPresentation`: pure provider timing, cost, coverage and split/merge projection for the Music Video scene card, reusing canonical shot-timing policy. || `musicVideoShotTiming.js` | Re-export of `server/lib/musicVideoShotTiming.js` (#8977) — shot modes, the verified source-audio lip-sync capability table, `performanceBlockedReason`, `planPerformanceRepair` (measured accepted-prefix boundary, suffix interval and next spend), `planPerformanceWindow`, `grokCoverage`, `approximateMotionCues`, `shotSplitLimit` (when a scene offers a lyric-boundary split), `falSceneTake` (a fal take's model, length, resolution and estimated cost). Used by `hooks/useMusicVideoSceneMedia.js` and `components/musicVideo/SceneCard.jsx`. || `musicVideoStages.js` | Music Video page stage model: `MUSIC_VIDEO_STAGES` (six steps: Song `setup` → Look `cast-sets` → Storyboard `board` → Make `produce` → Final render `review` → Publish; a retired `compose` link resolves to Make), `resolveStageParam(value)` for the `:stage` route param, `deriveStages(project)` (per-stage `done`/`active`/`blocked`/`todo` + `current`, the first incomplete step; a live production run pins Make), `deriveNextAction(project, ctx)` (the one primary action the sticky header offers — approve Cast & Sets, verify lyric timing, stop/resume production, render final, …), `describeProjectStatus` (the header line and the step that needs the director), `autopilotStatus` (the header Autopilot button), `projectSpend(project)` (paid generation used vs. cap), `projectShotSummary(project)` (document shots or scene counts), `stageChecklist(stageId, project, readiness)` (what one step still needs, with the open approval's reason and a scroll anchor; an `optional` item, such as Make's animated proof, is listed but not counted), `summarizeStoryboardProblems(problems)` (folds the server's one-sentence-per-shot storyboard problems into one count line per kind), `stepNotes(project, readiness, publish)` (one fact per step for the step list), `listPreviewSources` (final, live composition, drafts, then the storyboard animatic), `projectServicesSummary(project)` (the saved image/video render services), `compareMusicVideoProjectsNewestFirst(a, b)` (sort projects newest created / updated first for project cards and pickers), and `currentProductionRun`; `productionReviewStopGuidance` separates current approval blockers from historical run stops. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. || `musicVideoAttention.js` | Music Video "Needs attention" model (#9940): `deriveAttentionItems(project, live)` returns the banner rows for server-held states a client-orchestrated workflow can strand — an open/rendering revision, an interrupted Cast & Sets stage, a running auto-review waiting on its revised sections, a final render nobody is watching — derived from the persisted record so they survive a reload (healthy work this tab can see progressing is not flagged); `openRevisionOf(project)`; `ATTENTION_ANCHOR_ID` + `revealAttention()` scroll a refusal toast to the banner. Used by `components/musicVideo/NeedsAttentionBanner.jsx` and `pages/MusicVideo.jsx`. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex 6e0352a306..bdf51852b3 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -75,6 +75,7 @@ export * from './musicVideoAspect.js';export * from './musicVideoMotion.js';export * from './musicVideoTakes.js';export * from './musicVideoSceneAttention.js';+export * from './musicVideoSceneTiming.js';export * from './musicVideoCoverOverlay.js';export * from './musicVideoShotTiming.js';export * from './musicVideoStages.js';diff --git a/client/src/lib/musicVideoSceneTiming.js b/client/src/lib/musicVideoSceneTiming.jsnew file mode 100644index 0000000000..9cef3bd31e--- /dev/null+++ b/client/src/lib/musicVideoSceneTiming.js@@ -0,0 +1,44 @@+import { formatUsd } from '../utils/formatters.js';+import {+ falSceneTake, grokCoverage, isPerformanceScene, performanceBlockedReason, performanceCapability, planPerformanceWindow, shotSplitLimit,+} from './musicVideoShotTiming.js';++// "est. $0.81 (5.05s at 1080P)" — or null when the take cannot be priced.+const falEstimate = (take) => (take?.costUsd == null ? null+ : `est. ${formatUsd(take.costUsd)} (${take.seconds}s${take.resolution ? ` at ${take.resolution}` : ''})`);++/**+ * Provider timing and cost presentation for one scene. Domain policy remains+ * in the canonical shot-timing helpers shared with media submission.+ */+export function buildSceneTimingPresentation({+ scene, layer, lipSyncBackend, songDurationSec, falVideoSettings,+ nextEndSec, isLast, documentComposition, hasMergeNext,+}) {+ const performance = isPerformanceScene(scene);+ const capability = performance ? performanceCapability(lipSyncBackend) : null;+ const timedSpan = typeof scene.startSec === 'number' && typeof scene.endSec === 'number' && scene.endSec > scene.startSec+ ? scene.endSec - scene.startSec+ : null;+ const plan = capability+ ? planPerformanceWindow({ startSec: scene.startSec, endSec: scene.endSec, songDurationSec: songDurationSec ?? Infinity, capability })+ : null;+ const performanceBlocked = performance+ ? (capability ? (plan.ok ? null : plan.message) : performanceBlockedReason(lipSyncBackend))+ : null;+ const grokPlan = !performance && lipSyncBackend === 'grok' && timedSpan != null ? grokCoverage(timedSpan) : null;+ const falTake = lipSyncBackend === 'fal' && layer === 'footage'+ ? falSceneTake({ scene, videoSettings: falVideoSettings || {}, songDurationSec })+ : null;+ const falCost = falEstimate(falTake);+ const performanceCost = falTake?.performance ? (falCost || capability?.costLabel) : capability?.costLabel;+ const splitLimit = layer === 'footage' ? shotSplitLimit(scene, lipSyncBackend) : null;+ const canSplit = splitLimit != null && timedSpan != null && timedSpan > splitLimit + 1e-6;+ const mergedSpan = typeof scene.startSec === 'number' && typeof nextEndSec === 'number' ? nextEndSec - scene.startSec : null;+ const canMerge = hasMergeNext && !isLast && !documentComposition+ && (splitLimit == null || (mergedSpan != null && mergedSpan <= splitLimit + 1e-6));+ return {+ performance, capability, timedSpan, plan, performanceBlocked, grokPlan,+ falTake, falCost, performanceCost, splitLimit, canSplit, mergedSpan, canMerge,+ };+}