Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agents): hide switched-off models in every model picker

rubenluetke10-beepb3deef50a962
diff --git a/jarvis/agent_chat/agent_provider_prefs.py b/jarvis/agent_chat/agent_provider_prefs.py
index b4d8b16411..1d37d4a63a 100644
--- a/jarvis/agent_chat/agent_provider_prefs.py
+++ b/jarvis/agent_chat/agent_provider_prefs.py
@@ -12,8 +12,13 @@ the user data folder:
subscription.
- ``hidden_models`` — per provider id, model ids left out of the pickers.
-Read on the agents' surface only (``surface="society"``): the coding panes
-and the front page's chat keep every seat they had.
+``disabled`` and ``api_only`` narrow the agents' surface only
+(``surface="society"``): the coding panes and the front page's chat keep
+every seat they had. ``hidden_models`` narrows every model picker — the
+agents', the threads', the coding panes' and the front page's — because a
+model switched off on the API Keys page is one the person does not want to
+scroll past anywhere. A hidden model still runs when a session already sits
+on it; hiding only takes it out of the lists.
"""
from __future__ import annotations
@@ -27,7 +32,7 @@ from typing import Any
from loguru import logger
-#: The agents' surface; the only one these preferences narrow.
+#: The agents' surface; the only one ``disabled`` and ``api_only`` narrow.
AGENT_SURFACE = "society"
_MAX_IDS = 256
@@ -126,6 +131,12 @@ def save(prefs: AgentProviderPrefs) -> AgentProviderPrefs:
return prefs
+def offered_models(provider_id: str, models: list[dict[str, Any]]) -> list[dict[str, Any]]:
+ """``models`` minus the ones hidden for ``provider_id`` on the API Keys page."""
+ hidden = set(load().hidden(provider_id))
+ return [m for m in models if m.get("id") not in hidden] if hidden else models
+
+
def forces_api(provider_id: str, surface: str) -> bool:
"""Whether a dual row must run on its API key on ``surface``."""
return surface == AGENT_SURFACE and provider_id in load().api_only
diff --git a/jarvis/ui/web/agent_chat_routes.py b/jarvis/ui/web/agent_chat_routes.py
index ff9a84ee23..8eb75880cf 100644
--- a/jarvis/ui/web/agent_chat_routes.py
+++ b/jarvis/ui/web/agent_chat_routes.py
@@ -449,9 +449,11 @@ def _catalog_rows(
"""The provider rows for ``surface`` with this machine's runner facts."""
from jarvis.agent_chat import agent_provider_prefs
- # The agents' own seats carry the API Keys page's on/off and hidden
- # models; their pickers filter on them. Other surfaces keep every seat.
- prefs = agent_provider_prefs.load() if surface == agent_provider_prefs.AGENT_SURFACE else None
+ # Every surface's rows carry the models hidden on the API Keys page, and
+ # every model picker leaves them out. The on/off switch is the agents'
+ # own: other surfaces keep every seat.
+ prefs = agent_provider_prefs.load()
+ agents = surface == agent_provider_prefs.AGENT_SURFACE
rows: list[dict[str, Any]] = []
for row in rows_for(surface):
d = row.to_dict()
@@ -482,9 +484,9 @@ def _catalog_rows(
# decided here, from the runner, so the box never offers a "/" list
# to a seat that would read it as plain text.
d["typeahead"] = list(typeahead.triggers_for(runner, surface))
- if prefs is not None:
+ if agents:
d["enabled"] = prefs.enabled(row.id)
- d["hidden_models"] = list(prefs.hidden(row.id))
+ d["hidden_models"] = list(prefs.hidden(row.id))
rows.append(d)
return rows
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx b/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
index f561207a8e..8679a3b73f 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/AgentComposer.tsx
@@ -25,6 +25,7 @@ import { folderLeaf } from "@/lib/folderPath";
import { effortLadder, snapEffort } from "@/lib/effortLadder";
import { rankModels } from "@/lib/modelRanking";
import { isApiRunner, pickAgentChatFolder, type CuratedModel } from "@/lib/agentChatApi";
+import { offeredModels, useSavedHiddenModels } from "@/lib/agentProviderPrefs";
import { runningTurn } from "@/components/agentchat/reduce";
import { permissionModeIcon } from "@/components/agentchat/permissionIcons";
import { useComposerDictation } from "@/components/agentchat/useComposerDictation";
@@ -148,6 +149,7 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
const backendOutdated = useAgentChat((s) => s.backendOutdated);
const connections = useAgentChat((s) => s.connections);
const liveModels = useAgentChat((s) => s.liveModels);
+ const savedHidden = useSavedHiddenModels((s) => s.hidden);
const health = useAgentChat((s) => s.health);
const draft = useAgentChat((s) => s.draft);
const timeline = useAgentChat((s) => s.timeline);
@@ -434,7 +436,9 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
const brainGroups = useMemo<ComboboxGroup[]>(() => {
return brainProviders.map((p) => {
const live = liveModels[p.id];
- const models = p.models_source === "live" && live && live.length ? live : (p.curated_models ?? []);
+ const listed = p.models_source === "live" && live && live.length ? live : (p.curated_models ?? []);
+ // Models switched off on the API Keys page stay out; the current pick stays.
+ const models = offeredModels(p, listed, p.id === draft.provider ? draft.model : "", savedHidden);
const disabled = !p.connected;
const hint = disabled
? p.cli_installed === false
@@ -475,7 +479,7 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
more: older.length ? { label: t("agent_chat.older_models"), options: older.map(toOption) } : undefined,
};
});
- }, [brainProviders, liveModels, providerMark, t]);
+ }, [brainProviders, liveModels, providerMark, t, draft.provider, draft.model, savedHidden]);
const modelList = useMemo(() => {
if (!provider) return [];
@@ -493,7 +497,8 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
hint: m.note || (m.label && m.label !== m.id ? m.id : undefined),
searchText: m.id,
});
- const { current, older } = rankModels(modelList.filter((m) => m.id));
+ // Models switched off on the API Keys page stay out; the current pick stays.
+ const { current, older } = rankModels(offeredModels(provider, modelList, draft.model, savedHidden).filter((m) => m.id));
const options: ComboboxOption[] = [
{ value: "", label: t("agent_chat.model_default"), hint: provider.label },
...current.map(toOption),
@@ -503,7 +508,7 @@ export function AgentComposer({ autoFocus = false }: { autoFocus?: boolean }) {
options,
more: older.length ? { label: t("agent_chat.older_models"), options: older.map(toOption) } : undefined,
}];
- }, [provider, modelList, t]);
+ }, [provider, modelList, t, draft.model, savedHidden]);
// The effort ladder is the provider's, narrowed to the chosen model's own
// levels when the catalog knows them (agy's Pro: low/high; its Claude
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPickers.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPickers.tsx
index 19584c2c41..189f830922 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPickers.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPickers.tsx
@@ -4,6 +4,7 @@ import { isUnguardedPermissionMode, permissionModeIcon } from "@/components/agen
import { Combobox, type ComboboxGroup, type ComboboxOption } from "@/components/ui/combobox";
import { useT } from "@/i18n";
import type { CuratedModel } from "@/lib/agentChatApi";
+import { offeredModels, useSavedHiddenModels } from "@/lib/agentProviderPrefs";
import { effortLadder } from "@/lib/effortLadder";
import { rankModels } from "@/lib/modelRanking";
import { cn } from "@/lib/utils";
@@ -63,12 +64,15 @@ export function AgentModelPicker({
onPick: (provider: string, model: string) => void;
}) {
const olderLabel = useT()("agent_chat.older_models");
+ const saved = useSavedHiddenModels((state) => state.hidden);
const groups = useMemo<ComboboxGroup[]>(() => providers.map((provider) => {
const locked = lockedProvider !== null && provider.id !== lockedProvider;
const disabled = !provider.connected || locked;
const hint = locked ? "new thread" : !provider.connected ? (provider.cli_installed === false ? "not installed" : "connect first") : undefined;
const icon = <AgentMark agent={provider.agent ?? ""} label={provider.label} logoUrl={provider.logoUrl} variant="plain" size="sm" />;
- const models = modelsOf(provider, liveModels).filter((model) => model.id);
+ // Models switched off on the API Keys page stay out; the current pick stays.
+ const current = provider.id === draft.provider ? draft.model : "";
+ const models = offeredModels(provider, modelsOf(provider, liveModels), current, saved).filter((model) => model.id);
const toOption = (model: CuratedModel): ComboboxOption => ({
value: `${provider.id}${SEP}${model.id}`,
label: model.label || model.id,
@@ -88,7 +92,7 @@ export function AgentModelPicker({
],
more: ranked.older.length ? { label: olderLabel, options: ranked.older.map(toOption) } : undefined,
};
- }), [providers, liveModels, lockedProvider, olderLabel]);
+ }), [providers, liveModels, lockedProvider, draft.provider, draft.model, saved, olderLabel]);
return <Combobox ariaLabel="Coding agent and model" testId="thread-model-picker"
value={`${draft.provider}${SEP}${draft.model}`} groups={groups}
onChange={(value) => { const [provider, model = ""] = value.split(SEP); onPick(provider, model); }}
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
index f0d64cc54b..536e344a9d 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
@@ -66,6 +66,7 @@ import { cn } from "@/lib/utils";
import { societyDisplayName } from "@/lib/societyDisplayName";
import { createAgentChatStore, useAgentChatStore, type AgentChatStoreHook } from "@/store/agentChat";
import type { AgentChatSurface, ApprovalDecision } from "@/lib/agentChatApi";
+import { offeredModels, useSavedHiddenModels } from "@/lib/agentProviderPrefs";
import { AgentSwatch } from "../AgentSwatch";
import {
@@ -504,6 +505,7 @@ function ModelPicker() {
const providerOptions = useAgentChat((s) => s.providerOptions);
const providerById = useAgentChat((s) => s.providerById);
const liveModels = useAgentChat((s) => s.liveModels);
+ const savedHidden = useSavedHiddenModels((s) => s.hidden);
const loadModels = useAgentChat((s) => s.loadModels);
const setDraft = useAgentChat((s) => s.setDraft);
const locks = useAgentChat((s) => s.locks);
@@ -517,12 +519,14 @@ function ModelPicker() {
const models = useMemo(() => {
if (!chosen) return [];
const seen = new Set<string>();
- return [...(liveModels[chosen.id] ?? []), ...chosen.curated_models].filter((m) => {
+ const listed = [...(liveModels[chosen.id] ?? []), ...chosen.curated_models].filter((m) => {
if (seen.has(m.id)) return false;
seen.add(m.id);
return true;
});
- }, [chosen, liveModels]);
+ // Models switched off on the API Keys page stay out; the current pick stays.
+ return offeredModels(chosen, listed, chosen.id === draft.provider ? draft.model : "", savedHidden);
+ }, [chosen, liveModels, draft.provider, draft.model, savedHidden]);
useEffect(() => {
if (open && chosen && chosen.models_source === "live") void loadModels(chosen.id);
diff --git a/jarvis/ui/web/frontend/src/lib/agentChatApi.ts b/jarvis/ui/web/frontend/src/lib/agentChatApi.ts
index 2c970402df..7ebc2af89a 100644
--- a/jarvis/ui/web/frontend/src/lib/agentChatApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agentChatApi.ts
@@ -63,10 +63,15 @@ export interface AgentChatProvider {
typeahead?: string[];
/**
* The agents' surface only (`surface=society`): whether the API Keys page
- * has this provider on for the agents, and the models it hid there.
- * Absent elsewhere and on an older backend: on, nothing hidden.
+ * has this provider on for the agents. Absent elsewhere and on an older
+ * backend: on.
*/
enabled?: boolean;
+ /**
+ * The models the API Keys page hid for this provider, on every surface;
+ * every model picker leaves them out (`offeredModels`). Absent on an older
+ * backend: nothing hidden.
+ */
hidden_models?: string[];
}
diff --git a/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.test.ts b/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.test.ts
new file mode 100644
index 0000000000..d6b4c8cb07
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from "vitest";
+import { offeredModels } from "./agentProviderPrefs";
+
+const MODELS = [
+ { id: "claude-opus-5-5", label: "Claude Opus 5.5" },
+ { id: "claude-opus-5", label: "Claude Opus 5" },
+ { id: "opusplan", label: "Opus plans, Sonnet builds" },
+];
+
+describe("offeredModels", () => {
+ it("leaves out the models the API Keys page hid for the row", () => {
+ const row = { id: "claude-api", hidden_models: ["claude-opus-5", "opusplan"] };
+ expect(offeredModels(row, MODELS).map((m) => m.id)).toEqual(["claude-opus-5-5"]);
+ });
+
+ it("returns the same list when nothing is hidden", () => {
+ expect(offeredModels({ id: "claude-api" }, MODELS)).toBe(MODELS);
+ expect(offeredModels({ id: "claude-api", hidden_models: [] }, MODELS)).toBe(MODELS);
+ });
+
+ it("keeps the current pick listed even when it is hidden", () => {
+ const row = { id: "claude-api", hidden_models: ["claude-opus-5", "opusplan"] };
+ expect(offeredModels(row, MODELS, "opusplan").map((m) => m.id)).toEqual(["claude-opus-5-5", "opusplan"]);
+ });
+
+ it("prefers the lists this window saved over the row's older copy", () => {
+ const row = { id: "claude-api", hidden_models: ["claude-opus-5"] };
+ expect(offeredModels(row, MODELS, "", { "claude-api": ["opusplan"] }).map((m) => m.id)).toEqual([
+ "claude-opus-5-5",
+ "claude-opus-5",
+ ]);
+ // A save that left this provider with nothing hidden shows everything again.
+ expect(offeredModels(row, MODELS, "", {})).toBe(MODELS);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.ts b/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.ts
index 8d0a391d95..12a632cbd8 100644
--- a/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.ts
+++ b/jarvis/ui/web/frontend/src/lib/agentProviderPrefs.ts
@@ -4,8 +4,12 @@
*
* Every connected provider is on unless listed in `disabled`; a dual row in
* `api_only` runs on its key instead of the subscription; `hidden_models`
- * leaves models out of the agents' pickers.
+ * leaves models out of every model picker — the agents', the threads', the
+ * coding panes' and the front page's (each catalog row carries its own list).
*/
+import { create } from "zustand";
+import type { CuratedModel } from "@/lib/agentChatApi";
+
export interface AgentProviderPrefs {
disabled: string[];
api_only: string[];
@@ -37,6 +41,34 @@ export async function saveAgentProviderPrefs(patch: Partial<AgentProviderPrefs>)
return (await res.json()) as AgentProviderPrefs;
}
+/**
+ * The hidden-model lists this window last saved on the API Keys page, or null
+ * before any save. Newer than a catalog a picker already holds: those are
+ * read once and kept, so without this a model switched off would stay listed
+ * until the next thread or chat reloaded its catalog.
+ */
+export const useSavedHiddenModels = create<{ hidden: Record<string, string[]> | null }>(() => ({ hidden: null }));
+
+/**
+ * The models a picker lists for a catalog row: `models` minus the ones hidden
+ * on the API Keys page (`saved`, when this window saved since, else the row's
+ * own list). `keep` (the current pick) stays listed even when hidden, so a
+ * session already on it still shows what it runs on.
+ */
+export function offeredModels(
+ row: { id: string; hidden_models?: string[] },
+ models: CuratedModel[],
+ keep = "",
+ saved: Record<string, string[]> | null = null,
+): CuratedModel[] {
+ const ids = saved ? saved[row.id] : row.hidden_models;
+ if (!ids?.length) return models;
+ const hidden = new Set(ids);
+ hidden.delete(keep);
+ const shown = models.filter((model) => !hidden.has(model.id));
+ return shown.length === models.length ? models : shown;
+}
+
/** `ids` added to (`on` = false) or taken out of (`on` = true) a list, order kept. */
export function toggled(list: readonly string[], ids: readonly string[], on: boolean): string[] {
const drop = new Set(ids);
diff --git a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
index de2d7f3814..5dfd10fe8d 100644
--- a/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
+++ b/jarvis/ui/web/frontend/src/views/apikeys/AgentsTab.tsx
@@ -31,6 +31,7 @@ import {
fetchAgentProviderPrefs,
saveAgentProviderPrefs,
toggled,
+ useSavedHiddenModels,
type AgentProviderPrefs,
} from "@/lib/agentProviderPrefs";
import {
@@ -116,6 +117,7 @@ function useAgentProviders(entriesFor: (prefs: AgentProviderPrefs) => FamilyAcce
try {
const saved = await saveAgentProviderPrefs(patch);
client.setQueryData(AGENT_PROVIDER_PREFS_KEY, saved);
+ useSavedHiddenModels.setState({ hidden: saved.hidden_models });
void client.invalidateQueries({ queryKey: SOCIETY_CATALOG_KEY });
void client.invalidateQueries({ queryKey: ["society", "providers"] });
const next = nextDefault(entriesFor(withPatch(prefs, saved)), primary, familyId);
diff --git a/jarvis/workspace/launch_picks.py b/jarvis/workspace/launch_picks.py
index 07cc752b1d..4f8fccb63f 100644
--- a/jarvis/workspace/launch_picks.py
+++ b/jarvis/workspace/launch_picks.py
@@ -508,18 +508,23 @@ def offered(agent: str, live: Mapping[str, list[dict[str, Any]]] | None = None)
Deliberately the shape of an agent-chat catalog row (``AgentChatProvider``
in the frontend): the IDE's chat composer is the front page's composer, so
handing it rows it already knows how to draw is what keeps the two
- surfaces from growing two different model pickers.
+ surfaces from growing two different model pickers. Models hidden on the
+ API Keys page are left out of the list; :func:`normalize_model` still
+ accepts them, so a pane already on one reopens on it.
"""
picks = picks_for(agent)
default_model = ""
+ models = offered_models(agent, live)
if picks is not None and picks.provider:
+ from jarvis.agent_chat import agent_provider_prefs
from jarvis.agent_chat.catalog import provider_row
row = provider_row(picks.provider)
if row is not None:
default_model = row.default_model
+ models = agent_provider_prefs.offered_models(picks.provider, models)
return {
- "models": offered_models(agent, live),
+ "models": models,
"default_model": default_model,
"effort_levels": list(effort_levels(agent)),
"default_effort": default_effort(agent),
diff --git a/tests/unit/agent_chat/test_agent_provider_prefs.py b/tests/unit/agent_chat/test_agent_provider_prefs.py
index 3d277dd913..8fb6b12bbd 100644
--- a/tests/unit/agent_chat/test_agent_provider_prefs.py
+++ b/tests/unit/agent_chat/test_agent_provider_prefs.py
@@ -1,5 +1,6 @@
"""The agents' provider choices: several seats on at once, models hidden,
-Claude set to its key — and only the agents' surface narrowed by them."""
+Claude set to its key — the on/off and the key choice narrowing the agents'
+surface only, the hidden models every model picker."""
from __future__ import annotations
@@ -60,6 +61,42 @@ def test_claude_on_its_key_changes_the_agents_surface_only(monkeypatch: pytest.M
assert service.resolve_runner("claude-api", surface="agent") == "claude-cli"
+def test_hidden_models_reach_every_surface_but_the_switch_only_the_agents() -> None:
+ from jarvis.ui.web.agent_chat_routes import _catalog_rows
+
+ surfaces = ("agent", "jarvis", "society")
+ before = {s: {r["id"]: r["curated_models"] for r in _catalog_rows(s, {})} for s in surfaces}
+
+ prefs_mod.save(
+ prefs_mod.parse({"disabled": ["openai"], "hidden_models": {"claude-api": ["opusplan"]}})
+ )
+
+ for surface in surfaces:
+ rows = {row["id"]: row for row in _catalog_rows(surface, {})}
+ assert rows["claude-api"]["hidden_models"] == ["opusplan"], surface
+ assert rows["openai"]["hidden_models"] == [], surface
+ # The list itself stays whole: the picker filters, and the API Keys
+ # page (which reads the same rows) still shows the switched-off model.
+ assert {k: r["curated_models"] for k, r in rows.items()} == before[surface], surface
+ agents = {row["id"]: row for row in _catalog_rows("society", {})}
+ assert agents["openai"]["enabled"] is False
+ assert all("enabled" not in row for row in _catalog_rows("agent", {}))
+
+
+def test_coding_panes_leave_hidden_models_out_but_still_launch_on_them() -> None:
+ from jarvis.workspace import launch_picks
+
+ every = [m["id"] for m in launch_picks.offered("claude")["models"]]
+ assert "opusplan" in every
+
+ prefs_mod.save(prefs_mod.parse({"hidden_models": {"claude-api": ["opusplan"]}}))
+
+ offered = [m["id"] for m in launch_picks.offered("claude")["models"]]
+ assert offered == [m for m in every if m != "opusplan"]
+ # A pane already on the model reopens on it: hiding only shortens the list.
+ assert launch_picks.normalize_model("claude", "opusplan") == "opusplan"
+
+
def test_the_page_route_merges_and_refuses_unknown_ids() -> None:
from fastapi import FastAPI
from fastapi.testclient import TestClient