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

refactor(music-video): derive autopilot tool catalog from backend alphabets

[._.]/ Adam Eivy3a48ac23cb22
diff --git a/client/src/components/musicVideo/AutomationBriefFields.jsx b/client/src/components/musicVideo/AutomationBriefFields.jsx
index 342ddb4edd..1dc759335d 100644
--- a/client/src/components/musicVideo/AutomationBriefFields.jsx
+++ b/client/src/components/musicVideo/AutomationBriefFields.jsx
@@ -1,34 +1,15 @@
-import { MUSIC_VIDEO_AUTOMATION_TOOLS } from '../../../../server/lib/musicVideoAutomation.js';
+import ToggleChip from '../ui/ToggleChip.jsx';
+import { MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOL_IDS } from '../../lib/musicVideoAutomation.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';
-// Free (local) tools — the default pick for a new autopilot brief, so nothing
-// metered is spent until the director opts in.
-export const DEFAULT_AUTOMATION_TOOLS = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => !t.metered).map((t) => t.id);
-
-// Form draft ↔ wire shape. The draft keeps budget as the raw input string so
-// an empty field reads as "no cap" rather than 0.
-export const automationDraftFrom = (automation) => ({
- tools: automation?.tools ?? DEFAULT_AUTOMATION_TOOLS,
- guidance: automation?.guidance ?? '',
- budget: automation?.budgetUsd != null ? String(automation.budgetUsd) : '',
-});
-export const automationFromDraft = (draft) => {
- const budget = Number.parseFloat(draft.budget);
- return {
- tools: draft.tools,
- guidance: draft.guidance.trim(),
- budgetUsd: draft.budget.trim() && Number.isFinite(budget) && budget >= 0 ? budget : null,
- };
-};
-
/** Tool picker + guidance + budget for an automation-first music video. */
export default function AutomationBriefFields({ idPrefix, draft, onChange }) {
const picked = new Set(draft.tools);
- const allPicked = picked.size === MUSIC_VIDEO_AUTOMATION_TOOLS.length;
+ const allPicked = picked.size === MUSIC_VIDEO_AUTOMATION_TOOL_IDS.length;
const toggle = (id) => onChange({
- tools: MUSIC_VIDEO_AUTOMATION_TOOLS.map((t) => t.id).filter((t) => (t === id ? !picked.has(t) : picked.has(t))),
+ tools: MUSIC_VIDEO_AUTOMATION_TOOL_IDS.filter((t) => (t === id ? !picked.has(t) : picked.has(t))),
});
return (
<div className="space-y-3 min-w-0">
@@ -37,7 +18,7 @@ export default function AutomationBriefFields({ idPrefix, draft, onChange }) {
<span id={`${idPrefix}-tools-label`} className="text-xs text-port-text-muted">Tools the agent may use</span>
<button
type="button"
- onClick={() => onChange({ tools: allPicked ? [] : MUSIC_VIDEO_AUTOMATION_TOOLS.map((t) => t.id) })}
+ onClick={() => onChange({ tools: allPicked ? [] : [...MUSIC_VIDEO_AUTOMATION_TOOL_IDS] })}
className="text-xs text-port-accent min-h-[44px] sm:min-h-0"
>
{allPicked ? 'Clear all' : 'Select all'}
@@ -47,18 +28,18 @@ export default function AutomationBriefFields({ idPrefix, draft, onChange }) {
{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>
- {MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group === group).map((tool) => (
- <label key={tool.id} htmlFor={`${idPrefix}-tool-${tool.id}`} className="flex items-center gap-2 text-sm py-0.5 min-h-[32px] sm:min-h-0">
- <input
+ <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}`}
- type="checkbox"
+ label={tool.metered ? `${tool.label} $` : tool.label}
+ hint={tool.metered ? 'Spends money or remote quota' : undefined}
checked={picked.has(tool.id)}
- onChange={() => toggle(tool.id)}
+ onToggle={() => toggle(tool.id)}
/>
- <span className="min-w-0 break-words">{tool.label}</span>
- {tool.metered && <span className="ml-auto text-[10px] text-port-warning" title="Spends money or remote quota"><span aria-hidden="true">$</span><span className="sr-only">(metered)</span></span>}
- </label>
- ))}
+ ))}
+ </div>
</div>
))}
</div>
diff --git a/client/src/components/musicVideo/AutomationPanel.jsx b/client/src/components/musicVideo/AutomationPanel.jsx
index 19a345222e..ea14732ac2 100644
--- a/client/src/components/musicVideo/AutomationPanel.jsx
+++ b/client/src/components/musicVideo/AutomationPanel.jsx
@@ -1,93 +1,96 @@
import { useState } from 'react';
import { Bot, Play } from 'lucide-react';
-import AutomationBriefFields, { automationDraftFrom, automationFromDraft } from './AutomationBriefFields.jsx';
-import { MUSIC_VIDEO_AUTOMATION_TOOLS } from '../../../../server/lib/musicVideoAutomation.js';
+import AutomationBriefFields from './AutomationBriefFields.jsx';
+import Pill from '../ui/Pill.jsx';
+import { MUSIC_VIDEO_AUTOMATION_TOOLS, automationDraftFrom, automationFromDraft } from '../../lib/musicVideoAutomation.js';
import { formatUsd } from '../../utils/formatters.js';
const toolLabel = new Map(MUSIC_VIDEO_AUTOMATION_TOOLS.map((t) => [t.id, t.label]));
+const actionClass = 'text-sm text-port-accent min-h-[44px] sm:min-h-0 px-1';
/**
* The project's automation brief — tools, guidance, budget — shown first on
* the board, with a one-click kickoff (analyze the song, then plan every shot
- * against the brief). Edits PATCH through `onSave`.
+ * against the brief). Edits PATCH through `onSave`, which owns the error toast.
*/
export default function AutomationPanel({ project, onSave, onKickoff, kickoffBusy, kickoffBlockedReason }) {
const [draft, setDraft] = useState(null);
const [saving, setSaving] = useState(false);
const automation = project.automation || null;
- const editing = draft !== null;
const save = () => {
setSaving(true);
onSave(automationFromDraft(draft))
.then(() => setDraft(null))
- // The page owns the error toast; a failed save keeps the brief open.
+ // A failed save keeps the brief open for another try.
.catch(() => {})
.finally(() => setSaving(false));
};
+ let header = null;
+ let body;
+ if (draft) {
+ body = (
+ <fieldset disabled={saving} className="space-y-3 min-w-0">
+ <AutomationBriefFields idPrefix={`mv-auto-${project.id}`} draft={draft} onChange={(patch) => setDraft((d) => ({ ...d, ...patch }))} />
+ <div className="flex flex-wrap gap-3">
+ <button type="button" onClick={save} className="bg-port-accent text-white rounded px-3 py-2 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50">
+ {saving ? 'Saving…' : 'Save brief'}
+ </button>
+ <button type="button" onClick={() => setDraft(null)} className="text-sm min-h-[44px] sm:min-h-0">Cancel</button>
+ </div>
+ </fieldset>
+ );
+ } else if (automation) {
+ header = (
+ <>
+ <span className="text-xs text-port-text-muted">
+ {automation.tools.length} tool{automation.tools.length === 1 ? '' : 's'}
+ {' · '}
+ {automation.budgetUsd != null ? `${formatUsd(automation.budgetUsd)} cap` : 'no budget cap'}
+ </span>
+ <div className="ml-auto flex flex-wrap items-center gap-2">
+ <button type="button" onClick={() => setDraft(automationDraftFrom(automation))} className={actionClass}>Edit brief</button>
+ <button
+ type="button"
+ onClick={onKickoff}
+ disabled={kickoffBusy || !!kickoffBlockedReason}
+ title={kickoffBlockedReason || 'Analyze the song, then plan every shot against the brief'}
+ className="flex items-center gap-1 bg-port-accent text-white rounded px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50"
+ >
+ <Play size={14} /> {kickoffBusy ? 'Working…' : 'Analyze & plan'}
+ </button>
+ </div>
+ </>
+ );
+ body = (
+ <>
+ {automation.tools.length > 0 && (
+ <div className="flex flex-wrap gap-1">
+ {automation.tools.map((id) => <Pill key={id} size="xs" bordered={false}>{toolLabel.get(id) || id}</Pill>)}
+ </div>
+ )}
+ <p className="text-xs text-port-text-muted break-words line-clamp-3">
+ {automation.guidance || 'No guidance yet — the agent plans from the song, universe and board alone.'}
+ </p>
+ {kickoffBlockedReason && <p className="text-xs text-port-warning">{kickoffBlockedReason}</p>}
+ </>
+ );
+ } else {
+ header = (
+ <button type="button" onClick={() => setDraft(automationDraftFrom(null))} className={`ml-auto ${actionClass}`}>Set up autopilot</button>
+ );
+ body = <p className="text-xs text-port-text-muted">Hand this video to the agent: pick the tools it may use, give it guidance and a budget.</p>;
+ }
+
return (
<section className="bg-port-card border border-port-border rounded-lg p-3 space-y-2 min-w-0" aria-label="Autopilot">
<div className="flex flex-wrap items-center gap-2">
<Bot size={16} className="text-port-accent shrink-0" aria-hidden="true" />
<h3 className="text-sm font-medium">Autopilot</h3>
- {automation && !editing && (
- <span className="text-xs text-port-text-muted">
- {automation.tools.length} tool{automation.tools.length === 1 ? '' : 's'}
- {' · '}
- {automation.budgetUsd != null ? `${formatUsd(automation.budgetUsd)} cap` : 'no budget cap'}
- </span>
- )}
- <div className="ml-auto flex flex-wrap items-center gap-2">
- {!editing && (
- <button type="button" onClick={() => setDraft(automationDraftFrom(automation))} className="text-sm text-port-accent min-h-[44px] sm:min-h-0 px-1">
- {automation ? 'Edit brief' : 'Set up autopilot'}
- </button>
- )}
- {automation && !editing && (
- <button
- type="button"
- onClick={onKickoff}
- disabled={kickoffBusy || !!kickoffBlockedReason}
- title={kickoffBlockedReason || 'Analyze the song, then plan every shot against the brief'}
- className="flex items-center gap-1 bg-port-accent text-white rounded px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50"
- >
- <Play size={14} /> {kickoffBusy ? 'Working…' : 'Analyze & plan'}
- </button>
- )}
- </div>
+ {header}
</div>
-
- {!editing && automation && (
- <>
- {automation.tools.length > 0 && (
- <div className="flex flex-wrap gap-1">
- {automation.tools.map((id) => (
- <span key={id} className="text-[11px] px-1.5 py-0.5 rounded bg-port-border">{toolLabel.get(id) || id}</span>
- ))}
- </div>
- )}
- <p className="text-xs text-port-text-muted break-words line-clamp-3">
- {automation.guidance || 'No guidance yet — the agent plans from the song, universe and board alone.'}
- </p>
- {kickoffBlockedReason && <p className="text-xs text-port-warning">{kickoffBlockedReason}</p>}
- </>
- )}
- {!editing && !automation && (
- <p className="text-xs text-port-text-muted">Hand this video to the agent: pick the tools it may use, give it guidance and a budget.</p>
- )}
-
- {editing && (
- <fieldset disabled={saving} className="space-y-3 min-w-0">
- <AutomationBriefFields idPrefix={`mv-auto-${project.id}`} draft={draft} onChange={(patch) => setDraft((d) => ({ ...d, ...patch }))} />
- <div className="flex flex-wrap gap-3">
- <button type="button" onClick={save} className="bg-port-accent text-white rounded px-3 py-2 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50">
- {saving ? 'Saving…' : 'Save brief'}
- </button>
- <button type="button" onClick={() => setDraft(null)} className="text-sm min-h-[44px] sm:min-h-0">Cancel</button>
- </div>
- </fieldset>
- )}
+ {body}
</section>
);
}
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 6928ebe345..beba2715da 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -62,6 +62,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`, `takeProvenance`; `TAKE_SLOT` maps a take kind to its selection field. Used by `components/musicVideo/SceneTakeStrip.jsx` and `pages/MusicVideo.jsx`. |
| `musicVideoShotTiming.js` | Re-export of `server/lib/musicVideoShotTiming.js` (#8977) — shot modes, the verified source-audio lip-sync capability table, `performanceBlockedReason`, `planPerformanceWindow`, `grokCoverage`, `approximateMotionCues`, `shotSplitLimit` (when a scene offers a lyric-boundary split). Used by `hooks/useMusicVideoSceneMedia.js` and `components/musicVideo/SceneCard.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`. Also `universeStyleSnapshot(universe)` / `moodBoardStyleSnapshot(board)` — the bounded style text copied into `concept.universeStyle` / `concept.moodBoardStyle` by the creative setup panel and the automation-first create drawer. |
+| `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 `AutomationPanel`. |
| `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). |
| `characterFramework.js` | The narrative-character framework as the editors consume it. Re-exports `CHARACTER_ARC_TYPES` / `CHARACTER_FRAMEWORK_FIELDS` / `CHARACTER_FRAMEWORK_TEXT_FIELDS` / `CHARACTER_FRAMEWORK_LIMITS` / `CHARACTER_PSYCHOLOGY_LIMITS` / `CHARACTER_SLIDER_AXES` / `PSYCHOLOGY_ASSESSMENTS` / `PSYCHOLOGY_DRIVE_AXES` / `RELATIONSHIP_LINK_TYPES` from the pure leaf `server/lib/characterFramework.js`, and adds the editor descriptors `CHARACTER_FRAMEWORK_EDITOR_FIELDS` (Ghost → Wound → Lie → Need → Want, with labels/placeholders/caps), `CHARACTER_MOTIVATIONS_FIELD`, `CHARACTER_SECRETS_FIELD`, `CHARACTER_PSYCHOLOGY_EDITOR_FIELDS` / `CHARACTER_PSYCHOLOGY_NOTE_FIELD` / `CHARACTER_PSYCHOLOGY_DRIVE_HINTS` (#6414), and `CHARACTER_SLIDER_MIN` / `CHARACTER_SLIDER_MAX`. Shared by the Universe cast editor and the Writers Room bible so the two never restate the same field copy (#6417). |
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index ac2e9c0a14..a188a8ddcc 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -70,6 +70,7 @@ export * from './musicVideoLayers.js';
export * from './musicVideoTakes.js';
export * from './musicVideoShotTiming.js';
export * from './musicVideoUniverseRefs.js';
+export * from './musicVideoAutomation.js';
export * from './pipelineImageDefaults.js';
export * from './reverseOutlineGrid.js';
export * from './reviewerModels.js';
diff --git a/client/src/lib/musicVideoAutomation.js b/client/src/lib/musicVideoAutomation.js
new file mode 100644
index 0000000000..b6b9d07fed
--- /dev/null
+++ b/client/src/lib/musicVideoAutomation.js
@@ -0,0 +1,27 @@
+// Music Video automation brief — client half. Re-exports the server's tool
+// catalog (a dependency-free leaf) and owns the form draft ↔ wire mapping.
+
+import { MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOL_IDS } from '../../../server/lib/musicVideoAutomation.js';
+
+export { MUSIC_VIDEO_AUTOMATION_TOOLS, MUSIC_VIDEO_AUTOMATION_TOOL_IDS };
+
+// Free (local) tools — the default pick for a new autopilot brief, so nothing
+// metered is spent until the director opts in.
+export const DEFAULT_AUTOMATION_TOOLS = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => !t.metered).map((t) => t.id);
+
+// The draft keeps budget as the raw input string so an empty field reads as
+// "no cap" rather than 0.
+export const automationDraftFrom = (automation) => ({
+ tools: automation?.tools ?? DEFAULT_AUTOMATION_TOOLS,
+ guidance: automation?.guidance ?? '',
+ budget: automation?.budgetUsd != null ? String(automation.budgetUsd) : '',
+});
+
+export const automationFromDraft = (draft) => {
+ const budget = Number.parseFloat(draft.budget);
+ return {
+ tools: draft.tools,
+ guidance: draft.guidance.trim(),
+ budgetUsd: Number.isFinite(budget) && budget >= 0 ? budget : null,
+ };
+};
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 7b580e62bf..3c80231910 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -42,7 +42,7 @@ import { listTracks } from '../services/apiTracks.js';
import BeatTimeline from '../components/musicVideo/BeatTimeline.jsx';
import CreateProjectDrawer from '../components/musicVideo/CreateProjectDrawer.jsx';
import AutomationPanel from '../components/musicVideo/AutomationPanel.jsx';
-import { automationDraftFrom, automationFromDraft } from '../components/musicVideo/AutomationBriefFields.jsx';
+import { automationDraftFrom, automationFromDraft } from '../lib/musicVideoAutomation.js';
import { getUniverse, listUniverseNames } from '../services/apiUniverseBuilder.js';
import { getMoodBoard } from '../services/apiMoodBoard.js';
import { universeStyleSnapshot, moodBoardStyleSnapshot } from '../lib/musicVideoUniverseRefs.js';
@@ -70,6 +70,14 @@ const emptyCreateForm = () => ({
name: '', mode: 'autonomous', trackId: '', universeId: '', moodBoardId: '', automation: automationDraftFrom(null),
});
+// Why the autopilot kickoff can't run yet, or null when it can.
+function autopilotBlocker(project) {
+ if (!project) return null;
+ if (!project.trackId && !project.uploadedAudioFilename) return 'Attach a track before starting autopilot.';
+ if ((project.scenes || []).length > 0) return 'The board already has shots — edit them below or fork a new version to re-plan.';
+ return null;
+}
+
const STATUS_COLORS = {
draft: 'bg-port-border text-port-text',
analyzed: 'bg-port-accent/30 text-port-accent',
@@ -100,7 +108,6 @@ export default function MusicVideo() {
const [importingLyrics, setImportingLyrics] = useState(false);
const [createOpen, setCreateOpen] = useState(false);
const [creating, setCreating] = useState(false);
- const [kickingOff, setKickingOff] = useState(false);
const [form, setForm] = useState(emptyCreateForm);
const selected = projects.find((p) => p.id === selectedId) || null;
@@ -318,19 +325,15 @@ export default function MusicVideo() {
// Autopilot kickoff: analyze the song when it has no beat map yet, then plan
// every shot against the brief (the planner reads automation.guidance).
- const autopilotBlockedReason = !selected ? null
- : (!selected.trackId && !selected.uploadedAudioFilename) ? 'Attach a track before starting autopilot.'
- : (selected.scenes || []).length > 0 ? 'The board already has shots — edit them below or fork a new version to re-plan.'
- : null;
+ const autopilotBlockedReason = autopilotBlocker(selected);
const handleKickoff = () => {
- if (!selected || kickingOff || autopilotBlockedReason) return;
- setKickingOff(true);
+ if (!selected || analyzing || planning || autopilotBlockedReason) return;
(selected.audioAnalysis ? Promise.resolve(selected) : handleAnalyze())
- .then((proj) => (proj?.audioAnalysis ? handlePlan(proj) : null))
- .finally(() => setKickingOff(false));
+ .then((proj) => (proj?.audioAnalysis ? handlePlan(proj) : null));
};
- const saveAutomation = (automation) => updateMusicVideoProject(selected.id, { automation }, { silent: true })
- .then((proj) => patchProject(proj.id, { automation: proj.automation, updatedAt: proj.updatedAt }))
+ // Saving a brief hands the project to autopilot, so mode follows it.
+ const saveAutomation = (automation) => updateMusicVideoProject(selected.id, { automation, mode: 'autonomous' }, { silent: true })
+ .then((proj) => patchProject(proj.id, { automation: proj.automation, mode: proj.mode, updatedAt: proj.updatedAt }))
.catch((err) => { toast.error(err?.message || 'Failed to save autopilot brief'); throw err; });
// Auto-arrange (#1915): distribute every scene across the analyzed song
@@ -697,7 +700,7 @@ export default function MusicVideo() {
project={selected}
onSave={saveAutomation}
onKickoff={handleKickoff}
- kickoffBusy={kickingOff || analyzing || planning}
+ kickoffBusy={analyzing || planning}
kickoffBlockedReason={autopilotBlockedReason}
/>
<CreativeSetupPanel key={`creative-${selected.id}`} project={selected} onPendingChange={setCreativeSetupPending}
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index eda00d07b8..f3a48794dd 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -1363,7 +1363,7 @@ describe('MusicVideo YouTube audio import (#1945)', () => {
const [body] = createMusicVideoProject.mock.calls[0];
expect(body).toMatchObject({ name: 'Auto MV', mode: 'autonomous', trackId: null });
expect(body.automation).toEqual({
- tools: ['image:local', 'image:external', 'video:local', 'video:fal', 'code:render'],
+ tools: ['image:external', 'image:local', 'video:local', 'video:fal', 'code:render'],
guidance: 'one long take',
budgetUsd: 40,
});
diff --git a/server/lib/musicVideoAutomation.js b/server/lib/musicVideoAutomation.js
index 42003259ac..a94101c169 100644
--- a/server/lib/musicVideoAutomation.js
+++ b/server/lib/musicVideoAutomation.js
@@ -5,13 +5,17 @@
* A dependency-free leaf (the client's create drawer and automation panel
* import it directly, like navManifest.js) so the tool alphabet cannot drift
* between the picker and the server schema. Image/video tool ids derive from
- * the render-backend alphabets in generationModes.js, so a backend added there
- * reaches the picker in the same commit; `code:render` is the code-rendered
+ * the render-backend alphabets in generationModes.js and `metered` from its
+ * cloud (remote-quota) lists, so a backend added there reaches the picker —
+ * correctly flagged — in the same commit; `code:render` is the code-rendered
* pass (typography, composition layers, procedural frames).
*/
-import { IMAGE_GEN_MODE, VIDEO_GEN_MODE } from './generationModes.js';
+import {
+ CLOUD_IMAGE_GEN_MODES, CLOUD_VIDEO_GEN_MODES, IMAGE_GEN_MODE, IMAGE_GEN_MODES, VIDEO_GEN_MODE, VIDEO_GEN_MODES,
+} from './generationModes.js';
+// Display names only; a backend with no entry falls back to its mode id.
const IMAGE_TOOL_LABELS = {
[IMAGE_GEN_MODE.LOCAL]: 'Local image gen',
[IMAGE_GEN_MODE.CODEX]: 'Codex image gen',
@@ -19,7 +23,6 @@ const IMAGE_TOOL_LABELS = {
[IMAGE_GEN_MODE.AGY]: 'Antigravity image gen',
[IMAGE_GEN_MODE.EXTERNAL]: 'External SD API',
};
-
const VIDEO_TOOL_LABELS = {
[VIDEO_GEN_MODE.LOCAL]: 'Local video gen',
[VIDEO_GEN_MODE.GROK]: 'Grok video',
@@ -27,18 +30,17 @@ const VIDEO_TOOL_LABELS = {
[VIDEO_GEN_MODE.REACTOR]: 'Reactor video',
};
-// Metered = spends money or remote quota; the budget cap is meaningful only
-// for these. Local backends cost electricity, not dollars.
-const METERED = new Set([
- `image:${IMAGE_GEN_MODE.CODEX}`, `image:${IMAGE_GEN_MODE.GROK}`, `image:${IMAGE_GEN_MODE.AGY}`,
- `video:${VIDEO_GEN_MODE.GROK}`, `video:${VIDEO_GEN_MODE.FAL}`, `video:${VIDEO_GEN_MODE.REACTOR}`,
-]);
+// Metered = spends money or remote quota (the cloud lists); the budget cap is
+// meaningful only for these. Local backends cost electricity, not dollars.
+const toolsFor = (group, modes, labels, cloud) => modes.map((mode) => ({
+ id: `${group}:${mode}`, group, label: labels[mode] || `${mode} ${group}`, metered: cloud.includes(mode),
+}));
export const MUSIC_VIDEO_AUTOMATION_TOOLS = Object.freeze([
- ...Object.entries(IMAGE_TOOL_LABELS).map(([mode, label]) => ({ id: `image:${mode}`, group: 'image', label })),
- ...Object.entries(VIDEO_TOOL_LABELS).map(([mode, label]) => ({ id: `video:${mode}`, group: 'video', label })),
- { id: 'code:render', group: 'code', label: 'Render with code' },
-].map((tool) => Object.freeze({ ...tool, metered: METERED.has(tool.id) })));
+ ...toolsFor('image', IMAGE_GEN_MODES, IMAGE_TOOL_LABELS, CLOUD_IMAGE_GEN_MODES),
+ ...toolsFor('video', VIDEO_GEN_MODES, VIDEO_TOOL_LABELS, CLOUD_VIDEO_GEN_MODES),
+ { id: 'code:render', group: 'code', label: 'Render with code', metered: false },
+].map((tool) => Object.freeze(tool)));
export const MUSIC_VIDEO_AUTOMATION_TOOL_IDS = Object.freeze(MUSIC_VIDEO_AUTOMATION_TOOLS.map((t) => t.id));