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
feat: preflight code-first music video assets (#9301)
[._.]/ Adam Eivyaf2b99e5b422
diff --git a/client/src/components/musicVideo/AutopilotPanel.jsx b/client/src/components/musicVideo/AutopilotPanel.jsxindex 6bb318016c..b96606ca83 100644--- a/client/src/components/musicVideo/AutopilotPanel.jsx+++ b/client/src/components/musicVideo/AutopilotPanel.jsx@@ -6,6 +6,7 @@ import useProviderModels from '../../hooks/useProviderModels.js';import ProviderModelSelector from '../ProviderModelSelector.jsx';import ToggleChip from '../ui/ToggleChip.jsx';import MediumPlanSummary from './MediumPlanSummary.jsx';+import { codeFirstProductionAssets } from '../../../../server/lib/musicVideoMediumPlan.js';import {DEFAULT_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOLS, automationDraftFrom, automationFromDraft,} from '../../lib/musicVideoAutomation.js';@@ -295,12 +296,25 @@ function ProductionSection({ project, production }) {const run = currentProductionRun(project);const active = run && RESUMABLE_RUN_STATUSES.has(run.status);const codeFirst = project.productionPolicy?.strategy === 'code-first';+ const assets = codeFirst ? codeFirstProductionAssets(project) : null;+ const count = (action) => assets.steps.filter((step) => step.action === action).length;return (<div className="rounded border border-port-border p-2 space-y-2 text-xs" aria-label="Production run"><span className="font-medium flex items-center gap-1"><Clapperboard size={12} /> Autonomous production (opt-in)</span>{run && <RunView run={run} production={production} codeFirst={codeFirst} />}{codeFirst && <><MediumPlanSummary project={project} />+ <div className="rounded border border-port-border p-2 space-y-1" aria-label="Code-first asset preflight">+ <p className="font-medium">Selected asset preparation</p>+ <p className="text-port-text-muted">+ Procedural: {count('code')} · Reused stills: {count('reuse-image')} · Reused takes: {count('reuse-video')} · Still jobs: {count('generate-image')} · Video jobs: {count('generate-video')}+ </p>+ <p className="text-port-text-muted">Routes needed for selected assets: {assets.requiredRoutes.image ? 'image' : 'no image'} · {assets.requiredRoutes.video ? 'video' : 'no video'}</p>+ {assets.conflicts.length > 0 && <ul className="list-disc pl-4 text-port-warning">+ {assets.conflicts.map((conflict, index) => <li key={`${index}-${conflict}`}>{conflict}</li>)}+ </ul>}+ <p className="text-port-text-muted">Code authoring, still jobs, and video jobs use separate providers and costs when autonomous dispatch is available. This preflight does not submit jobs.</p>+ </div><p className="text-port-warning">Autonomous code-first production is waiting for document authoring and review checkpoints. Use the mixed-media document controls for the approved plan.</p></>}{!active && !codeFirst && <StartForm key={run?.id || 'new'} project={project} production={production} />}diff --git a/client/src/components/musicVideo/AutopilotPanel.test.jsx b/client/src/components/musicVideo/AutopilotPanel.test.jsxindex 59e0344419..37981f05dc 100644--- a/client/src/components/musicVideo/AutopilotPanel.test.jsx+++ b/client/src/components/musicVideo/AutopilotPanel.test.jsx@@ -160,9 +160,40 @@ describe('AutopilotPanel production run', () => {audioAnalysis: { durationSec: 30 }, scenes: [], treatment: { shotDirections: [] },}} />);expect(screen.getByText(/generated video 0 \/ 0 seconds/)).toBeTruthy();+ expect(screen.getByLabelText('Code-first asset preflight')).toHaveTextContent('Routes needed for selected assets: no image · no video');expect(screen.queryByRole('button', { name: /Start production/ })).toBeNull();});+ it('preflights selected assets without treating procedural or imported shots as generation jobs', () => {+ const directions = [+ { sceneId: 'code', medium: 'procedural', mediumRationale: 'Type motion' },+ { sceneId: 'still', medium: 'still', mediumRationale: 'Poster image' },+ { sceneId: 'imported', medium: 'existing-footage', mediumRationale: 'Existing performance' },+ { sceneId: 'exception', medium: 'generated-footage', mediumRationale: 'One motion exception' },+ ];+ const scenes = [+ { sceneId: 'code', startSec: 0, endSec: 5 },+ { sceneId: 'still', startSec: 5, endSec: 10, referenceImageId: 'selected-image' },+ { sceneId: 'imported', startSec: 10, endSec: 15 },+ { sceneId: 'exception', startSec: 15, endSec: 20 },+ ];+ const project = { id: 'p1', productionRuns: [], productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 25 },+ audioAnalysis: { durationSec: 20 }, scenes, treatment: { shotDirections: directions } };+ const { rerender } = render(<ProductionHarness initial={project} />);+ const preflight = screen.getByLabelText('Code-first asset preflight');+ expect(preflight).toHaveTextContent('Procedural: 1 · Reused stills: 1 · Reused takes: 0 · Still jobs: 1 · Video jobs: 1');+ expect(preflight).toHaveTextContent('Routes needed for selected assets: image · video');+ expect(preflight).toHaveTextContent('Select an existing take for imported before production.');+ expect(api.startMusicVideoProduction).not.toHaveBeenCalled();+ // A selected imported take is reused; the generated exception still needs+ // its own frame and video submission.+ rerender(<AutopilotPanel project={{ ...project, scenes: scenes.map((scene) => scene.sceneId === 'imported'+ ? { ...scene, videoHistoryId: 'selected-video' } : scene) }} production={IDLE_PRODUCTION}+ onSave={vi.fn()} onKickoff={vi.fn()} kickoffBusy={false} />);+ expect(screen.getByLabelText('Code-first asset preflight')).toHaveTextContent('Reused takes: 1 · Still jobs: 1 · Video jobs: 1');+ expect(screen.getByLabelText('Code-first asset preflight')).not.toHaveTextContent('Select an existing take');+ });+it('starts only when the director presses Start, with the allowed pool and limits', async () => {api.startMusicVideoProduction.mockResolvedValue({ project: { id: 'p1', productionRuns: [run()] }, run: run() });render(<ProductionHarness initial={{ id: 'p1', productionRuns: [] }} />);diff --git a/server/lib/README.md b/server/lib/README.mdindex 4358271774..c4efe652ea 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -803,4 +803,4 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `musicVideoAspect.js` | `musicVideoAspect(project)` (treatment brief aspect, default 16:9), `MUSIC_VIDEO_FRAME_GEN_SIZES` and `musicVideoFrameGenSize(project)`: the size every Music Video reference frame is requested at, so a backend never picks portrait for a 16:9 video. `musicVideoAtAspect(project, aspect)` re-frames the project for one render (a vertical social cut) without touching the record. Shared by `productionDispatch.js`, `documentRender.js` and the client board. || `musicVideoMotion.js` | `MOTION_CONTINUITY_CLAUSE`: the clause every Music Video motion (i2v) prompt ends with, pinning the reference frame's lighting, time of day and palette. Shared by `handoff.js` and the client board. || `musicVideoConditioning.js` | `musicVideoStyleImages`, `musicVideoStylePrompt`, `musicVideoStyleBasis`, and `musicVideoStyleReferenceCapacity` supply bounded moodboard conditioning and text fallback; `musicVideoConditioningReferences(project, scene)` selects the approved character sheet and scene's mapped set plate, with capped project-wide fallback; shared by board and production. |-| `musicVideoMediumPlan.js` | `normalizeMusicVideoProductionPolicy`, `planMusicVideoMedia`, and `summarizeMusicVideoMediumPlan`: pinned shot media and union-of-intervals video allowance shared by treatment planning and Board review. |+| `musicVideoMediumPlan.js` | `normalizeMusicVideoProductionPolicy`, `planMusicVideoMedia`, `summarizeMusicVideoMediumPlan`, and `codeFirstProductionAssets`: pinned shot media, union-of-intervals video allowance, and selected-asset preflight shared by planning and Board review. |diff --git a/server/lib/musicVideoMediumPlan.js b/server/lib/musicVideoMediumPlan.jsindex 9dcf0e5c87..1f1bb79c62 100644--- a/server/lib/musicVideoMediumPlan.js+++ b/server/lib/musicVideoMediumPlan.js@@ -84,6 +84,42 @@ export function summarizeMusicVideoMediumPlan(project, directions = project?.tre};}+/**+ * Execution preflight for an approved code-first plan. This describes work,+ * never dispatches it: an existing selected asset wins over generation, and+ * procedural scenes need neither a reference frame nor a video provider.+ * Imported-footage gaps are conflicts, not permission to generate a take.+ */+export function codeFirstProductionAssets(project) {+ const plan = summarizeMusicVideoMediumPlan(project);+ if (plan.strategy !== 'code-first') return null;+ const directions = new Map((project?.treatment?.shotDirections || []).map((d) => [d.sceneId, d]));+ const steps = [];+ const conflicts = plan.unresolved.filter((item) => item.blocking).map((item) => item.message);+ for (const scene of project?.scenes || []) {+ const medium = directions.get(scene.sceneId)?.medium;+ if (!MUSIC_VIDEO_MEDIA.includes(medium)) continue;+ if (medium === 'procedural') {+ steps.push({ sceneId: scene.sceneId, medium, action: 'code' });+ } else if (medium === 'still') {+ steps.push({ sceneId: scene.sceneId, medium, action: scene.referenceImageId ? 'reuse-image' : 'generate-image' });+ } else if (medium === 'existing-footage') {+ if (scene.videoHistoryId) steps.push({ sceneId: scene.sceneId, medium, action: 'reuse-video' });+ else conflicts.push(`Select an existing take for ${scene.label || scene.sceneId} before production.`);+ } else if (scene.videoHistoryId) {+ steps.push({ sceneId: scene.sceneId, medium, action: 'reuse-video' });+ } else {+ if (!scene.referenceImageId) steps.push({ sceneId: scene.sceneId, medium, action: 'generate-image' });+ steps.push({ sceneId: scene.sceneId, medium, action: 'generate-video' });+ }+ }+ return { steps, conflicts,+ requiredRoutes: {+ image: steps.some((step) => step.action === 'generate-image'),+ video: steps.some((step) => step.action === 'generate-video'),+ } };+}+/** Retain director pins; allocate optional generated shots only within the union budget. */export function planMusicVideoMedia(project, directions) {const policy = normalizeMusicVideoProductionPolicy(project.productionPolicy);