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: select local image models and resolve install defaults (#9913)
Adam Eivy096cb88efcab
diff --git a/client/src/components/musicVideo/ToolPicker.jsx b/client/src/components/musicVideo/ToolPicker.jsxindex e9b872f61c..7421313ef5 100644--- a/client/src/components/musicVideo/ToolPicker.jsx+++ b/client/src/components/musicVideo/ToolPicker.jsx@@ -1,4 +1,5 @@import { useEffect, useState } from 'react';+import useLocalImageModels from '../../hooks/useLocalImageModels.js';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';@@ -13,7 +14,7 @@ const inputClass = 'w-full min-w-0 bg-port-bg border border-port-border rounded* 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 }) {+function localModelSelectState({ catalog, failed, pinned, kind }) {const models = Array.isArray(catalog?.models) ? catalog.models : [];const loading = catalog == null && !failed;const defaultId = typeof catalog?.defaultModel === 'string' ? catalog.defaultModel : '';@@ -29,8 +30,8 @@ function localVideoModelSelectState({ catalog, failed, pinned }) {...(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.';+ if (failed) status = `Could not load local ${kind} models.`;+ else if (!loading && models.length === 0) status = `No local ${kind} models are compatible with this machine.`;return {blankLabel: loading ? 'Loading models…' : (blankDetail ? `Install default (${blankDetail})` : 'Install default'),options,@@ -78,6 +79,7 @@ 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 localImage = useLocalImageModels(picked.has('image:local'));const localVideo = useLocalVideoModels(modelTools.some((tool) => tool.id === LOCAL_VIDEO_TOOL_ID));const setModel = (toolId, value) => onChange({ tools, models: { ...models, [toolId]: value } });@@ -116,7 +118,7 @@ export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChan{modelTools.map((tool) => {const fieldId = `${idPrefix}-model-${tool.id}`;const value = models[tool.id] || '';- if (tool.id !== LOCAL_VIDEO_TOOL_ID) {+ if (tool.id !== LOCAL_VIDEO_TOOL_ID && tool.id !== 'image:local') {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>@@ -131,7 +133,11 @@ export default function ToolPicker({ idPrefix = 'mv-auto', tools, models, onChan</div>);}- const select = localVideoModelSelectState({ catalog: localVideo.catalog, failed: localVideo.failed, pinned: value });+ const image = tool.id === 'image:local';+ const select = localModelSelectState({+ catalog: image ? (localImage.models === null ? null : { models: localImage.models, defaultModel: localImage.installDefault }) : localVideo.catalog,+ failed: image ? localImage.failed : localVideo.failed, pinned: value, kind: image ? 'image' : 'video',+ });const statusId = `${fieldId}-status`;return (<div key={tool.id} className="min-w-0">diff --git a/client/src/components/musicVideo/ToolPicker.test.jsx b/client/src/components/musicVideo/ToolPicker.test.jsxnew file mode 100644index 0000000000..b70a31fc2a--- /dev/null+++ b/client/src/components/musicVideo/ToolPicker.test.jsx@@ -0,0 +1,33 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, fireEvent, cleanup } from '@testing-library/react';+import ToolPicker from './ToolPicker.jsx';+const image = vi.hoisted(() => ({ models: [], installDefault: null, failed: false }));+vi.mock('../../hooks/useLocalImageModels.js', () => ({ default: () => image }));+vi.mock('../../services/apiImageVideo.js', () => ({ getVideoGenModelContext: vi.fn() }));+beforeEach(() => { cleanup(); Object.assign(image, { models: [], installDefault: null, failed: false }); });+const show = (models = {}) => {+ const onChange = vi.fn();+ render(<ToolPicker tools={['image:local', 'image:fal']} models={models} onChange={onChange} />);+ return onChange;+};+describe('local image tool models', () => {+ it('selects listed models and keeps the blank install-default choice without converting cloud inputs', () => {+ Object.assign(image, { models: [{ id: 'example-image', name: 'Example image' }], installDefault: 'example-image' });+ const onChange = show();+ const select = screen.getByRole('combobox');+ expect(screen.getByRole('option', { name: 'Install default (Example image)' })).toBeTruthy();+ expect(screen.getByRole('textbox')).toBeTruthy();+ fireEvent.change(select, { target: { value: 'example-image' } });+ expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ models: { 'image:local': 'example-image' } }));+ fireEvent.change(select, { target: { value: '' } });+ expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ models: { 'image:local': '' } }));+ });+ it.each([false, true])('preserves unknown pins with an empty or failed catalog (%s)', (failed) => {+ image.failed = failed;+ show({ 'image:local': 'missing-image' });+ expect(screen.getByRole('combobox').value).toBe('missing-image');+ expect(screen.getByRole('option', { name: 'missing-image (unavailable on this machine)' })).toBeTruthy();+ expect(screen.getByRole('status').textContent).toMatch(failed ? /Could not load/ : /No local image models/);+ expect(screen.getByRole('combobox').disabled).toBe(false);+ });+});diff --git a/client/src/hooks/useLocalImageModels.js b/client/src/hooks/useLocalImageModels.jsindex 3213693590..791c2bfee6 100644--- a/client/src/hooks/useLocalImageModels.js+++ b/client/src/hooks/useLocalImageModels.js@@ -26,18 +26,21 @@ import { installLocalModelId } from '../lib/imageGenBackends';export default function useLocalImageModels(enabled) {const [models, setModels] = useState(null);const [installDefault, setInstallDefault] = useState(null);+ const [failed, setFailed] = useState(false);useEffect(() => {if (!enabled) return undefined;let alive = true;+ setModels(null);+ setFailed(false);listImageModels({ silent: true }).then((list) => { if (alive) setModels(Array.isArray(list) ? list : []); })- .catch(() => { if (alive) setModels([]); });+ .catch(() => { if (alive) { setModels([]); setFailed(true); } });getSettings({ silent: true }).then((s) => { if (alive) setInstallDefault(installLocalModelId(s)); }).catch(() => { if (alive) setInstallDefault(installLocalModelId(null)); });return () => { alive = false; };}, [enabled]);- return { models, installDefault };+ return { models, installDefault, failed };}diff --git a/server/services/musicVideo/productionPool.js b/server/services/musicVideo/productionPool.jsindex df37bb4e9a..488b32b3cf 100644--- a/server/services/musicVideo/productionPool.js+++ b/server/services/musicVideo/productionPool.js@@ -24,6 +24,7 @@* routes cost $0.*/+import { selectLocalImageModelFromSettings } from '../imageGen/prepareParams.js';import { ServerError } from '../../lib/errorHandler.js';import { FAL_IMAGE_FAMILIES, buildFalImageRequest, falImageFamily } from '../../lib/falImageModels.js';import { resolveFalApiKey } from '../falQueue.js';@@ -36,6 +37,10 @@ import { isHardwareCompatible } from '../../lib/systemCapabilities.js';import { RUNNER_FAMILIES } from '../../lib/runners.js';import { poolHasRoute, routeKey } from './production.js';+const localImageModel = (route, env) => route.model+ ? (env.imageModels || []).find((model) => model.id === route.model)+ : selectLocalImageModelFromSettings(env.settings, '', env.imageModels || []);+const describe = (route) => `${route.kind} ${route.mode}${route.model ? ` (${route.model})` : ''}`;const isMetered = (route) => MUSIC_VIDEO_AUTOMATION_TOOLS.some((t) => t.id === `${route.kind}:${route.mode}` && t.metered);@@ -134,9 +139,9 @@ async function routeEligibility(route, env) {}if (route.mode === 'local') {if (!settings?.imageGen?.local?.pythonPath) return { ok: false, reason: 'The local image runtime is not configured in Settings' };- const model = (env.imageModels || []).find((m) => m.id === route.model);- if (!route.model || !model) return { ok: false, reason: `Local image model "${route.model || '(none)'}" is not installed` };- if (!isHardwareCompatible(model.hardwareCompatibility)) return { ok: false, reason: `Local image model "${route.model}" cannot run on this hardware` };+ const model = localImageModel(route, env);+ if (!model) return { ok: false, reason: `Local image model "${route.model || '(none)'}" is not installed` };+ if (!isHardwareCompatible(model.hardwareCompatibility)) return { ok: false, reason: `Local image model "${model.id}" cannot run on this hardware` };return { ok: true, reason: null };}if (settings?.imageGen?.[route.mode]?.enabled !== true) {@@ -177,9 +182,9 @@ function routeIncapableReason(route, requirement, env) {return `${describe(route)} takes at most ${limit} reference image${limit === 1 ? '' : 's'}; the visual spec conditions on ${requirement.conditioning}`;}if (route.mode === 'local') {- const model = (env.imageModels || []).find((m) => m.id === route.model);+ const model = localImageModel(route, env);if (model?.runner !== RUNNER_FAMILIES.FLUX2 && model?.pipelineClass !== 'QwenImage21Pipeline') {- return `Local model "${route.model}" cannot use reference images (FLUX.2 and Qwen Image 2.1 only)`;+ return `Local model "${model?.id || route.model || '(none)'}" cannot use reference images (FLUX.2 and Qwen Image 2.1 only)`;}}}diff --git a/server/services/musicVideo/productionPool.test.js b/server/services/musicVideo/productionPool.test.jsindex 550c96f8bb..b24382e064 100644--- a/server/services/musicVideo/productionPool.test.js+++ b/server/services/musicVideo/productionPool.test.js@@ -27,3 +27,28 @@ describe('local video pool eligibility', () => {.rejects.toThrow(/example-default.*cannot run on this hardware/);});});++describe('local image pool eligibility', () => {+ const route = { kind: 'image', mode: 'local' };+ const imageEnv = (models, pin) => ({+ ...envFor(() => {}), imageModels: models,+ settings: { imageGen: { local: { pythonPath: '/opt/example/python', modelId: pin } } },+ });+ it('resolves a blank pin and checks reference conditioning against the same installed model', async () => {+ const env = imageEnv([{ id: 'example-image', pipelineClass: 'QwenImage21Pipeline' }], 'example-image');+ await expect(assertPoolEligible([route], env)).resolves.toBeUndefined();+ const { chooseProductionRoute } = await import('./productionPool.js');+ await expect(chooseProductionRoute({ pool: [route] }, { kind: 'image', conditioning: 1 }, env))+ .resolves.toMatchObject({ route });+ env.imageModels[0].pipelineClass = 'ExamplePipeline';+ await expect(chooseProductionRoute({ pool: [route] }, { kind: 'image', conditioning: 1 }, env))+ .resolves.toMatchObject({ route: null, reasons: [expect.stringContaining('example-image')] });+ });+ it('never falls back for an unavailable named pin, or accepts an incompatible default', async () => {+ const env = imageEnv([{ id: 'example-image' }]);+ await expect(assertPoolEligible([{ ...route, model: 'missing-image' }], env)).rejects.toThrow(/missing-image.*not installed/);+ env.imageModels[0].hardwareCompatibility = { state: 'unavailable', reasons: ['needs a GPU'] };+ await expect(assertPoolEligible([route], env)).rejects.toThrow(/example-image.*cannot run/);+ await expect(assertPoolEligible([route], imageEnv([]))).rejects.toThrow(/not installed/);+ });+});