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

feat: music-video-autopilot Schedule settings form and existing mood board option (#9475)

Adam Eivy87aaf3315c8c
diff --git a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.jsx b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.jsx
new file mode 100644
index 0000000000..661bf2a7fd
--- /dev/null
+++ b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.jsx
@@ -0,0 +1,116 @@
+import { useEffect, useState } from 'react';
+import ToggleChip from '../../../ui/ToggleChip';
+import ProviderModelSelector from '../../../ProviderModelSelector';
+import ToolPicker from '../../../musicVideo/ToolPicker';
+import MoodBoardPicker from '../../../musicVideo/MoodBoardPicker';
+import useProviderModels from '../../../../hooks/useProviderModels';
+import {
+ AUTONOMOUS_CHECKPOINT_IDS, AUTONOMOUS_CHECKPOINT_LABELS, autopilotDraftFromParams, autopilotParamsFromDraft,
+} from '../../../../lib/musicVideoAutonomous';
+
+const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm';
+
+/**
+ * Settings for the `music-video-autopilot` scheduled task, stored in
+ * `taskMetadata.musicVideoAutopilot`: the same fields as the Autonomous start
+ * drawer (tools, per-tool models, budget, limits, checkpoints, LLM, mood
+ * board) plus the Brain idea tags a run may draw from. Saved explicitly — the
+ * form holds a draft so a half-edited budget never hits the server.
+ */
+export default function MusicVideoAutopilotSettings({ taskType, config, onUpdate, updating, setUpdating }) {
+ const saved = config.taskMetadata?.musicVideoAutopilot;
+ const [draft, setDraft] = useState(() => autopilotDraftFromParams(saved));
+ const llm = useProviderModels({ allowDefault: true, silent: true });
+ const [llmSeeded, setLlmSeeded] = useState(false);
+ const patch = (next) => setDraft((d) => ({ ...d, ...next }));
+
+ // Restore the saved writer-LLM pin once the provider catalog has loaded.
+ const { setSelectedProviderId, setSelectedModel } = llm;
+ const providersLoaded = llm.providers.length > 0;
+ useEffect(() => {
+ if (llmSeeded || !providersLoaded) return;
+ if (saved?.llm?.providerId) {
+ setSelectedProviderId(saved.llm.providerId);
+ setSelectedModel(saved.llm.model || '');
+ }
+ setLlmSeeded(true);
+ }, [llmSeeded, providersLoaded, saved, setSelectedProviderId, setSelectedModel]);
+
+ const toggleCheckpoint = (id) => patch({
+ checkpoints: AUTONOMOUS_CHECKPOINT_IDS.filter((c) => (c === id ? !draft.checkpoints.includes(c) : draft.checkpoints.includes(c))),
+ });
+
+ const handleSave = async (e) => {
+ e.preventDefault();
+ if (updating) return;
+ setUpdating(true);
+ const params = autopilotParamsFromDraft(draft, saved, {
+ providerId: llm.selectedProviderId || undefined, model: llm.selectedModel || undefined,
+ });
+ await onUpdate(taskType, { taskMetadata: { ...config.taskMetadata, musicVideoAutopilot: params } }).catch(() => {});
+ setUpdating(false);
+ };
+
+ return (
+ <form onSubmit={handleSave} className="space-y-4">
+ <p className="text-xs text-gray-500">
+ Each run turns the oldest unused Brain idea into a fully autonomous music video with these settings. Use Run Now under Global defaults to start one immediately.
+ </p>
+
+ <div>
+ <label htmlFor="mv-ap-idea-tags" className="block text-xs text-port-text-muted mb-1">Brain idea tags (optional)</label>
+ <input id="mv-ap-idea-tags" value={draft.ideaTags} onChange={(e) => patch({ ideaTags: e.target.value })} placeholder="song, music — comma separated; blank = any active idea" className={inputClass} />
+ </div>
+
+ <ToggleChip id="mv-ap-instrumental" label="Instrumental (no vocals)" checked={draft.instrumental} onToggle={() => patch({ instrumental: !draft.instrumental })} />
+
+ <ToolPicker idPrefix="mv-ap" tools={draft.tools} models={draft.models} onChange={patch} />
+
+ <MoodBoardPicker id="mv-ap-mood-board" value={draft.moodBoardId} onChange={(moodBoardId) => patch({ moodBoardId })} />
+
+ <div>
+ <label htmlFor="mv-ap-guidance" className="block text-xs text-port-text-muted mb-1">Guidance (optional)</label>
+ <textarea id="mv-ap-guidance" rows={2} maxLength={4000} value={draft.guidance} onChange={(e) => patch({ guidance: e.target.value })} className={inputClass} />
+ </div>
+
+ <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,12rem),16rem))] gap-3">
+ <div>
+ <label htmlFor="mv-ap-budget" className="block text-xs text-port-text-muted mb-1">Budget cap (USD)</label>
+ <input id="mv-ap-budget" type="number" min="0" step="1" value={draft.budget} onChange={(e) => patch({ budget: e.target.value })} placeholder="No cap" className={inputClass} />
+ </div>
+ <div>
+ <label htmlFor="mv-ap-generations" className="block text-xs text-port-text-muted mb-1">Max generations</label>
+ <input id="mv-ap-generations" type="number" min="1" max="500" step="1" value={draft.maxGenerations} onChange={(e) => patch({ maxGenerations: e.target.value })} className={inputClass} />
+ </div>
+ </div>
+
+ <fieldset className="min-w-0" aria-labelledby="mv-ap-checkpoints-label">
+ <span id="mv-ap-checkpoints-label" className="block text-xs text-port-text-muted mb-1">Pause for my approval after (optional)</span>
+ <div className="flex flex-wrap gap-1.5">
+ {AUTONOMOUS_CHECKPOINT_IDS.map((id) => (
+ <ToggleChip key={id} id={`mv-ap-checkpoint-${id}`} label={AUTONOMOUS_CHECKPOINT_LABELS[id]} checked={draft.checkpoints.includes(id)} onToggle={() => toggleCheckpoint(id)} />
+ ))}
+ </div>
+ </fieldset>
+
+ {llm.providers.length > 0 && (
+ <ProviderModelSelector
+ providers={llm.providers}
+ selectedProviderId={llm.selectedProviderId}
+ selectedModel={llm.selectedModel}
+ availableModels={llm.availableModels}
+ onProviderChange={llm.setSelectedProviderId}
+ onModelChange={llm.setSelectedModel}
+ label="Writes the brief and lyrics"
+ disabled={updating}
+ modelDisabled={llm.availableModels.length === 0}
+ compact
+ />
+ )}
+
+ <button type="submit" disabled={updating} className="w-full bg-port-accent text-white rounded px-2 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50">
+ {updating ? 'Saving…' : 'Save settings'}
+ </button>
+ </form>
+ );
+}
diff --git a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx
new file mode 100644
index 0000000000..730b025d20
--- /dev/null
+++ b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx
@@ -0,0 +1,45 @@
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react';
+
+vi.mock('../../../../services/apiMoodBoard.js', () => ({
+ listMoodBoardNames: vi.fn(async () => [{ id: 'mb-1', name: 'Neon Rain' }]),
+}));
+vi.mock('../../../../hooks/useProviderModels', () => ({
+ default: () => ({
+ providers: [], selectedProviderId: '', selectedModel: '', availableModels: [],
+ setSelectedProviderId: () => {}, setSelectedModel: () => {},
+ }),
+}));
+
+import MusicVideoAutopilotSettings from './MusicVideoAutopilotSettings';
+
+afterEach(cleanup);
+
+describe('MusicVideoAutopilotSettings', () => {
+ it('loads the saved params, saves edits into taskMetadata.musicVideoAutopilot, and keeps unedited fields', async () => {
+ const onUpdate = vi.fn(async () => {});
+ const setUpdating = vi.fn();
+ const config = {
+ taskMetadata: {
+ musicVideoAutopilot: { tools: ['image:local'], budgetUsd: 3, ideaTags: ['song'], limits: { maxGenerations: 10, maxReviewAttempts: 5 }, moodBoardId: 'mb-1' },
+ },
+ };
+ render(<MusicVideoAutopilotSettings taskType="music-video-autopilot" config={config} onUpdate={onUpdate} updating={false} setUpdating={setUpdating} />);
+
+ expect(screen.getByLabelText('Budget cap (USD)').value).toBe('3');
+ expect(screen.getByLabelText('Brain idea tags (optional)').value).toBe('song');
+ await waitFor(() => expect(screen.getByLabelText('Mood board').value).toBe('mb-1'));
+
+ fireEvent.change(screen.getByLabelText('Budget cap (USD)'), { target: { value: '8' } });
+ fireEvent.click(screen.getByLabelText('Instrumental (no vocals)'));
+ fireEvent.click(screen.getByText('Save settings'));
+
+ await waitFor(() => expect(onUpdate).toHaveBeenCalledTimes(1));
+ const [type, payload] = onUpdate.mock.calls[0];
+ expect(type).toBe('music-video-autopilot');
+ expect(payload.taskMetadata.musicVideoAutopilot).toMatchObject({
+ tools: ['image:local'], budgetUsd: 8, instrumental: true, ideaTags: ['song'], moodBoardId: 'mb-1',
+ limits: { maxGenerations: 10, maxReviewAttempts: 5 },
+ });
+ });
+});
diff --git a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
index f3e7040a59..638b1af15c 100644
--- a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
+++ b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
@@ -6,6 +6,7 @@ import { pipelineStages } from './scheduleConstants';
import PipelineStageConfig from './PipelineStageConfig';
import GlobalConfigControls from './GlobalConfigControls';
import PerAppOverrideList from './PerAppOverrideList';
+import MusicVideoAutopilotSettings from './MusicVideoAutopilotSettings';
// Slide-over panel holding the full configuration for a single task.
// Receives the live config object so it re-renders against the freshest
@@ -15,6 +16,8 @@ import PerAppOverrideList from './PerAppOverrideList';
// single section runs off the bottom of the drawer:
// - Stage config — per-stage provider/model (only when the task has a
// pipeline; count = number of stages)
+// - Video settings — the music-video-autopilot task's run settings
+// (only for that task type)
// - Global defaults — schedule/provider/prompt controls (always present)
// - Per-app options — turns the task on/off per app, plus that app's
// optional per-app settings (only when there are
@@ -48,13 +51,15 @@ export default function TaskConfigDrawer({
// Tabs are dynamic: a task without a pipeline hides Stage config, and an
// install with no active apps hides Per-app options — never an empty tab.
+ const hasVideoSettings = taskType === 'music-video-autopilot';
const tabs = [
+ hasVideoSettings && { id: 'video', label: 'Video settings' },
hasStages && { id: 'stages', label: 'Stage config', count: stages.length },
{ id: 'global', label: 'Global defaults' },
hasOverrides && { id: 'overrides', label: 'Per-app options', count: activeApps.length },
].filter(Boolean);
const tabIds = tabs.map(t => t.id);
- const defaultTab = hasStages ? 'stages' : 'global';
+ const defaultTab = hasVideoSettings ? 'video' : hasStages ? 'stages' : 'global';
const [activeTab, setActiveTab] = useDrawerTab('taskTab', defaultTab, tabIds);
return (
@@ -85,6 +90,17 @@ export default function TaskConfigDrawer({
/>
)}
+ {activeTab === 'video' && hasVideoSettings && (
+ <MusicVideoAutopilotSettings
+ key={taskType}
+ taskType={taskType}
+ config={config}
+ onUpdate={onUpdate}
+ updating={updating}
+ setUpdating={setUpdating}
+ />
+ )}
+
{activeTab === 'global' && (
<GlobalConfigControls
key={taskType}
diff --git a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.test.jsx b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.test.jsx
index a8a9e09608..13767c117a 100644
--- a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.test.jsx
+++ b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.test.jsx
@@ -20,6 +20,10 @@ vi.mock('./PerAppOverrideList', () => ({
default: ({ taskType }) => <div data-testid="override-list">overrides:{taskType}</div>,
}));
+vi.mock('./MusicVideoAutopilotSettings', () => ({
+ default: ({ taskType }) => <div data-testid="video-settings">video:{taskType}</div>,
+}));
+
import TaskConfigDrawer from './TaskConfigDrawer';
const STAGED_CONFIG = {
@@ -111,6 +115,14 @@ describe('TaskConfigDrawer tabbed layout', () => {
expect(screen.queryByRole('tab', { name: /Per-app options/ })).not.toBeInTheDocument();
});
+ it('shows the Video settings tab (default) only for the music-video-autopilot task', () => {
+ renderDrawer({ taskType: 'music-video-autopilot', config: { type: 'on-demand' } });
+ expect(screen.getByTestId('video-settings')).toBeInTheDocument();
+ cleanup();
+ renderDrawer();
+ expect(screen.queryByRole('tab', { name: /Video settings/ })).not.toBeInTheDocument();
+ });
+
it('renders nothing when config is not yet loaded', () => {
const { container } = renderDrawer({ config: null });
expect(container.querySelector('[role="dialog"]')).toBeNull();
diff --git a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
index a9d6ebcd19..138dd85310 100644
--- a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
+++ b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx
@@ -20,6 +20,7 @@ vi.mock('../../services/apiMusicVideo.js', () => ({
stopAutonomousMusicVideo: vi.fn(),
cancelAutonomousMusicVideo: vi.fn(),
}));
+vi.mock('../../services/apiMoodBoard.js', () => ({ listMoodBoardNames: vi.fn(async () => [{ id: 'mb-1', name: 'Neon Rain' }]) }));
vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), info: vi.fn(), error: vi.fn() } }));
vi.mock('../../hooks/useProviderModels.js', () => ({
default: () => ({
@@ -131,10 +132,12 @@ describe('AutonomousStartDrawer', () => {
fireEvent.click(screen.getByLabelText('Lyrics', { selector: '#mv-auto-checkpoint-lyrics' }));
fireEvent.change(screen.getByLabelText(/local image gen model/i), { target: { value: 'flux2-dev' } });
fireEvent.change(screen.getByLabelText(/budget cap/i), { target: { value: '12' } });
+ await waitFor(() => expect(screen.getByRole('option', { name: 'Neon Rain' })).toBeTruthy());
+ fireEvent.change(screen.getByLabelText('Mood board'), { target: { value: 'mb-1' } });
fireEvent.click(screen.getByRole('button', { name: /start autonomous video/i }));
await waitFor(() => expect(api.startAutonomousMusicVideo).toHaveBeenCalled());
expect(api.startAutonomousMusicVideo.mock.calls[0][0]).toMatchObject({
- checkpoints: ['lyrics'], models: { 'image:local': 'flux2-dev' }, budgetUsd: 12,
+ checkpoints: ['lyrics'], models: { 'image:local': 'flux2-dev' }, budgetUsd: 12, moodBoardId: 'mb-1',
});
});
});
diff --git a/client/src/components/musicVideo/AutonomousStartDrawer.jsx b/client/src/components/musicVideo/AutonomousStartDrawer.jsx
index a069aecfe8..82cfa98696 100644
--- a/client/src/components/musicVideo/AutonomousStartDrawer.jsx
+++ b/client/src/components/musicVideo/AutonomousStartDrawer.jsx
@@ -2,16 +2,16 @@ import { useState } from 'react';
import { Wand2 } from 'lucide-react';
import Drawer from '../Drawer.jsx';
import ToggleChip from '../ui/ToggleChip.jsx';
+import ToolPicker from './ToolPicker.jsx';
+import MoodBoardPicker from './MoodBoardPicker.jsx';
import ProviderModelSelector from '../ProviderModelSelector.jsx';
import toast from '../ui/Toast';
import useProviderModels from '../../hooks/useProviderModels.js';
import { startAutonomousMusicVideo } from '../../services/apiMusicVideo.js';
-import { MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOL_IDS } from '../../lib/musicVideoAutomation.js';
import {
- AUTONOMOUS_CHECKPOINT_IDS, AUTONOMOUS_CHECKPOINT_LABELS, autonomousMedium, autonomousRequestFromDraft, emptyAutonomousDraft,
+ AUTONOMOUS_CHECKPOINT_IDS, AUTONOMOUS_CHECKPOINT_LABELS, autonomousRequestFromDraft, emptyAutonomousDraft,
} from '../../lib/musicVideoAutonomous.js';
-const GROUPS = [['image', 'Image'], ['video', 'Video'], ['code', 'Code']];
const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm';
/**
@@ -25,15 +25,9 @@ export default function AutonomousStartDrawer({ open, onClose, onStarted }) {
const [submitting, setSubmitting] = useState(false);
const llm = useProviderModels({ allowDefault: true, silent: true });
const patch = (next) => setDraft((d) => ({ ...d, ...next }));
- const picked = new Set(draft.tools);
- const medium = autonomousMedium(draft.tools);
- const toggleTool = (id) => patch({
- tools: MUSIC_VIDEO_AUTOMATION_TOOL_IDS.filter((t) => (t === id ? !picked.has(t) : picked.has(t))),
- });
const toggleCheckpoint = (id) => patch({
checkpoints: AUTONOMOUS_CHECKPOINT_IDS.filter((c) => (c === id ? !draft.checkpoints.includes(c) : draft.checkpoints.includes(c))),
});
- const modelTools = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group !== 'code' && picked.has(t.id));
const valid = draft.prompt.trim().length > 0;
const handleSubmit = (e) => {
@@ -82,51 +76,9 @@ export default function AutonomousStartDrawer({ open, onClose, onStarted }) {
<ToggleChip id="mv-auto-instrumental" label="Instrumental (no vocals)" checked={draft.instrumental} onToggle={() => patch({ instrumental: !draft.instrumental })} />
- <fieldset className="min-w-0" aria-labelledby="mv-auto-tools-label">
- <span id="mv-auto-tools-label" className="block text-xs text-port-text-muted mb-1">How the video is made</span>
- <div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
- {GROUPS.map(([group, label]) => (
- <div key={group} className="border border-port-border rounded p-2 min-w-0">
- <div className="text-[11px] uppercase tracking-wide text-port-text-muted mb-1">{label}</div>
- <div className="flex flex-wrap gap-1.5">
- {MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group === group).map((tool) => (
- <ToggleChip
- key={tool.id}
- id={`mv-auto-tool-${tool.id}`}
- label={tool.metered ? `${tool.label} $` : tool.label}
- hint={tool.metered ? 'Spends money or remote quota' : undefined}
- checked={picked.has(tool.id)}
- onToggle={() => toggleTool(tool.id)}
- />
- ))}
- </div>
- </div>
- ))}
- </div>
- <p className="text-[11px] text-port-text-muted mt-1">
- {medium === 'code'
- ? 'Only “Render with code” is picked: the video is drawn by code — no images or footage are generated.'
- : 'Image and video tools drive the production run; it stops at the generation limit and the budget.'}
- </p>
- </fieldset>
+ <ToolPicker tools={draft.tools} models={draft.models} onChange={patch} />
- {modelTools.length > 0 && (
- <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3">
- {modelTools.map((tool) => (
- <div key={tool.id} className="min-w-0">
- <label htmlFor={`mv-auto-model-${tool.id}`} className="block text-xs text-port-text-muted mb-1">{tool.label} model (optional)</label>
- <input
- id={`mv-auto-model-${tool.id}`}
- value={draft.models[tool.id] || ''}
- onChange={(e) => patch({ models: { ...draft.models, [tool.id]: e.target.value } })}
- placeholder="Install default"
- maxLength={200}
- className={inputClass}
- />
- </div>
- ))}
- </div>
- )}
+ <MoodBoardPicker id="mv-auto-mood-board" value={draft.moodBoardId} onChange={(moodBoardId) => patch({ moodBoardId })} />
<div>
<label htmlFor="mv-auto-guidance" className="block text-xs text-port-text-muted mb-1">Guidance (optional)</label>
diff --git a/client/src/components/musicVideo/MoodBoardPicker.jsx b/client/src/components/musicVideo/MoodBoardPicker.jsx
new file mode 100644
index 0000000000..5e7c440359
--- /dev/null
+++ b/client/src/components/musicVideo/MoodBoardPicker.jsx
@@ -0,0 +1,36 @@
+import { useEffect, useState } from 'react';
+import { listMoodBoardNames } from '../../services/apiMoodBoard.js';
+
+/**
+ * Pick an existing mood board for an autonomous run to reuse, or leave it on
+ * "Generate from the prompt". A saved id whose board no longer exists stays
+ * listed so the saved choice is never silently dropped.
+ */
+export default function MoodBoardPicker({ id, value, onChange }) {
+ const [boards, setBoards] = useState([]);
+ useEffect(() => {
+ let live = true;
+ listMoodBoardNames({ silent: true })
+ .then((rows) => { if (live) setBoards(Array.isArray(rows) ? rows : []); })
+ .catch(() => {});
+ return () => { live = false; };
+ }, []);
+ const missing = value && !boards.some((b) => b.id === value);
+
+ return (
+ <div>
+ <label htmlFor={id} className="block text-xs text-port-text-muted mb-1">Mood board</label>
+ <select
+ id={id}
+ value={value || ''}
+ onChange={(e) => onChange(e.target.value)}
+ className="w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm"
+ >
+ <option value="">Generate one from the prompt</option>
+ {missing && <option value={value}>{value} (not found)</option>}
+ {boards.map((b) => <option key={b.id} value={b.id}>{b.name}</option>)}
+ </select>
+ <p className="text-[11px] text-port-text-muted mt-1">Pick an existing board to reuse its style instead of generating a new one.</p>
+ </div>
+ );
+}
diff --git a/client/src/components/musicVideo/ToolPicker.jsx b/client/src/components/musicVideo/ToolPicker.jsx
new file mode 100644
index 0000000000..5d55f9e141
--- /dev/null
+++ b/client/src/components/musicVideo/ToolPicker.jsx
@@ -0,0 +1,72 @@
+import ToggleChip from '../ui/ToggleChip.jsx';
+import { MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOL_IDS } from '../../lib/musicVideoAutomation.js';
+import { autonomousMedium } from '../../lib/musicVideoAutonomous.js';
+
+const GROUPS = [['image', 'Image'], ['video', 'Video'], ['code', 'Code']];
+const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm';
+
+/**
+ * "How the video is made" — the render-tool chips plus a per-tool model pin for
+ * each picked image/video tool. Shared by the Autonomous start drawer and the
+ * music-video-autopilot Schedule settings, so the two cannot drift. Controlled:
+ * `tools` is the picked id list, `models` the `{ toolId: model }` pins.
+ */
+export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChange }) {
+ const picked = new Set(tools);
+ const medium = autonomousMedium(tools);
+ const toggleTool = (id) => onChange({
+ tools: MUSIC_VIDEO_AUTOMATION_TOOL_IDS.filter((t) => (t === id ? !picked.has(t) : picked.has(t))),
+ models,
+ });
+ const modelTools = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group !== 'code' && picked.has(t.id));
+
+ return (
+ <>
+ <fieldset className="min-w-0" aria-labelledby={`${idPrefix}-tools-label`}>
+ <span id={`${idPrefix}-tools-label`} className="block text-xs text-port-text-muted mb-1">How the video is made</span>
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
+ {GROUPS.map(([group, label]) => (
+ <div key={group} className="border border-port-border rounded p-2 min-w-0">
+ <div className="text-[11px] uppercase tracking-wide text-port-text-muted mb-1">{label}</div>
+ <div className="flex flex-wrap gap-1.5">
+ {MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group === group).map((tool) => (
+ <ToggleChip
+ key={tool.id}
+ id={`${idPrefix}-tool-${tool.id}`}
+ label={tool.metered ? `${tool.label} $` : tool.label}
+ hint={tool.metered ? 'Spends money or remote quota' : undefined}
+ checked={picked.has(tool.id)}
+ onToggle={() => toggleTool(tool.id)}
+ />
+ ))}
+ </div>
+ </div>
+ ))}
+ </div>
+ <p className="text-[11px] text-port-text-muted mt-1">
+ {medium === 'code'
+ ? 'Only “Render with code” is picked: the video is drawn by code — no images or footage are generated.'
+ : 'Image and video tools drive the production run; it stops at the generation limit and the budget.'}
+ </p>
+ </fieldset>
+
+ {modelTools.length > 0 && (
+ <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3">
+ {modelTools.map((tool) => (
+ <div key={tool.id} className="min-w-0">
+ <label htmlFor={`${idPrefix}-model-${tool.id}`} className="block text-xs text-port-text-muted mb-1">{tool.label} model (optional)</label>
+ <input
+ id={`${idPrefix}-model-${tool.id}`}
+ value={models[tool.id] || ''}
+ onChange={(e) => onChange({ tools, models: { ...models, [tool.id]: e.target.value } })}
+ placeholder="Install default"
+ maxLength={200}
+ className={inputClass}
+ />
+ </div>
+ ))}
+ </div>
+ )}
+ </>
+ );
+}
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index ef3a0181cf..a4037a1bbc 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -66,7 +66,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `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` (setup → cast-sets → board → produce → compose → review), `resolveStageParam(value)` for the `:stage` route param, `deriveStages(project)` (per-stage `done`/`active`/`blocked`/`todo` + `current`, the first incomplete stage; a live production run pins Produce), `deriveNextAction(project, ctx)` (the one primary action the sticky header offers — approve Cast & Sets, stop/resume production, render final, …), `projectSpend(project)` (paid generation used vs. cap) and `currentProductionRun`. Used by `components/musicVideo/MusicVideoLayout.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoUniverseRefs.js` | `pullUniverseCanonReferences(universe, existingReferences)` (#8978) maps a linked universe's characters/places/objects to visual-spec references (character/set/prop roles), skipping images already present and capping at `MUSIC_VIDEO_MAX_REFERENCES` (24, mirrors the server schema). Returns `{ next, added, skipped }`; the caller persists `next` via the ordinary visualSpec PATCH. Used by `components/musicVideo/VisualSpecPanel.jsx`. (The style snapshots are derived server-side, #9105.) |
-| `musicVideoAutonomous.js` | Fully-autonomous Music Video, client half: re-exports the server stage vocabulary (`AUTONOMOUS_STAGES`, checkpoint ids, default tools/limits, `autonomousMedium`), the status/checkpoint labels, and owns the start form's `emptyAutonomousDraft` / `autonomousRequestFromDraft` mapping plus `autonomousStageRows(run)` and `isAutonomousLive(run)` for the run panel. |
+| `musicVideoAutonomous.js` | Fully-autonomous Music Video, client half: re-exports the server stage vocabulary (`AUTONOMOUS_STAGES`, checkpoint ids, default tools/limits, `autonomousMedium`), the status/checkpoint labels, and owns the start form's `emptyAutonomousDraft` / `autonomousRequestFromDraft` mapping plus `autonomousStageRows(run)` and `isAutonomousLive(run)` for the run panel, and `autopilotDraftFromParams` / `autopilotParamsFromDraft` for the music-video-autopilot Schedule settings form. |
| `musicVideoAutomation.js` | Music Video automation brief, client half: re-exports the server tool catalog (`MUSIC_VIDEO_AUTOMATION_TOOLS` / `_TOOL_IDS`), `DEFAULT_AUTOMATION_TOOLS` (the unmetered tools), and the form mapping `automationDraftFrom(automation)` / `automationFromDraft(draft)` (empty budget = no cap). Used by the create drawer and `AutopilotPanel`. |
| `bibleLimits.js` | `BIBLE_LIMITS` re-exported from the pure leaf `server/lib/bibleLimits.js`, plus the client-only `capImageRefs` / `appendImageRefById` for the optimistic imageRefs-append paths. |
| `characterEvolution.js` | The five-stage character evolution lens as the editors consume it. Re-exports `EVOLUTION_STAGES` / `EVOLUTION_OUTCOMES` / `EVOLUTION_STAGE_LABELS` / `EVOLUTION_STAGE_TEXT_FIELDS` / `EVOLUTION_EVIDENCE_FIELDS` / `EVOLUTION_EVIDENCE_STATUSES` / `CHARACTER_EVOLUTION_LIMITS` / `evolutionEvidenceStatus` / `isDeclaredEvolution` from the pure leaf `server/lib/characterEvolution.js` (a guard in `server/lib/characterEvolution.test.js` fails if this file ever restates a vocabulary instead of re-exporting it), adds the editor descriptors `EVOLUTION_STAGE_EDITOR_FIELDS` / `EVOLUTION_OUTCOME_HINTS` (#6440), and the draft-mutation helpers `evolutionStage` / `patchEvolution` / `patchEvolutionStage` / `patchEvolutionEvidence` that keep an editor's draft collapsing to the same shape the server sanitizer produces — so a present-but-empty field is a real clear (#6441). |
diff --git a/client/src/lib/musicVideoAutonomous.js b/client/src/lib/musicVideoAutonomous.js
index 9bef829a61..179db42dca 100644
--- a/client/src/lib/musicVideoAutonomous.js
+++ b/client/src/lib/musicVideoAutonomous.js
@@ -27,6 +27,7 @@ export const emptyAutonomousDraft = () => ({
budget: '',
maxGenerations: String(AUTONOMOUS_DEFAULT_LIMITS.maxGenerations),
checkpoints: [],
+ moodBoardId: '',
});
const optionalInt = (raw) => {
@@ -50,6 +51,7 @@ export function autonomousRequestFromDraft(draft, { providerId, model } = {}) {
budgetUsd: Number.isFinite(budget) && budget >= 0 ? budget : null,
...(maxGenerations ? { limits: { maxGenerations } } : {}),
checkpoints: draft.checkpoints,
+ ...(draft.moodBoardId ? { moodBoardId: draft.moodBoardId } : {}),
...(providerId ? { providerId, ...(model ? { model } : {}) } : {}),
};
}
@@ -66,3 +68,40 @@ export function autonomousStageRows(run) {
/** True while the run can still move (or be nudged): the project page keeps its panel prominent. */
export const isAutonomousLive = (run) => !!run && AUTONOMOUS_LIVE_STATUSES.includes(run.status);
+
+/** The Schedule-card form's draft for a saved `taskMetadata.musicVideoAutopilot` (the prompt comes from a Brain idea, so there is none). */
+export function autopilotDraftFromParams(params) {
+ const p = params && typeof params === 'object' ? params : {};
+ const { prompt: _prompt, ...base } = emptyAutonomousDraft();
+ return {
+ ...base,
+ instrumental: p.instrumental === true,
+ tools: Array.isArray(p.tools) ? [...p.tools] : base.tools,
+ models: { ...(p.models || {}) },
+ guidance: p.guidance || '',
+ budget: p.budgetUsd != null ? String(p.budgetUsd) : '',
+ maxGenerations: String(p.limits?.maxGenerations ?? AUTONOMOUS_DEFAULT_LIMITS.maxGenerations),
+ checkpoints: Array.isArray(p.checkpoints) ? [...p.checkpoints] : [],
+ moodBoardId: p.moodBoardId || '',
+ ideaTags: (p.ideaTags || []).join(', '),
+ };
+}
+
+/**
+ * The `musicVideoAutopilot` params a draft saves. Starts from the saved params
+ * so fields the form does not edit (review attempts, authoring provider, song
+ * source) survive a save; the server re-normalizes it all on write.
+ */
+export function autopilotParamsFromDraft(draft, saved, { providerId, model } = {}) {
+ const { prompt: _prompt, ...request } = autonomousRequestFromDraft({ ...draft, prompt: '' }, {});
+ const { llm: _llm, ...kept } = saved && typeof saved === 'object' ? saved : {};
+ return {
+ ...kept,
+ ...request,
+ models: request.models || {},
+ limits: { ...(kept.limits || {}), ...(request.limits || {}) },
+ moodBoardId: draft.moodBoardId || null,
+ ideaTags: String(draft.ideaTags || '').split(',').map((t) => t.trim()).filter(Boolean),
+ ...(providerId ? { llm: { providerId, model: model || null } } : {}),
+ };
+}
diff --git a/server/lib/musicVideoAutonomous.js b/server/lib/musicVideoAutonomous.js
index 708242a862..9695cafb98 100644
--- a/server/lib/musicVideoAutonomous.js
+++ b/server/lib/musicVideoAutonomous.js
@@ -121,6 +121,8 @@ function normalizeAutonomousSettings(raw = {}) {
maxReviewAttempts: int(raw.limits?.maxReviewAttempts, AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts, AUTONOMOUS_DEFAULT_LIMITS.maxReviewAttempts),
},
checkpoints,
+ // An existing mood board to reuse instead of generating one (blank = generate).
+ moodBoardId: clean(raw.moodBoardId, 64) || null,
llm: llmProvider ? { providerId: llmProvider, model: llmModel || null } : null,
authoring: authoringProvider && authoringModel ? { providerId: authoringProvider, model: authoringModel } : null,
};
diff --git a/server/lib/musicVideoAutonomous.test.js b/server/lib/musicVideoAutonomous.test.js
index 1ad5d8ca5b..240987690c 100644
--- a/server/lib/musicVideoAutonomous.test.js
+++ b/server/lib/musicVideoAutonomous.test.js
@@ -112,5 +112,8 @@ describe('scheduled-task params', () => {
expect(saved.musicVideoAutopilot).toMatchObject({ tools: ['image:local'], ideaTags: ['Song', 'song'], budgetUsd: 3 });
expect(saved.musicVideoAutopilot).toEqual(normalizeAutopilotParams(saved.musicVideoAutopilot));
expect(sanitizeTaskMetadata({ musicVideoAutopilot: 'nope' })).toBeNull();
+ // The existing-mood-board pick round-trips; blank collapses to "generate one".
+ expect(sanitizeTaskMetadata({ musicVideoAutopilot: { moodBoardId: ' mb-1 ' } }).musicVideoAutopilot.moodBoardId).toBe('mb-1');
+ expect(sanitizeTaskMetadata({ musicVideoAutopilot: { moodBoardId: ' ' } }).musicVideoAutopilot.moodBoardId).toBeNull();
});
});
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 29d29f887b..6136a4668f 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -749,6 +749,8 @@ export const musicVideoAutonomousStartSchema = z.object({
maxReviewAttempts: z.number().int().min(AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts.min).max(AUTONOMOUS_LIMIT_BOUNDS.maxReviewAttempts.max).optional(),
}).strict().optional(),
checkpoints: z.array(z.enum(AUTONOMOUS_CHECKPOINT_IDS)).max(AUTONOMOUS_CHECKPOINT_IDS.length).optional(),
+ // Reuse this existing mood board instead of generating one from the prompt.
+ moodBoardId: z.string().trim().min(1).max(64).nullable().optional(),
// The LLM that writes the brief and lyrics (blank = the install's active provider).
providerId: z.string().trim().min(1).max(200).nullable().optional(),
model: z.string().trim().min(1).max(200).nullable().optional(),
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index 6e1b8cc158..4cfbba3c5b 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -138,7 +138,7 @@ const STAGES = {
async style({ project, run }) {
const board = run.output.moodBoard;
- const moodBoardId = run.output.moodBoardId || (await deps.createMoodBoard(board)).id;
+ const moodBoardId = run.brief.moodBoardId || run.output.moodBoardId || (await deps.createMoodBoard(board)).id;
// The board is also the project's linked mood board; the server derives the
// authored style snapshot from it (styleSnapshots.js).
await deps.updateProject(project.id, {
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index 210d0877ae..c10c0c6b95 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -131,6 +131,14 @@ describe('startAutonomousVideo', () => {
await vi.waitFor(() => expect(calls).toContain('production')); // let the background run finish before the next test resets the doubles
});
+ it('reuses an existing mood board instead of generating one', async () => {
+ await service.startAutonomousVideo({ prompt: 'p', moodBoardId: 'board-existing' });
+ await vi.waitFor(() => expect(calls).toContain('production'));
+ expect(calls).not.toContain('board');
+ expect(runOf().output.moodBoardId).toBe('board-existing');
+ expect(doubles.updateProject).toHaveBeenCalledWith('mv-auto', expect.objectContaining({ visualSpec: { moodBoardId: 'board-existing' } }));
+ });
+
it('rejects a blank prompt', async () => {
await expect(service.startAutonomousVideo({ prompt: ' ' })).rejects.toMatchObject({ status: 400 });
expect(calls).toEqual([]);