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
address review (claude): drop cli-backend rows from the vision id set
Adam Eivy183a0d1e85e5
diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsxindex a965d13c74..73108e00bc 100644--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx@@ -69,8 +69,12 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, oconst [saving, setSaving] = useState(false);// Authoritative vision-capable ids from the backends themselves; `null` until// fetched, which `assignmentModelOptions` degrades to its id regex for. Gated- // on `open` — this drawer stays mounted on a closed page.- const visionModelIds = useVisionModelIds(open);+ // on `open` — this drawer stays mounted on a closed page. `visionLoaded` gates+ // the "no VLM installed" claim below: the capability scan is slower than the+ // assignments fetch, so `loading===false` with the scan still in flight is the+ // normal first render, and asserting "none found" there would flash the exact+ // empty-picker bug this drawer was fixed for.+ const { ids: visionModelIds, loaded: visionLoaded } = useVisionModelIds(open);const seed = useCallback((next) => { setDrafts(next); setBaseline(next); }, []);@@ -212,10 +216,15 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, oconst providerOptions = assignmentProviderOptions(entry, providers);const modelOptions = assignmentModelOptions(entry, providers, draft.providerId, visionModelIds);const pinned = !!draft.providerId;+ // A vision stage's options are only trustworthy once the capability+ // scan has settled — until then `modelOptions` is regex-only, which+ // is exactly the stale answer that hid the user's VLMs.+ const visionPending = entry?.modelFilter === 'vision' && !visionLoaded;// A vision stage on a local backend with nothing to offer means no// VLM is installed — say so instead of showing a bare text box that// reads as a broken dropdown.- const noVisionModels = pinned && entry?.modelFilter === 'vision' && modelOptions.length === 0;+ const noVisionModels = pinned && entry?.modelFilter === 'vision'+ && !visionPending && modelOptions.length === 0;return (<section key={stage.key} className="bg-port-bg border border-port-border rounded-lg p-3 space-y-2"><div className="flex items-center gap-2">@@ -257,6 +266,12 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o<span className="text-[11px] uppercase tracking-wide text-gray-500">Model</span>{!pinned ? (<div className="text-sm text-gray-600 py-2">—</div>+ ) : visionPending ? (+ // Hold the slot rather than rendering the free-text+ // fallback: the scan is about to widen the list, and+ // swapping an <input> the user may have typed into for a+ // <select> would drop their text from view.+ <div className="text-sm text-gray-500 py-2">Checking installed models…</div>) : modelOptions.length > 0 ? (<selectvalue={draft.model}diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsxindex 7e3f43b979..c2bc690072 100644--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx@@ -145,6 +145,35 @@ describe('CreativeDirectorModelsDrawer', () => {expect(getVisionModels).not.toHaveBeenCalled();});+ // /vision-models also returns `backend:'cli'` rows, and those are a blanket+ // per-PROVIDER claim: the server tags EVERY model of a `command:'claude'|'codex'`+ // CLI vision-capable because the CLI can read an image file. An ollama-backed+ // Claude CLI's model list is Ollama's TOOL-USE models, whose ids collide with+ // the real ollama provider's — so a flat id set would hand a text-only model to+ // the vision picker and sceneEvaluator would send frames to a model that can't+ // see them.+ it('ignores cli-backend rows so a text-only model cannot be smuggled in as vision', async () => {+ getVisionModels.mockResolvedValue({+ models: [+ { providerId: 'ollama', backend: 'ollama', id: 'gemma4:26b', vision: true },+ // The ollama-backed Claude CLI fronting a text-only Ollama model whose id+ // is also in the real `ollama` provider's list.+ { providerId: 'claude-ollama', backend: 'cli', id: 'llama3.2:latest', vision: true },+ ],+ });+ renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });+ await waitFor(() => expect(getVisionModels).toHaveBeenCalled());++ fireEvent.change(screen.getByLabelText('Scene evaluation provider'), { target: { value: 'ollama' } });++ const optionValues = Array.from(+ screen.getByLabelText('Scene evaluation model').querySelectorAll('option'),+ ).map((o) => o.value);+ expect(optionValues).toContain('gemma4:26b');+ // The cli-backend row must NOT make this text-only id a vision option.+ expect(optionValues).not.toContain('llama3.2:latest');+ });+it('falls back to the id regex when the vision-model fetch fails', async () => {getVisionModels.mockRejectedValue(new Error('ollama down'));renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });diff --git a/client/src/components/settings/AiAssignmentsTab.jsx b/client/src/components/settings/AiAssignmentsTab.jsxindex 444b8fc3c7..e9b5fcf2f3 100644--- a/client/src/components/settings/AiAssignmentsTab.jsx+++ b/client/src/components/settings/AiAssignmentsTab.jsx@@ -48,8 +48,9 @@ export default function AiAssignmentsTab() {const [bulkSaving, setBulkSaving] = useState(false);// Authoritative vision-capable ids straight from the local backends, so a// vision-filtered row (Scene evaluation) isn't reduced to an empty list by- // the client's id regex not knowing a newer VLM family.- const visionModelIds = useVisionModelIds();+ // the client's id regex not knowing a newer VLM family. This table renders a+ // <select> either way (no "none installed" claim), so it needs `ids` only.+ const { ids: visionModelIds } = useVisionModelIds();const load = useCallback(async () => {setLoading(true);diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex d3b4d7a739..90ce9de3d6 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -148,7 +148,7 @@ grep -i "what you want to do" client/src/hooks/README.md| `useRecordMerge` | Duplicate Universe/Series merge flow: open → dry-run preview → resolve field conflicts → execute, with an `onMerged` refresh callback. Drives `<MergeModal>`. | Surfacing the merge-duplicates UI anywhere (Sharing → Duplicates, Universes page). Don't re-implement the preview/execute dance. || `useProviderModels` | AI providers + two-step provider→model selection. | Any UI that picks a provider + model. || `useLocalModels` | Live installed Ollama/LM Studio model ids per backend + the server's editorial recommendation. | Model pickers that must show currently-installed local models (not just a provider's stale stored `models`). Fold in via `mergeModelLists` + `localBackendForProvider`. |-| `useVisionModelIds` | `Set` of model ids the server reports as vision-capable from each backend's own capability metadata (Ollama `/api/show`, LM Studio `type:'vlm'`); `null` until fetched. | Any VISION model picker — pass to `visionLocalModelFilter` / `assignmentModelOptions` so a new multimodal family (`gemma4`) isn't hidden by the stale client id regex. |+| `useVisionModelIds` | `{ ids, loaded }` — `ids` is the `Set` of model ids the server reports vision-capable on a LOCAL backend (Ollama `/api/show`, LM Studio `type:'vlm'`), `null` until fetched; `loaded` flips once the fetch settles. Drops `backend:'cli'` rows (a blanket per-provider claim, not a per-model fact). | Any VISION model picker — pass `ids` to `visionLocalModelFilter` / `assignmentModelOptions` so a new multimodal family (`gemma4`) isn't hidden by the stale client id regex; gate any "none installed" messaging on `loaded`. || `useTheme` | Dark/light theme + paired-theme switching. | Theme picker. || `useSingToScore` | Capture a sung melody from the mic and transcribe it into lead-sheet notation. `start()` opens the mic, counts in on the shared metronome, then accumulates a pitch track relative to beat 1; `stop()` runs the `transcribePitchTrack` pipeline (segment → quantize at the song tempo → spell for the key) and returns the lead-sheet body. Exposes `{ phase, beat, result, error, start, stop, reset }`; tears down mic/analyser/tracker/metronome on stop and unmount. | The Song editor's Sing-to-score panel. || `useSongTraining` | Drives a song training run over one scope (whole song or a sliced section) on top of `useColorMatch`: counts in, walks + grades the scope's score, then folds the finished take into the rolling progress history (`songProgress.recordAttempt`) and surfaces the next aggregate via `onProgress`. Supports looping (auto-restart after a run) and keeps a `lastSummary`. Exposes `{ running, countingIn, noteColors, activeIndex, lastSummary, start, stop }`; cancels pending loop relaunches on stop/unmount. | The Song editor's Training panel. |diff --git a/client/src/hooks/useVisionModelIds.js b/client/src/hooks/useVisionModelIds.jsindex ade80f5f5b..dff786d794 100644--- a/client/src/hooks/useVisionModelIds.js+++ b/client/src/hooks/useVisionModelIds.js@@ -2,7 +2,28 @@ import { useEffect, useState } from 'react';import { getVisionModels } from '../services/apiLocalLlm';/**- * The set of model ids the SERVER reports as vision-capable, fetched once.+ * Local backends whose `/vision-models` entries are per-MODEL capability facts.+ * MIRROR of `LOCAL_VISION_BACKENDS` in+ * server/services/creativeDirector/sceneEvaluator.js — keep in lockstep.+ *+ * The endpoint also returns `backend: 'cli'` entries, and those are NOT a+ * per-model fact: `isVisionCapableCliProvider` (server/lib/localModelHeuristics.js)+ * tags EVERY model of any `command: 'claude'|'codex'` CLI provider `vision: true`,+ * because such a CLI can read an image file whatever model it fronts. For an+ * ollama-backed Claude CLI (the shipped `claude-ollama` sample) that model list is+ * Ollama's *tool-use* models — `gpt-oss:20b`, `qwen3.6:35b` — text-only ids that+ * also exist in the real `ollama` provider's list. Folding those into a flat id+ * set would hand a text-only model to a vision picker on the `ollama` provider+ * (the id matches, so the per-provider intersection can't catch it), and+ * sceneEvaluator honors an explicit pin's model verbatim — so the scene would be+ * "evaluated" by a model that cannot see it. Drop CLI entries here, exactly as+ * sceneEvaluator's own auto-resolution does.+ */+const LOCAL_VISION_BACKENDS = new Set(['ollama', 'lmstudio']);++/**+ * The set of model ids the SERVER reports as vision-capable on a LOCAL backend,+ * fetched once.** The client's `isVisionModel` regex can only recognize multimodal families it* was written against, so it silently goes stale as new ones ship — it knew@@ -12,37 +33,52 @@ import { getVisionModels } from '../services/apiLocalLlm';* capabilities and LM Studio's `type: 'vlm'` tag), so vision pickers union this* set with the regex via `visionLocalModelFilter`.*- * Returns `null` until the fetch resolves (and on failure). Callers union this- * set with the regex, so it only ever ADDS models the regex didn't recognize —- * `null` (or an empty set, when no local VLM is installed) simply degrades to- * today's regex-only behavior rather than blanking a picker. Widening is the- * safe direction: a stale regex hides a model the user has, whereas this set- * can't speak for a custom provider pointing at a host the server never- * enumerated, so neither source is allowed to veto the other.+ * Returns `{ ids, loaded }`. Callers union `ids` with the regex, so it only ever+ * ADDS models the regex didn't recognize — a `null`/empty set simply degrades to+ * regex-only rather than blanking a picker. Widening is the safe direction: a+ * stale regex hides a model the user has, whereas this set can't speak for a+ * custom provider pointing at a host the server never enumerated, so neither+ * source vetoes the other.+ *+ * `loaded` flips true once the fetch SETTLES (success or failure) and exists so a+ * caller can tell "still fetching" from "fetched, none installed" — the endpoint+ * asks Ollama for each installed model's capabilities, so the pending window is+ * real. Without it a picker asserts "no vision models found" during the fetch+ * (the very bug this hook exists to fix) and then flips. `ids` alone can't carry+ * that distinction: it stays `null` on failure too.** @param {boolean} [enabled] gate the fetch — pass a drawer/modal's `open` when- * the host stays mounted while closed. The endpoint asks Ollama for each- * installed model's capabilities, so it is not free enough to fire on every- * render of a page that merely *contains* a closed picker. Fetches once and- * keeps the result if `enabled` later goes false.- * @returns {Set<string>|null}+ * the host stays mounted while closed, so a page merely *containing* a closed+ * picker doesn't pay for the capability scan. Fetches once and keeps the result+ * if `enabled` later goes false.+ * @returns {{ids: Set<string>|null, loaded: boolean}}*/export default function useVisionModelIds(enabled = true) {- const [ids, setIds] = useState(null);+ const [state, setState] = useState({ ids: null, loaded: false });useEffect(() => {- if (!enabled || ids) return undefined;+ if (!enabled || state.loaded) return undefined;let canceled = false;// Secondary control — a failed fetch falls back to the regex rather than- // toasting over the host page.+ // toasting over the host page. It still marks `loaded`, so an unreachable+ // backend can't suppress a caller's "none installed" messaging forever;+ // regex-only is then the best answer available.getVisionModels({ silent: true }).then((res) => {if (canceled) return;- setIds(new Set((res?.models || []).map((m) => m?.id).filter(Boolean)));+ const ids = new Set(+ (res?.models || [])+ .filter((m) => LOCAL_VISION_BACKENDS.has(m?.backend))+ .map((m) => m?.id)+ .filter(Boolean),+ );+ setState({ ids, loaded: true });})- .catch(() => {});+ .catch(() => { if (!canceled) setState({ ids: null, loaded: true }); });+ // A cancel (drawer closed mid-flight) leaves `loaded` false, so reopening+ // refetches rather than rendering against a result that never arrived.return () => { canceled = true; };- }, [enabled, ids]);+ }, [enabled, state.loaded]);- return ids;+ return state;}