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 (codex): merge installed VLMs in, key them by the enumerated provider
Adam Eivye46783009f96
diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsxindex 15bbd3f416..1e125be14c 100644--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx@@ -75,7 +75,7 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o// 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 { idsByBackend: visionIdsByBackend, loaded: visionLoaded } = useVisionModelIds(open);+ const { idsByProvider: visionIdsByProvider, loaded: visionLoaded } = useVisionModelIds(open);const seed = useCallback((next) => { setDrafts(next); setBaseline(next); }, []);@@ -215,7 +215,7 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, oconst entry = entryById[assignmentIdFor(stage.key)];const draft = drafts[stage.key] || { providerId: '', model: '' };const providerOptions = assignmentProviderOptions(entry, providers);- const modelOptions = assignmentModelOptions(entry, providers, draft.providerId, visionIdsByBackend);+ const modelOptions = assignmentModelOptions(entry, providers, draft.providerId, visionIdsByProvider);const pinned = !!draft.providerId;// Both hints below are about the LOCAL capability scan, so they only// apply when the pinned provider is an Ollama / LM Studio backend. A@@ -256,7 +256,7 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o// Vision-filtered stages (scene evaluation) seed the first// eligible VLM when the provider's default is text-only.const nextDefault = providerId- ? assignmentDefaultModel(entry, providers, providerId, visionIdsByBackend)+ ? assignmentDefaultModel(entry, providers, providerId, visionIdsByProvider): '';// Seed the provider's default model on switch; clearing the// provider clears the model too.diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsxindex f71678e441..dced8d9d81 100644--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx@@ -133,6 +133,33 @@ describe('CreativeDirectorModelsDrawer', () => {expect(optionValues).toContain('llava:latest');});+ // The shipped `ollama` provider starts with `models: []` and /local-llm/install+ // never refreshes it, so on a fresh install the stored snapshot is empty while+ // a VLM IS installed. Filtering that empty list can only ever yield nothing —+ // the server's installed list has to be merged INTO the candidates.+ it('offers an installed VLM even when the provider model list is stale/empty', async () => {+ getAiAssignments.mockResolvedValue({+ ...ASSIGNMENTS,+ providers: [+ ...ASSIGNMENTS.providers.filter((p) => p.id !== 'ollama'),+ { id: 'ollama', name: 'Ollama', type: 'api', enabled: true, defaultModel: null, models: [] },+ ],+ });+ getVisionModels.mockResolvedValue({+ models: [{ providerId: 'ollama', backend: 'ollama', id: 'gemma4:e4b', 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 modelSelect = screen.getByLabelText('Scene evaluation model');+ expect(Array.from(modelSelect.querySelectorAll('option')).map((o) => o.value)).toContain('gemma4:e4b');+ // ...and it seeds, rather than leaving the stage on a blank/auto pin.+ expect(modelSelect.value).toBe('gemma4:e4b');+ expect(screen.queryByText(/No vision-capable models found/i)).toBeNull();+ });+it('does not fetch vision models while closed', async () => {// The drawer stays mounted on the page; the endpoint asks Ollama for every// installed model's capabilities, so a closed drawer must not pay for it.diff --git a/client/src/components/settings/AiAssignmentsTab.jsx b/client/src/components/settings/AiAssignmentsTab.jsxindex 18bfa038fe..a3f854ca4a 100644--- a/client/src/components/settings/AiAssignmentsTab.jsx+++ b/client/src/components/settings/AiAssignmentsTab.jsx@@ -50,7 +50,7 @@ export default function AiAssignmentsTab() {// vision-filtered row (Scene evaluation) isn't reduced to an empty list by// 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 the map only.- const { idsByBackend: visionIdsByBackend } = useVisionModelIds();+ const { idsByProvider: visionIdsByProvider } = useVisionModelIds();const load = useCallback(async () => {setLoading(true);@@ -137,7 +137,7 @@ export default function AiAssignmentsTab() {const savedIds = [];for (const entry of targets) {// Vision-filtered rows seed the first eligible VLM, not a text-only default.- const targetDefaultModel = assignmentDefaultModel(entry, data.providers, toProvider, visionIdsByBackend);+ const targetDefaultModel = assignmentDefaultModel(entry, data.providers, toProvider, visionIdsByProvider);const nextModel = entry.modelEditable === false ? (drafts[entry.id]?.model || '') : targetDefaultModel;const next = await updateAiAssignment(entry.id, {providerId: toProvider,@@ -258,7 +258,7 @@ export default function AiAssignmentsTab() {{filtered.map((entry) => {const draft = drafts[entry.id] || getDraft(entry);const providerOptions = assignmentProviderOptions(entry, data.providers);- const modelOptions = assignmentModelOptions(entry, data.providers, draft.providerId, visionIdsByBackend);+ const modelOptions = assignmentModelOptions(entry, data.providers, draft.providerId, visionIdsByProvider);const dirty = !sameDraft(entry, draft);return (<tr key={entry.id} className="align-top">@@ -280,7 +280,7 @@ export default function AiAssignmentsTab() {const nextProviderId = e.target.value;// Vision-filtered rows (e.g. Scene evaluation) seed the// first eligible VLM when the provider default is text-only.- const nextDefault = assignmentDefaultModel(entry, data.providers, nextProviderId, visionIdsByBackend);+ const nextDefault = assignmentDefaultModel(entry, data.providers, nextProviderId, visionIdsByProvider);setDraft(entry.id, { providerId: nextProviderId, model: entry.modelEditable === false ? draft.model : nextDefault });}}aria-label={`Provider for ${entry.label}`}diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex 6354c35020..de223bd1ce 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` | `{ idsByBackend, loaded }` — vision-capable model ids the server reports, keyed by local backend (`{ ollama: Set, lmstudio: Set }` from 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 `idsByBackend` 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` and on the provider being a local backend. |+| `useVisionModelIds` | `{ idsByProvider, loaded }` — vision-capable model ids the server reports (Ollama `/api/show` + LM Studio `type:'vlm'`), keyed by the provider id that serves them (`{ ollama: Set, lmstudio: Set }`), `null` until fetched; `loaded` flips once the fetch settles. Drops `backend:'cli'` rows (a blanket per-provider claim, not a per-model fact) and never vouches for a provider the server didn't enumerate. | Any VISION model picker — pass `idsByProvider` to `visionLocalModelFilter` / `assignmentModelOptions` so a new multimodal family (`gemma4`) isn't hidden by the stale client id regex, and so an installed VLM shows even when the provider's stored `models` snapshot is stale; gate any "none installed" messaging on `loaded` and on the provider being a local backend. || `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 71bcd805c4..b09f42cd53 100644--- a/client/src/hooks/useVisionModelIds.js+++ b/client/src/hooks/useVisionModelIds.js@@ -22,8 +22,17 @@ import { getVisionModels } from '../services/apiLocalLlm';const LOCAL_VISION_BACKENDS = new Set(['ollama', 'lmstudio']);/**- * The model ids the SERVER reports as vision-capable, keyed BY LOCAL BACKEND- * (`{ ollama: Set, lmstudio: Set }`), fetched once.+ * The provider ids the server tags its local rows with (`PROVIDER_ID[backend]` in+ * server/services/localLlm.js). Seeded into the map so a backend that reports no+ * VLM is a definite "none installed" rather than an absent key. A CUSTOM provider+ * pointed at a different Ollama/LM Studio host is deliberately NOT here: the+ * server never enumerated that host, so it stays on the regex-only path.+ */+const LOCAL_PROVIDER_IDS = ['ollama', 'lmstudio'];++/**+ * The model ids the SERVER reports as vision-capable, keyed BY THE PROVIDER ID+ * that serves them (`{ ollama: Set, lmstudio: Set }`), 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@@ -31,36 +40,36 @@ const LOCAL_VISION_BACKENDS = new Set(['ollama', 'lmstudio']);* `gemma4:e4b` and `qwen3.6:35b` staring at an EMPTY Scene Evaluation model* picker. The server has the authoritative answer (Ollama's `/api/show`* capabilities and LM Studio's `type: 'vlm'` tag), so vision pickers union this- * set with the regex via `visionLocalModelFilter`.+ * in via `visionLocalModelFilter` / `assignmentModelOptions`.*- * Returns `{ idsByBackend, loaded }`. Callers union `idsByBackend` with the regex- * via `visionLocalModelFilter`, so it only ever ADDS models the regex didn't- * recognize — a `null`/empty map 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 map can't speak for a custom provider pointing at a- * host the server never enumerated, so neither source vetoes the other.+ * Returns `{ idsByProvider, loaded }`. Callers union `idsByProvider` with the+ * regex, so it only ever ADDS models the regex didn't recognize — a `null`/empty+ * map 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 map can't+ * speak for a provider the server never enumerated, so neither vetoes the other.*- * Keyed by backend, never flattened to one id set: a bare id is not a- * capability. The same id can be a VLM on one backend and text-only on another,- * and CLI rows assert vision for every model of a claude/codex CLI regardless of- * the model — so a flat set leaks text-only ids onto the `ollama` provider,- * whose own list contains the very same ids.+ * Keyed by the ENUMERATED PROVIDER, never flattened and never keyed by backend+ * alone — a bare id is not a capability. Flattening leaks a claude/codex CLI's+ * blanket per-provider vision claim onto `ollama` (whose list holds the very same+ * ids); keying by backend still leaks a local VLM's id onto a CUSTOM provider+ * pointed at a *different* Ollama/LM Studio host that the server never+ * enumerated. Both matter because sceneEvaluator honors a pin's model verbatim.** `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. `idsByBackend` alone+ * (the very bug this hook exists to fix) and then flips. `idsByProvider` 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, 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 {{idsByBackend: Record<string, Set<string>>|null, loaded: boolean}}+ * @returns {{idsByProvider: Record<string, Set<string>>|null, loaded: boolean}}*/export default function useVisionModelIds(enabled = true) {- const [state, setState] = useState({ idsByBackend: null, loaded: false });+ const [state, setState] = useState({ idsByProvider: null, loaded: false });useEffect(() => {if (!enabled || state.loaded) return undefined;@@ -72,18 +81,21 @@ export default function useVisionModelIds(enabled = true) {getVisionModels({ silent: true }).then((res) => {if (canceled) return;- // Every local backend gets a key even when it reports nothing, so a- // present-but-empty backend reads as "none installed" rather than+ // Key by the providerId the server itself reports for each row, so the+ // map only ever vouches for the provider the server actually enumerated.+ // Seed a key per enumerated local provider even when it reports nothing,+ // so a present-but-empty backend reads as "none installed" rather than// "unknown" at the lookup site.- const idsByBackend = Object.fromEntries(- [...LOCAL_VISION_BACKENDS].map((backend) => [backend, new Set()]),- );+ const idsByProvider = {};for (const m of res?.models || []) {- if (m?.id && LOCAL_VISION_BACKENDS.has(m?.backend)) idsByBackend[m.backend].add(m.id);+ if (!LOCAL_VISION_BACKENDS.has(m?.backend) || !m?.providerId) continue;+ (idsByProvider[m.providerId] ||= new Set());+ if (m.id) idsByProvider[m.providerId].add(m.id);}- setState({ idsByBackend, loaded: true });+ for (const providerId of LOCAL_PROVIDER_IDS) idsByProvider[providerId] ||= new Set();+ setState({ idsByProvider, loaded: true });})- .catch(() => { if (!canceled) setState({ idsByBackend: null, loaded: true }); });+ .catch(() => { if (!canceled) setState({ idsByProvider: 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; };diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 93265f0f08..b09b1b4c57 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -198,37 +198,41 @@ export const filterGenerationModels = (models) =>* hide multimodal cloud models whose ids don't encode vision (`gpt-4o`,* `claude-*`). Pass as `useProviderModels({ modelFilter: visionLocalModelFilter })`.*- * `visionIdsByBackend` is the AUTHORITATIVE per-backend map the server reports- * from each backend's own capability metadata (Ollama `/api/show`, LM Studio- * `type: 'vlm'`) — `{ ollama: Set, lmstudio: Set }`, see `useVisionModelIds`.- * It is unioned with, not substituted for, the id regex: the regex alone goes- * stale every time a new multimodal family ships (it knew `gemma-3` but not- * `gemma4`, so a user with only `gemma4:e4b` + `qwen3.6:35b` installed saw an- * EMPTY vision picker), while the authoritative map alone can't speak for a- * custom provider pointing at a remote host the server never enumerated. Pass- * `null` (the default) when it hasn't loaded — that degrades to regex-only.+ * `visionIdsByProvider` is the AUTHORITATIVE map the server reports from each+ * backend's own capability metadata (Ollama `/api/show`, LM Studio+ * `type: 'vlm'`), keyed by the PROVIDER ID the server says serves each model —+ * see `useVisionModelIds`. It is unioned with, not substituted for, the id+ * regex: the regex alone goes stale every time a new multimodal family ships+ * (it knew `gemma-3` but not `gemma4`, so a user with only `gemma4:e4b` ++ * `qwen3.6:35b` installed saw an EMPTY vision picker), while the map alone+ * can't speak for a provider the server never enumerated. Pass `null` (the+ * default) when it hasn't loaded — that degrades to regex-only.*- * Keyed BY BACKEND rather than flattened to one id set, because a bare id is- * not a capability: the same id can be a VLM on one backend and text-only on- * another, and the server also reports `backend: 'cli'` rows that assert vision- * for EVERY model of a claude/codex CLI (that CLI can read an image file- * whatever model it fronts). Flattening let an ollama-backed Claude CLI's- * text-only ids — which collide with the real `ollama` provider's list — pass- * this filter, and sceneEvaluator honors a pin's model verbatim, so frames went- * to a model that cannot see them. The per-provider `models` intersection the- * callers below apply cannot catch that: the id genuinely is on both lists.+ * Keyed by the ENUMERATED PROVIDER, not flattened and not keyed by backend,+ * because a bare id is not a capability:+ * - The same id can be a VLM on one backend and text-only on another, and the+ * server also reports `backend: 'cli'` rows asserting vision for EVERY model+ * of a claude/codex CLI (that CLI reads an image file whatever model it+ * fronts). Flattening let an ollama-backed Claude CLI's text-only ids — which+ * collide with the real `ollama` provider's list — pass this filter.+ * - Keying by backend alone still over-shares: a CUSTOM provider pointed at a+ * *different* Ollama/LM Studio host (endpoint `:11434` on another machine)+ * resolves to the same backend, but the server never enumerated that host,+ * so a local VLM's id would vouch for a remote model that merely shares it.+ * An unenumerated local provider therefore stays on the regex-only path. This+ * matters because sceneEvaluator honors a pin's model verbatim — a wrong yes+ * here sends frames to a model that cannot see them.** @param {string} id* @param {{id?:string,endpoint?:string,name?:string}} [provider]- * @param {Record<string, Set<string>>|null} [visionIdsByBackend]+ * @param {Record<string, Set<string>>|null} [visionIdsByProvider]* @returns {boolean}*/-export const visionLocalModelFilter = (id, provider, visionIdsByBackend = null) => {- const backend = localBackendForProvider(provider);+export const visionLocalModelFilter = (id, provider, visionIdsByProvider = null) => {// Cloud/API providers are left intact — the regex is a local-name heuristic// and would wrongly hide multimodal cloud ids like `gpt-4o`.- if (!backend) return true;- return visionIdsByBackend?.[backend]?.has(id) === true || isVisionModel(id);+ if (!localBackendForProvider(provider)) return true;+ return visionIdsByProvider?.[provider?.id]?.has(id) === true || isVisionModel(id);};/**@@ -460,24 +464,35 @@ export const assignmentProviderOptions = (entry, providers) => {* When `entry.modelFilter === 'vision'`, LOCAL backends (Ollama / LM Studio)* are reduced to vision-capable models via `visionLocalModelFilter` so the* Scene Evaluation (and other vision) pickers can't offer text-only ids.- * Cloud/API providers are left intact by that filter. Pass `visionIdsByBackend`- * (from `useVisionModelIds`) so that reduction uses the backend's own- * capability metadata instead of the id regex alone.+ * Cloud/API providers are left intact by that filter. Pass `visionIdsByProvider`+ * (from `useVisionModelIds`) so that reduction uses the backend's own capability+ * metadata instead of the id regex alone.+ *+ * For a vision entry on an ENUMERATED local provider, the server's installed-VLM+ * list is also UNIONED INTO the candidates rather than only filtering them: a+ * provider's stored `models` is a snapshot that goes stale the moment the user+ * pulls a model (`/local-llm/install` doesn't refresh it, and the shipped+ * `ollama` provider starts out empty), so filtering that list alone still hides+ * a VLM that is installed right now — the same staleness `useLocalModels` ++ * `mergeModelLists` exists to solve for non-vision pickers. Only the provider+ * the server actually enumerated gets this: an unenumerated one would otherwise+ * be offered models from a host it doesn't serve.*/-export const assignmentModelOptions = (entry, providers, providerId, visionIdsByBackend = null) => {+export const assignmentModelOptions = (entry, providers, providerId, visionIdsByProvider = null) => {const provider = providers.find((p) => p.id === providerId);- const raw = Array.isArray(entry?.modelOptions)- ? entry.modelOptions- : (provider?.models || []);+ const baked = Array.isArray(entry?.modelOptions);+ const raw = baked ? entry.modelOptions : (provider?.models || []);// Normalize object-shaped entries (`{ id }`) so both baked and live lists// yield plain string options for the <select>.const models = raw.map((m) => (typeof m === 'string' ? m : m?.id)).filter(Boolean);- if (entry?.modelFilter === 'vision') {- return models.filter((id) => visionLocalModelFilter(id, provider, visionIdsByBackend));- }- return models;+ if (entry?.modelFilter !== 'vision') return models;+ // Pre-baked `modelOptions` is an explicit caller-supplied list — honor it as+ // the full candidate set rather than widening it from the backend.+ const installed = baked ? null : visionIdsByProvider?.[providerId];+ const candidates = installed ? mergeModelLists(models, [...installed]) : models;+ return candidates.filter((id) => visionLocalModelFilter(id, provider, visionIdsByProvider));};/**@@ -486,13 +501,13 @@ export const assignmentModelOptions = (entry, providers, providerId, visionIdsBy* filtered options — a local backend's text-only `defaultModel` must not be* seeded into the Scene Evaluation picker.*/-export const assignmentDefaultModel = (entry, providers, providerId, visionIdsByBackend = null) => {+export const assignmentDefaultModel = (entry, providers, providerId, visionIdsByProvider = null) => {if (!providerId) return '';const provider = providers.find((p) => p.id === providerId);if (!provider) return '';const def = provider.defaultModel || '';if (entry?.modelFilter !== 'vision') return def;- const models = assignmentModelOptions(entry, providers, providerId, visionIdsByBackend);+ const models = assignmentModelOptions(entry, providers, providerId, visionIdsByProvider);if (def && models.includes(def)) return def;return models[0] || '';};diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 5bb515542f..95846457b0 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -416,9 +416,11 @@ describe('mergeModelLists', () => {});describe('visionLocalModelFilter', () => {- const ollama = { name: 'Ollama', endpoint: 'http://localhost:11434' };- const lmstudio = { name: 'LM Studio', endpoint: 'http://localhost:1234' };- const cloud = { name: 'OpenAI', endpoint: 'https://api.openai.com/v1' };+ // `id` matters: the authoritative map is keyed by the provider id the SERVER+ // enumerated, so only these canonical ids can be vouched for.+ const ollama = { id: 'ollama', name: 'Ollama', endpoint: 'http://localhost:11434' };+ const lmstudio = { id: 'lmstudio', name: 'LM Studio', endpoint: 'http://localhost:1234' };+ const cloud = { id: 'openai', name: 'OpenAI', endpoint: 'https://api.openai.com/v1' };it('keeps only vision models for local backends (ollama/lm studio)', () => {expect(visionLocalModelFilter('qwen2.5vl:32b', ollama)).toBe(true);@@ -445,7 +447,7 @@ describe('visionLocalModelFilter', () => {expect(visionLocalModelFilter('qwen2.5-coder:32b', ollama, { ollama: new Set(['gemma4:e4b']) })).toBe(false);});- it('scopes capabilities to their own backend — an id is not a capability', () => {+ it('scopes capabilities to the enumerated provider — an id is not a capability', () => {// The same id can be a VLM on one backend and text-only on another; a flat// set would mark it eligible for either. LM Studio says it's vision; Ollama// never reported it, so on Ollama only the regex may speak (and it says no).@@ -454,6 +456,16 @@ describe('visionLocalModelFilter', () => {expect(visionLocalModelFilter('shared-id:latest', ollama, lmOnly)).toBe(false);});+ it('does not vouch for a custom provider pointed at a host the server never enumerated', () => {+ // A custom provider at a REMOTE ollama resolves to the ollama backend, but+ // the local /vision-models result says nothing about that host — so a local+ // VLM's id must not make a same-named remote model "vision".+ const remote = { id: 'ollama-udev', name: 'Ollama (udev)', endpoint: 'http://udev:11434' };+ const localOnly = { ollama: new Set(['gemma4:e4b']) };+ expect(visionLocalModelFilter('gemma4:e4b', ollama, localOnly)).toBe(true);+ expect(visionLocalModelFilter('gemma4:e4b', remote, localOnly)).toBe(false);+ });+it('leaves cloud providers untouched regardless of the authoritative map', () => {expect(visionLocalModelFilter('gpt-4o', cloud, { ollama: new Set() })).toBe(true);});