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

fix: make base-model collapsing opt-in and persist only the effort that will run (review round 2)

[._.]/ Adam Eivyb6bc2b3f0526
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index cefdbc5161..20822dcac1 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -74,4 +74,4 @@
- **The "Pick from Gallery" picker could only be narrowed by typing, so finding one object in one universe meant recalling a word from its prompt.** It now carries two dropdowns beside the search box: a scope select that groups every universe and media collection under `<optgroup>`s, and a type select built from the `entryCategory`/`entryKind` tags the Universe Builder stamps onto sidecars, labelled through the same `humanizeCategory` the Builder uses. Those two are separate vocabularies — a user-authored bucket can legitimately be keyed `canon` — so the type options are prefixed by which field they filter and grouped under Categories/Entry kinds rather than flattened into one list where the bucket and the stage would silently match each other. All three filters AND-combine, and both dropdowns list only universes/collections/types that actually match an image currently in the picker — a scope that can only ever produce an empty grid isn't offered, and a selection that stops matching resets itself to "All" rather than silently blanking the grid. Collection membership is matched on the stored `{ kind, ref }` pair (the same `<kind>:<ref>` string `normalizeImage` puts on `item.key`), not on a bare filename, so a collection holding video refs alongside images filters correctly. Both option fetches are best-effort: if the collections or universes call fails the picker keeps working, falling back to the universe name stamped on each sidecar, and the fetched lists are dropped on close so a reopen can't filter fresh images against stale membership. Sidecars are unvalidated JSON that also arrive from peers, so a tag that isn't a usable string is skipped rather than crashing the render — which surfaced a latent bug in the shared `humanizeCategory`: its label lookup wasn't `hasOwn`-guarded, so a user-authored category keyed `constructor` or `toString` resolved to an inherited function and handed every caller a label that throws on the next string method (#3479).
-- **The Antigravity model dropdown made you pick your reasoning effort inside the model name.** `agy models` enumerates the effort tiers as separate ids (`gemini-3.6-flash-low|-medium|-high`), so there was no way to set the base model and the effort independently — and the Three.js Model Generator, which builds its own prompt-runner invocation, had no effort control at all. The pickers now list base models with the suffixes stripped and deduped, and `ProviderModelSelector` grows optional `effort`/`onEffortChange` props that render a "Thinking effort" select for the effort-capable providers (Antigravity, Claude, Codex) and nothing for the rest, so callers need no guard of their own. Verified against the real binary before building it: `agy` takes `--effort` as its own session flag and accepts the base id — but it validates the PAIR, erroring with `gemini-3.1-pro has no "medium" effort (available: low, high)`. So the tiers offered for an Antigravity model are derived from that provider's own catalog rather than assumed to be the full ladder, and an out-of-range effort clamps down to the nearest tier the model really has instead of producing an invocation agy rejects. A stored suffixed id — still what older installs and federated peers persist — splits into base plus `--effort`, the equivalent invocation, rather than being orphaned, and the picker seeds both controls from its two halves; one that somehow can't be split stays visible as its own option instead of blanking the select. Threading the effort down to `runPromptThroughProvider` also closed a gap on that path generally: it rides the provider clone the arg builders already read, and until now `buildCliArgs`/`buildTuiInvocation` emitted no effort flag at all for claude or codex there (#3480).
+- **The Antigravity model dropdown made you pick your reasoning effort inside the model name.** `agy models` enumerates the effort tiers as separate ids (`gemini-3.6-flash-low|-medium|-high`), so there was no way to set the base model and the effort independently — and the Three.js Model Generator, which builds its own prompt-runner invocation, had no effort control at all. `ProviderModelSelector` grows optional `effort`/`onEffortChange` props that render a "Thinking effort" select for the effort-capable providers (Antigravity, Claude, Codex) and nothing for the rest, so callers need no guard of their own; a picker that wires those also passes `withEffort` to `useProviderModels` and then lists base models with the suffixes stripped and deduped. That pairing is deliberate rather than a global rewrite: in a picker with no effort control the suffixed ids are the only way to express a tier, so collapsing them there would strip the capability instead of relocating it. Verified against the real binary before building it: `agy` takes `--effort` as its own session flag and accepts the base id — but it validates the PAIR, erroring with `gemini-3.1-pro has no "medium" effort (available: low, high)`. So the tiers offered for an Antigravity model are derived from that provider's own catalog rather than assumed to be the full ladder, and an out-of-range effort clamps down to the nearest tier the model really has instead of producing an invocation agy rejects. A stored suffixed id — still what older installs and federated peers persist — splits into base plus `--effort`, the equivalent invocation, rather than being orphaned, and the picker seeds both controls from its two halves; one that somehow can't be split stays visible as its own option instead of blanking the select. The effort the record stores is the one that will ACTUALLY run — resolved server-side against the provider and model before persisting — so a level left over from a previous selection can not be saved and rendered for a run that never used it. Threading the effort down to `runPromptThroughProvider` also closed a gap on that path generally: it rides the provider clone the arg builders already read, and until now `buildCliArgs`/`buildTuiInvocation` emitted no effort flag at all for claude or codex there (#3480).
diff --git a/client/src/hooks/useProviderModels.js b/client/src/hooks/useProviderModels.js
index 1db909fe40..459504347d 100644
--- a/client/src/hooks/useProviderModels.js
+++ b/client/src/hooks/useProviderModels.js
@@ -5,13 +5,16 @@ import { filterSelectableModels, isAntigravityProvider, selectableModelsForProvi
// The provider's selectable model source: its `models` list, or — when that
// list is empty (a cloud/manual provider configured with only a defaultModel,
// where `[]` is truthy so `||` wouldn't fall through) — its defaultModel.
-// `selectableModelsForProvider` then applies any provider-specific rewrite —
-// today that means Antigravity lists BASE models (`gemini-3.6-flash`) rather
-// than one row per baked-in effort tier, since effort is its own control now.
-const sourceModels = (provider) => selectableModelsForProvider(
- provider,
- provider?.models?.length ? provider.models : [provider?.defaultModel],
-);
+//
+// `withEffort` then applies any provider-specific rewrite — today that means
+// Antigravity lists BASE models (`gemini-3.6-flash`) rather than one row per
+// baked-in effort tier. It is OPT-IN because for a picker with no effort
+// control the suffixed ids are the ONLY way to express a tier: collapsing them
+// there would silently strip the capability rather than relocate it.
+const sourceModels = (provider, withEffort) => {
+ const models = provider?.models?.length ? provider.models : [provider?.defaultModel];
+ return withEffort ? selectableModelsForProvider(provider, models) : models;
+};
/**
* Hook for loading AI providers and managing two-step provider > model selection.
@@ -32,9 +35,16 @@ const sourceModels = (provider) => selectableModelsForProvider(
* set, the auto-selected / provider-change model is the first model that
* passes the filter rather than the provider's `defaultModel` (which may not
* qualify). Omit for the full selectable list.
+ * @param {boolean} [options.withEffort] - Set when the caller also renders an
+ * effort control (`ProviderModelSelector`'s `effort`/`onEffortChange`) and
+ * threads the value to the server. Providers whose CLI bakes the reasoning
+ * tier into the model id — Antigravity's `gemini-3.6-flash-low|-medium|-high`
+ * — then list BASE models instead, with effort picked separately. Leave off
+ * for a picker with no effort control: there the suffixed ids are the only
+ * way to express a tier, so collapsing them would strip the capability.
* @returns {{ providers, selectedProviderId, selectedModel, availableModels, selectedProvider, setSelectedProviderId, setSelectedModel, loading }}
*/
-export default function useProviderModels({ filter, allowDefault = false, silent = false, modelFilter } = {}) {
+export default function useProviderModels({ filter, allowDefault = false, silent = false, modelFilter, withEffort = false } = {}) {
const [providers, setProviders] = useState([]);
const [selectedProviderId, setSelectedProviderId] = useState('');
const [selectedModel, setSelectedModel] = useState('');
@@ -47,10 +57,10 @@ export default function useProviderModels({ filter, allowDefault = false, silent
// model that passes the filter instead.
const pickInitialModel = useCallback((provider) => {
if (!modelFilter) return provider?.defaultModel || '';
- const models = filterSelectableModels(sourceModels(provider))
+ const models = filterSelectableModels(sourceModels(provider, withEffort))
.filter((m) => modelFilter(m, provider));
return models[0] || '';
- }, [modelFilter]);
+ }, [modelFilter, withEffort]);
const load = useCallback(async () => {
setLoading(true);
@@ -88,7 +98,7 @@ export default function useProviderModels({ filter, allowDefault = false, silent
// sourceModels falls back to [defaultModel] when `models` is empty (an
// `[]` is truthy, so a bare `||` would leave the dropdown empty for a
// cloud/manual provider configured with only a defaultModel).
- const models = filterSelectableModels(sourceModels(currentProvider));
+ const models = filterSelectableModels(sourceModels(currentProvider, withEffort));
const filtered = modelFilter ? models.filter((m) => modelFilter(m, currentProvider)) : models;
// Legacy-pin escape hatch: a record saved before Antigravity switched to
// base models still holds `gemini-3.6-flash-high`, which now matches no
@@ -101,12 +111,13 @@ export default function useProviderModels({ filter, allowDefault = false, silent
// SUFFIX qualifies. A bare "not in the list" test would also re-surface
// the configured-default sentinel (the shipped agy `defaultModel`, which
// filterSelectableModels exists to hide) and any typo'd/stale pin.
- const staleAntigravityPin = isAntigravityProvider(currentProvider)
+ const staleAntigravityPin = withEffort
+ && isAntigravityProvider(currentProvider)
&& !!splitAntigravityModel(selectedModel).effort
&& !filtered.includes(selectedModel);
return staleAntigravityPin ? [...filtered, selectedModel] : filtered;
},
- [currentProvider, modelFilter, selectedModel]
+ [currentProvider, modelFilter, selectedModel, withEffort]
);
const handleProviderChange = useCallback((id) => {
diff --git a/client/src/hooks/useProviderModels.test.js b/client/src/hooks/useProviderModels.test.js
index 38e7d8e5d4..5e6b02ca0a 100644
--- a/client/src/hooks/useProviderModels.test.js
+++ b/client/src/hooks/useProviderModels.test.js
@@ -33,9 +33,11 @@ const CODEX = {
models: ['gpt-5', 'gpt-5-high'],
};
-const mountWith = async (providers) => {
+// `withEffort` is what opts a picker into base models — it declares that the
+// caller also renders an effort control, so the tiers aren't lost.
+const mountWith = async (providers, options = { withEffort: true }) => {
api.getProviders.mockResolvedValue({ providers });
- const hook = renderHook(() => useProviderModels());
+ const hook = renderHook(() => useProviderModels(options));
await waitFor(() => expect(hook.result.current.loading).toBe(false));
return hook;
};
@@ -76,4 +78,15 @@ describe('useProviderModels — Antigravity base models', () => {
// `gpt-5-high` is NOT an Antigravity id, so its `-high` is not a tier suffix.
expect(result.current.availableModels).toEqual(['gpt-5', 'gpt-5-high']);
});
+
+ it('keeps the per-tier ids for a picker with no effort control (the default)', async () => {
+ // Without an effort select, the suffixed ids are the ONLY way to pick a
+ // tier — collapsing them there would strip the capability, not relocate it.
+ const { result } = await mountWith([AGY], {});
+ expect(result.current.availableModels).toEqual([
+ 'gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low',
+ 'gemini-3.1-pro-high', 'gemini-3.1-pro-low',
+ 'claude-sonnet-4-6', 'gpt-oss-120b-medium',
+ ]);
+ });
});
diff --git a/client/src/pages/ThreejsModelDetail.jsx b/client/src/pages/ThreejsModelDetail.jsx
index 4f02f12c53..c5e2f5b8e6 100644
--- a/client/src/pages/ThreejsModelDetail.jsx
+++ b/client/src/pages/ThreejsModelDetail.jsx
@@ -41,7 +41,9 @@ export default function ThreejsModelDetail() {
setSelectedProviderId,
setSelectedModel,
loading: providersLoading,
- } = useProviderModels({ filter: providerFilter, silent: true });
+ // This picker renders the effort control and threads the value to the
+ // server, so Antigravity lists base models with effort picked separately.
+ } = useProviderModels({ filter: providerFilter, silent: true, withEffort: true });
const load = async ({ initial = false } = {}) => {
const next = await getThreejsModel(id, { silent: true }).catch((error) => {
diff --git a/server/services/threejsModels/index.js b/server/services/threejsModels/index.js
index e629a41f28..375441fbd0 100644
--- a/server/services/threejsModels/index.js
+++ b/server/services/threejsModels/index.js
@@ -9,6 +9,7 @@ import { PATHS, resolveGalleryImage } from '../../lib/fileUtils.js';
import { runPromptThroughProvider } from '../../lib/promptRunner.js';
import { extractJson } from '../../lib/jsonExtract.js';
import { buildThreejsFactorySource, threejsSculptSpecSchema } from '../../lib/threejsModel.js';
+import { resolveCliEffort } from '../../lib/providerModels.js';
import { getProviderById } from '../providers.js';
import { buildThreejsGenerationPrompt } from './prompt.js';
import * as store from './db.js';
@@ -168,7 +169,14 @@ export async function startGeneration(id, {
const effectivePrompt = prompt ?? current.prompt ?? '';
// Absent (`undefined`) keeps whatever the record already had; an explicit
// `null` — what the picker's "Default effort" choice sends — clears it.
- const effectiveEffort = effort === undefined ? (current.effort || null) : (effort || null);
+ const requestedEffort = effort === undefined ? (current.effort || null) : (effort || null);
+ // Persist what will ACTUALLY run, not what was asked for. The picker hides the
+ // effort control for a provider/model with no tiers but keeps its last value,
+ // so an unhonored level would otherwise be stored and rendered ("high effort")
+ // for a run that never used one — with no way to clear it. resolveCliEffort
+ // returns null for API/effort-less providers and clamps an out-of-range level
+ // to the tier the chosen model really has, matching the CLI arg builders.
+ const effectiveEffort = resolveCliEffort(requestedEffort, provider, model || provider.defaultModel || null);
const generationPrompt = buildThreejsGenerationPrompt({
sourcePath,
name: current.name,
diff --git a/server/services/threejsModels/index.test.js b/server/services/threejsModels/index.test.js
index f45064579e..1080b6de69 100644
--- a/server/services/threejsModels/index.test.js
+++ b/server/services/threejsModels/index.test.js
@@ -250,6 +250,38 @@ describe('Three.js model generation orchestration', () => {
expect(read().effort).toBe('medium');
});
+ it('drops an effort the resolved provider/model cannot honor instead of persisting a lie', async () => {
+ // The picker hides the effort control for a provider with no tiers but
+ // keeps its last value, so the request can still carry one.
+ getProviderById.mockResolvedValue({
+ id: 'vision-api', name: 'Vision API', type: 'api', enabled: true, defaultModel: 'vision-default',
+ });
+ const read = primeRecord({ providerId: 'vision-api' });
+
+ await startGeneration('threejs-effort', { providerId: 'vision-api', model: 'vision-pro', effort: 'high' });
+
+ await vi.waitFor(() => expect(read().status).toBe('ready'));
+ expect(runPromptThroughProvider).toHaveBeenCalledWith(expect.objectContaining({ effort: undefined }));
+ expect(read().effort).toBeNull();
+ });
+
+ it('persists the CLAMPED effort when the chosen agy model lacks that tier', async () => {
+ getProviderById.mockResolvedValue({
+ ...agyProvider,
+ models: ['gemini-3.1-pro-low', 'gemini-3.1-pro-high'],
+ });
+ const read = primeRecord({ model: 'gemini-3.1-pro' });
+
+ // agy rejects `--model gemini-3.1-pro --effort medium`, so it runs as low.
+ await startGeneration('threejs-effort', {
+ providerId: 'antigravity-cli', model: 'gemini-3.1-pro', effort: 'medium',
+ });
+
+ await vi.waitFor(() => expect(read().status).toBe('ready'));
+ expect(runPromptThroughProvider).toHaveBeenCalledWith(expect.objectContaining({ effort: 'low' }));
+ expect(read().effort).toBe('low');
+ });
+
it('clears the stored effort on an explicit null (the picker\'s "Default effort")', async () => {
getProviderById.mockResolvedValue(agyProvider);
const read = primeRecord({ effort: 'medium' });