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
fix: choose local video models from a menu on autonomous setup
[._.]/ Adam Eivy617c05accdb2
diff --git a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsxindex f0b8dc61fa..9af47bdbd1 100644--- a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx+++ b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotSettings.test.jsx@@ -4,6 +4,15 @@ import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/revi.mock('../../../../services/apiMoodBoard.js', () => ({listMoodBoardNames: vi.fn(async () => [{ id: 'mb-1', name: 'Neon Rain' }]),}));+vi.mock('../../../../services/apiImageVideo.js', () => ({+ getVideoGenModelContext: vi.fn(async () => ({+ models: [+ { id: 'example-ltx', name: 'Example LTX' },+ { id: 'example-wan', name: 'Example Wan' },+ ],+ defaultModel: 'example-ltx',+ })),+}));vi.mock('../../../../hooks/useProviderModels', () => ({default: ({ filter } = {}) => ({providers: filter ? [{ id: 'fixture-api', name: 'Fixture API', type: 'api', enabled: true, defaultModel: 'fixture-model', models: ['fixture-model'] }].filter(filter) : [],@@ -59,6 +68,24 @@ describe('MusicVideoAutopilotSettings', () => {expect(onUpdate.mock.calls[0][1].taskMetadata.musicVideoAutopilot).toMatchObject({ mediaMode: 'code-only', songSource: 'local', localFallback: false });});+ it('keeps a saved local video model in the menu, including one the catalog no longer lists', async () => {+ const onUpdate = vi.fn(async () => {});+ const config = {+ taskMetadata: { musicVideoAutopilot: { tools: ['video:local'], models: { 'video:local': 'retired-model' } } },+ };+ render(<MusicVideoAutopilotSettings taskType="music-video-autopilot" config={config} onUpdate={onUpdate} updating={false} setUpdating={() => {}} />);+ const model = screen.getByLabelText(/local video gen model/i);+ expect(model.tagName).toBe('SELECT');+ expect(await screen.findByRole('option', { name: 'Example LTX' })).toBeTruthy();+ expect(model.value).toBe('retired-model');+ expect(screen.getByRole('option', { name: 'retired-model (unavailable on this machine)' })).toBeTruthy();++ fireEvent.change(model, { target: { value: 'example-wan' } });+ fireEvent.click(screen.getByText('Save settings'));+ await waitFor(() => expect(onUpdate).toHaveBeenCalled());+ expect(onUpdate.mock.calls[0][1].taskMetadata.musicVideoAutopilot.models).toEqual({ 'video:local': 'example-wan' });+ });+it('keeps a saved writer-LLM pin when saved before the provider catalog loads', async () => {const onUpdate = vi.fn(async () => {});const config = { taskMetadata: { musicVideoAutopilot: { authoring: { providerId: 'saved-author', model: 'saved-model', effort: 'high' }, llm: { providerId: 'prov-1', model: 'm-1' } } } };diff --git a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx b/client/src/components/musicVideo/AutonomousRunPanel.test.jsxindex 46c9e57519..c25ca9b09d 100644--- a/client/src/components/musicVideo/AutonomousRunPanel.test.jsx+++ b/client/src/components/musicVideo/AutonomousRunPanel.test.jsx@@ -22,6 +22,15 @@ vi.mock('../../services/apiMusicVideo.js', () => ({cancelAutonomousMusicVideo: vi.fn(),}));vi.mock('../../services/apiMoodBoard.js', () => ({ listMoodBoardNames: vi.fn(async () => [{ id: 'mb-1', name: 'Neon Rain' }]) }));+vi.mock('../../services/apiImageVideo.js', () => ({+ getVideoGenModelContext: vi.fn(async () => ({+ models: [+ { id: 'example-ltx', name: 'Example LTX' },+ { id: 'example-wan', name: 'Example Wan' },+ ],+ defaultModel: 'example-ltx',+ })),+}));vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), info: vi.fn(), error: vi.fn() } }));vi.mock('../../hooks/useProviderModels.js', () => ({default: ({ filter } = {}) => ({@@ -38,6 +47,7 @@ import AutonomousRunPanel from './AutonomousRunPanel.jsx';import AutonomousStartDrawer from './AutonomousStartDrawer.jsx';import useAutonomousMusicVideo from '../../hooks/useAutonomousMusicVideo.js';import * as api from '../../services/apiMusicVideo.js';+import { getVideoGenModelContext } from '../../services/apiImageVideo.js';const stages = (overrides = {}) => ({brief: { status: 'done' }, lyrics: { status: 'done' }, style: { status: 'pending' }, song: { status: 'pending' },@@ -261,6 +271,38 @@ describe('AutonomousStartDrawer', () => {expect(api.startAutonomousMusicVideo.mock.calls[0][0].suno).toEqual({ excludeStyles: 'metal', vocalGender: 'female', model: 'v6' });});+ it('offers local video models in a menu and pins only the one the director picks', async () => {+ api.startAutonomousMusicVideo.mockResolvedValue({ project: { id: 'mv-new' }, run: baseRun() });+ render(<AutonomousStartDrawer open onClose={() => {}} onStarted={() => {}} />);+ const model = screen.getByLabelText(/local video gen model/i);+ expect(model.tagName).toBe('SELECT');+ expect(await screen.findByRole('option', { name: 'Install default (Example LTX)' })).toBeTruthy();+ expect(screen.getByRole('option', { name: 'Example Wan' })).toBeTruthy();+ expect(model.value).toBe('');++ fireEvent.change(model, { target: { value: 'example-wan' } });+ fireEvent.change(screen.getByLabelText('Prompt'), { target: { value: 'p' } });+ fireEvent.change(screen.getByLabelText('Code authoring provider'), { target: { value: 'fixture-api' } });+ fireEvent.click(screen.getByRole('button', { name: /start autonomous video/i }));+ await waitFor(() => expect(api.startAutonomousMusicVideo).toHaveBeenCalledTimes(1));+ expect(api.startAutonomousMusicVideo.mock.calls[0][0].models).toEqual({ 'video:local': 'example-wan' });+ });++ it('keeps the local video field a menu when the catalog cannot load or is empty', async () => {+ getVideoGenModelContext.mockRejectedValueOnce(new Error('offline'));+ const { unmount } = render(<AutonomousStartDrawer open onClose={() => {}} onStarted={() => {}} />);+ const failed = await screen.findByLabelText(/local video gen model/i);+ expect(failed.tagName).toBe('SELECT');+ expect(await screen.findByText('Could not load local video models.')).toBeTruthy();+ expect(screen.queryByRole('option', { name: 'Example Wan' })).toBeNull();+ unmount();++ getVideoGenModelContext.mockResolvedValueOnce({ models: [], defaultModel: null });+ render(<AutonomousStartDrawer open onClose={() => {}} onStarted={() => {}} />);+ expect(await screen.findByText('No local video models are compatible with this machine.')).toBeTruthy();+ expect(screen.getByRole('option', { name: 'Install default (no compatible local model)' })).toBeTruthy();+ });+it('offers the local song source, and the Suno-only fallback opt-in only while Suno is the source', async () => {api.startAutonomousMusicVideo.mockResolvedValue({ project: { id: 'mv-new' }, run: baseRun() });render(<AutonomousStartDrawer open onClose={() => {}} onStarted={() => {}} />);diff --git a/client/src/components/musicVideo/ToolPicker.jsx b/client/src/components/musicVideo/ToolPicker.jsxindex 5d55f9e141..e9b872f61c 100644--- a/client/src/components/musicVideo/ToolPicker.jsx+++ b/client/src/components/musicVideo/ToolPicker.jsx@@ -1,15 +1,74 @@+import { useEffect, useState } from 'react';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';+import { getVideoGenModelContext } from '../../services/apiImageVideo.js';const GROUPS = [['image', 'Image'], ['video', 'Video'], ['code', 'Code']];+const LOCAL_VIDEO_TOOL_ID = 'video:local';const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm';+/**+ * The local-video `<select>` while its catalog loads, after it fails, or once+ * the hardware-compatible models are in. A blank value is the install default.+ * A pin the catalog no longer lists stays selected, so a save cannot drop it.+ */+function localVideoModelSelectState({ catalog, failed, pinned }) {+ const models = Array.isArray(catalog?.models) ? catalog.models : [];+ const loading = catalog == null && !failed;+ const defaultId = typeof catalog?.defaultModel === 'string' ? catalog.defaultModel : '';+ const defaultName = models.find((model) => model.id === defaultId)?.name || defaultId;+ const blankDetail = failed+ ? ''+ : models.length === 0+ ? 'no compatible local model'+ : (defaultName || 'no compatible local model');+ const known = models.some((model) => model.id === pinned);+ const options = [+ ...(pinned && (loading || !known) ? [{ id: pinned, name: loading ? pinned : `${pinned} (unavailable on this machine)` }] : []),+ ...(loading ? [] : models.map((model) => ({ id: model.id, name: model.name || model.id }))),+ ];+ let status = '';+ if (failed) status = 'Could not load local video models.';+ else if (!loading && models.length === 0) status = 'No local video models are compatible with this machine.';+ return {+ blankLabel: loading ? 'Loading models…' : (blankDetail ? `Install default (${blankDetail})` : 'Install default'),+ options,+ status,+ disabled: loading,+ };+}++/** Probe-free video catalog, fetched only while Local video gen is picked. */+function useLocalVideoModels(enabled) {+ const [catalog, setCatalog] = useState(null);+ const [failed, setFailed] = useState(false);+ useEffect(() => {+ if (!enabled) return undefined;+ let active = true;+ setCatalog(null);+ setFailed(false);+ getVideoGenModelContext({ silent: true })+ .then((next) => {+ if (active) setCatalog(next && typeof next === 'object' ? next : { models: [] });+ })+ .catch(() => {+ if (!active) return;+ setCatalog({ models: [] });+ setFailed(true);+ });+ return () => { active = false; };+ }, [enabled]);+ return { catalog: enabled ? catalog : null, failed: enabled && failed };+}+/*** "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.+ * Local video gen chooses from the install's video-model catalog. A blank pin+ * is the install default. Other tools still take a model id.*/export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChange }) {const picked = new Set(tools);@@ -19,6 +78,8 @@ export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChanmodels,});const modelTools = MUSIC_VIDEO_AUTOMATION_TOOLS.filter((t) => t.group !== 'code' && picked.has(t.id));+ const localVideo = useLocalVideoModels(modelTools.some((tool) => tool.id === LOCAL_VIDEO_TOOL_ID));+ const setModel = (toolId, value) => onChange({ tools, models: { ...models, [toolId]: value } });return (<>@@ -52,19 +113,44 @@ export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChan{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>- ))}+ {modelTools.map((tool) => {+ const fieldId = `${idPrefix}-model-${tool.id}`;+ const value = models[tool.id] || '';+ if (tool.id !== LOCAL_VIDEO_TOOL_ID) {+ return (+ <div key={tool.id} className="min-w-0">+ <label htmlFor={fieldId} className="block text-xs text-port-text-muted mb-1">{tool.label} model (optional)</label>+ <input+ id={fieldId}+ value={value}+ onChange={(e) => setModel(tool.id, e.target.value)}+ placeholder="Install default"+ maxLength={200}+ className={inputClass}+ />+ </div>+ );+ }+ const select = localVideoModelSelectState({ catalog: localVideo.catalog, failed: localVideo.failed, pinned: value });+ const statusId = `${fieldId}-status`;+ return (+ <div key={tool.id} className="min-w-0">+ <label htmlFor={fieldId} className="block text-xs text-port-text-muted mb-1">{tool.label} model (optional)</label>+ <select+ id={fieldId}+ value={value}+ disabled={select.disabled}+ aria-describedby={select.status ? statusId : undefined}+ onChange={(e) => setModel(tool.id, e.target.value)}+ className={inputClass}+ >+ <option value="">{select.blankLabel}</option>+ {select.options.map((model) => <option key={model.id} value={model.id}>{model.name}</option>)}+ </select>+ {select.status && <p id={statusId} role="status" className="text-[11px] text-port-warning mt-1">{select.status}</p>}+ </div>+ );+ })}</div>)}</>diff --git a/server/services/musicVideo/productionPool.js b/server/services/musicVideo/productionPool.jsindex 120a507f0a..df37bb4e9a 100644--- a/server/services/musicVideo/productionPool.js+++ b/server/services/musicVideo/productionPool.js@@ -157,10 +157,13 @@ async function routeEligibility(route, env) {}if (route.mode === 'local') {if (!settings?.imageGen?.local?.pythonPath) return { ok: false, reason: 'The local video runtime is not configured in Settings' };- if (!route.model) return { ok: false, reason: 'A local video route must name its model' };- const { model } = await env.resolveVideoModel(route.model);- if (!model) return { ok: false, reason: `Local video model "${route.model}" is not installed` };- if (!isHardwareCompatible(model.hardwareCompatibility)) return { ok: false, reason: `Local video model "${route.model}" cannot run on this hardware` };+ // A blank pin is the install default. The renderer resolves that same+ // omission, so refusing it here made "Install default" fail at Start.+ const requested = typeof route.model === 'string' ? route.model.trim() : '';+ const { model, modelId } = await env.resolveVideoModel(requested);+ const label = requested || modelId || '(none)';+ if (!model) return { ok: false, reason: `Local video model "${label}" is not installed` };+ if (!isHardwareCompatible(model.hardwareCompatibility)) return { ok: false, reason: `Local video model "${label}" cannot run on this hardware` };}return { ok: true, reason: null };}diff --git a/server/services/musicVideo/productionPool.test.js b/server/services/musicVideo/productionPool.test.jsnew file mode 100644index 0000000000..550c96f8bb--- /dev/null+++ b/server/services/musicVideo/productionPool.test.js@@ -0,0 +1,29 @@+import { describe, expect, it } from 'vitest';+import { assertPoolEligible } from './productionPool.js';++// Blank local-video pins are the install default. The renderer already resolves+// that omission; Start must accept the same route instead of demanding an id.+const envFor = (resolveVideoModel) => ({+ settings: { imageGen: { local: { pythonPath: '/opt/example/python' } } },+ imageModels: [],+ isVideoModeUsable: () => true,+ resolveVideoModel,+});++describe('local video pool eligibility', () => {+ it('accepts a blank model pin when the install default resolves', async () => {+ const resolveVideoModel = async (id) => (+ id ? { model: null, modelId: id } : { model: { id: 'example-default' }, modelId: 'example-default' }+ );+ await expect(assertPoolEligible([{ kind: 'video', mode: 'local' }], envFor(resolveVideoModel))).resolves.toBeUndefined();+ });++ it('refuses an install default this machine cannot run', async () => {+ const resolveVideoModel = async () => ({+ model: { id: 'example-default', hardwareCompatibility: { state: 'unavailable', reasons: ['needs a GPU'] } },+ modelId: 'example-default',+ });+ await expect(assertPoolEligible([{ kind: 'video', mode: 'local' }], envFor(resolveVideoModel)))+ .rejects.toThrow(/example-default.*cannot run on this hardware/);+ });+});