Skip to content

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

address review (claude): make the model-refresh mirror faithful

Adam Eivy0b74e8236789
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index e3e9a3f400..800f94a872 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -125,6 +125,20 @@ export const isAntigravityProvider = (provider) => {
*/
export const isCursorCommand = (command) => commandBasename(command) === 'cursor-agent';
+/**
+ * True when a command points at the Antigravity binary. MIRROR of
+ * `isAntigravityCommand` in server/lib/aiToolkit/internal/antigravity.js — keep
+ * in lockstep. Distinct from {@link isAntigravityProvider}, which also matches
+ * the shipped provider IDs: the server's model-refresh dispatch tests the
+ * COMMAND alone on its TUI arm, so mirroring that needs the narrower predicate.
+ * @param {string|null|undefined} command
+ * @returns {boolean}
+ */
+export const isAntigravityCommand = (command) => {
+ const base = commandBasename(command);
+ return base === 'agy' || base === 'antigravity';
+};
+
/**
* Whether the AI Providers page should offer a "Refresh Models" button for this
* provider — i.e. whether the server has a model fetcher that can answer for it.
@@ -140,34 +154,40 @@ export const isCursorCommand = (command) => commandBasename(command) === 'cursor
* @returns {boolean}
*/
export const supportsModelRefresh = (provider) => {
- // Claude Ollama (ollama-backed claude CLI/TUI) refreshes its model list from
- // the local Ollama daemon — including the TUI variant, which the server
- // refreshes via the type==='tui' && ollamaBacked branch. Check this before
- // the generic TUI gate so the TUI variant's Refresh Models button shows.
- if (isOllamaBackedProvider(provider)) return true;
- // Antigravity (`agy`) exposes a per-session `--model` flag and an
- // `agy models` catalog, so BOTH its CLI and TUI providers refresh (the
- // server has a type==='tui' branch for it) — checked before the generic
- // TUI gate, same as Claude Ollama above.
- if (isAntigravityProvider(provider)) return true;
- // Every other TUI's model is fixed by the CLI/config — no branch server-side.
- if (isTuiProvider(provider)) return false;
- // API providers all route to _refreshAPIProviderModels.
- if (isApiProvider(provider)) return true;
- // CLI: the server's `_refreshCLIProviderModels` has exactly two remaining
- // fetchers past the ollama/antigravity branches above — Anthropic and Gemini —
- // and THROWS for everything else. So this is an allowlist, not a deny-list.
- //
- // It used to be written as a deny-list (`command === 'gemini' || 'grok'`,
- // plus cursor), which reported true for `codex` and `kimi-cli` — two providers
- // that ship in the seed and whose Refresh button therefore 404'd on every
- // click. It also matched on the exact command string, so a path-configured
- // `/opt/homebrew/bin/gemini` fell through to true and 404'd too. Matching the
- // server's own name-or-command test (basename-tolerant) fixes both.
+ // Mirrors `refreshProviderModels`, which routes on `provider.type` FIRST and
+ // only then applies per-vendor tests — so this follows the same two-level
+ // shape. It is an ALLOWLIST: the server throws for any CLI it has no fetcher
+ // for. Written as a deny-list previously, it returned true for `codex` and
+ // `kimi-cli` (both shipped), whose Refresh button 404'd on every click.
const name = String(provider?.name || '').toLowerCase();
- const command = commandBasename(provider?.command);
- return name.includes('claude') || command === 'claude'
- || name.includes('gemini') || command === 'gemini';
+ const command = provider?.command;
+
+ // Every API provider routes to _refreshAPIProviderModels.
+ if (isApiProvider(provider)) return true;
+
+ if (isTuiProvider(provider)) {
+ // A TUI's model is normally fixed by the CLI/config; the server carries
+ // exactly two exceptions, and — unlike its CLI arm — neither consults the
+ // provider NAME, so this must not either.
+ return isOllamaBackedProvider(provider)
+ || provider?.id === 'antigravity-tui'
+ || isAntigravityCommand(command);
+ }
+
+ if (isCliProvider(provider)) {
+ if (isOllamaBackedProvider(provider)) return true;
+ if (name.includes('antigravity') || isAntigravityCommand(command)) return true;
+ // Deliberately the RAW command string, not a basename: the server's claude
+ // and gemini arms compare `provider.command === 'claude'` exactly. Matching
+ // on basename here would re-open the same 404 in a new place — a renamed,
+ // path-configured `/opt/homebrew/bin/claude` would show a button the server
+ // still refuses. Widening BOTH sides is tracked separately; until then the
+ // mirror stays faithful rather than optimistic.
+ return name.includes('claude') || command === 'claude'
+ || name.includes('gemini') || command === 'gemini';
+ }
+
+ return false;
};
export const knownProviderContextWindow = (provider) => {
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index db64b94132..73a284b368 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -36,6 +36,7 @@ import {
isKimiProvider,
isCodexProvider,
isCursorCommand,
+ isAntigravityCommand,
supportsModelRefresh,
isAntigravityProvider,
effortLevelsForProvider,
@@ -60,6 +61,7 @@ import {
seedModelEffort,
} from './providers.js';
import { PROVIDER_TYPES as SERVER_PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';
+import SHIPPED_PROVIDERS from '../../../data.reference/providers.json';
import {
effortLevelsForProvider as serverEffortLevelsForProvider,
isAntigravityProvider as serverIsAntigravityProvider,
@@ -756,12 +758,23 @@ describe('supportsModelRefresh', () => {
expect(supportsModelRefresh({ id: 'grok-cli', type: 'cli', command: 'grok', name: 'Grok Build CLI' })).toBe(false);
});
- // Regression: the old clause compared the exact command string, so a
- // path-configured binary fell through to true and 404'd.
- it('is basename-tolerant, matching the server test', () => {
- expect(supportsModelRefresh({ id: 'g', type: 'cli', command: '/opt/homebrew/bin/gemini', name: 'g' })).toBe(true);
- expect(supportsModelRefresh({ id: 'c', type: 'cli', command: '/opt/homebrew/bin/claude', name: 'c' })).toBe(true);
- expect(supportsModelRefresh({ id: 'k', type: 'cli', command: '/opt/homebrew/bin/kimi', name: 'k' })).toBe(false);
+ // The server's claude/gemini arms compare the RAW command string, so this
+ // must too — a basename-tolerant client would show a button on a renamed,
+ // path-configured binary that the server still refuses, which is the same
+ // 404 in a new place. (Widening both sides is tracked separately.)
+ it('matches the server on the raw command string, not a basename', () => {
+ expect(supportsModelRefresh({ id: 'c', type: 'cli', command: 'claude', name: 'renamed' })).toBe(true);
+ expect(supportsModelRefresh({ id: 'c', type: 'cli', command: '/opt/homebrew/bin/claude', name: 'renamed' })).toBe(false);
+ // A name carrying the vendor word is the server's other accepted signal.
+ expect(supportsModelRefresh({ id: 'c', type: 'cli', command: '/opt/homebrew/bin/claude', name: 'Claude Code CLI' })).toBe(true);
+ });
+
+ // Antigravity is the one vendor the server matches by NAME on its CLI arm but
+ // NOT on its TUI arm — mirror that asymmetry or the button drifts either way.
+ it('mirrors the antigravity name/command asymmetry between cli and tui', () => {
+ expect(supportsModelRefresh({ id: 'x', type: 'cli', command: '/usr/bin/weird', name: 'Antigravity Nightly' })).toBe(true);
+ expect(supportsModelRefresh({ id: 'x', type: 'tui', command: '/usr/bin/weird', name: 'Antigravity Nightly' })).toBe(false);
+ expect(supportsModelRefresh({ id: 'x', type: 'tui', command: '/opt/bin/agy', name: 'whatever' })).toBe(true);
});
it('still offers it for the providers the server CAN fetch for', () => {
@@ -778,6 +791,40 @@ describe('supportsModelRefresh', () => {
expect(() => supportsModelRefresh(null)).not.toThrow();
expect(() => supportsModelRefresh(undefined)).not.toThrow();
});
+
+ // The real lockstep gate: walk the SHIPPED catalog and compare this predicate
+ // against a transcription of the server's own dispatch. Targeted cases above
+ // can only cover the mismatches someone already thought of; this catches the
+ // next provider added to the seed without a matching client branch, which is
+ // exactly how codex and kimi-cli ended up with a button that 404'd.
+ it('agrees with the server dispatch for every shipped provider', () => {
+ // Transcribed from `refreshProviderModels` + `_refreshCLIProviderModels`
+ // (server/lib/aiToolkit/providers.js). Note the type-routing order and that
+ // the tui arm does NOT consult the provider name.
+ const serverWouldRefresh = (p) => {
+ const name = String(p.name || '').toLowerCase();
+ if (p.type === 'api') return true;
+ if (p.type === 'cli') {
+ if (isOllamaBackedProvider(p)) return true;
+ if (name.includes('claude') || p.command === 'claude') return true;
+ if (name.includes('antigravity') || isAntigravityCommand(p.command)) return true;
+ if (name.includes('gemini') || p.command === 'gemini') return true;
+ return false; // server throws → route 404s
+ }
+ if (p.type === 'tui' && isOllamaBackedProvider(p)) return true;
+ if (p.type === 'tui' && (p.id === 'antigravity-tui' || isAntigravityCommand(p.command))) return true;
+ return false;
+ };
+
+ const providers = Object.values(SHIPPED_PROVIDERS.providers);
+ expect(providers.length).toBeGreaterThan(20);
+ for (const p of providers) {
+ expect(
+ supportsModelRefresh(p),
+ `${p.id}: client and server disagree on model-refresh support`,
+ ).toBe(serverWouldRefresh(p));
+ }
+ });
});
describe('isCursorCommand (mirror of server lib/cursor.js)', () => {