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: scope Default/tier model selects to a provider's Model Access policy

[._.]/ Adam Eivye9ed40fd0bf5
diff --git a/client/src/components/providers/ProviderForm.jsx b/client/src/components/providers/ProviderForm.jsx
index 04e336dcd2..a1a0078a1f 100644
--- a/client/src/components/providers/ProviderForm.jsx
+++ b/client/src/components/providers/ProviderForm.jsx
@@ -21,7 +21,7 @@ import useDrawerTab from '../../hooks/useDrawerTab';
import { FormField } from '../ui/FormField';
import { GatewayKeyHint } from './ProviderNotices';
import ProviderModelAccess from './ProviderModelAccess';
-import { CONFIGURED_MODEL_KEYS, configuredModelsOf, normalizeModelAccess, providerModelCatalog } from '../../utils/providerModelAccess';
+import { CONFIGURED_MODEL_KEYS, configuredModelsOf, normalizeModelAccess, providerModelCatalog, scopeModelsByAccess } from '../../utils/providerModelAccess';
// The provider editor's Drawer tabs. `connection` is the default, so a bare
// /ai/edit/:providerId deep link opens on the identity/transport fields; the
@@ -198,9 +198,18 @@ export default function ProviderForm({ provider, daemonReadiness = null, onClose
...liveHardwareFor(formData),
},
}, daemonReadiness?.contextWindows), daemonReadiness?.runtimeContextWindow);
- const availableModels = filterHardwareCompatibleProviderModels(
- filterGenerationModels(mergedModels),
- capabilityProvider,
+ // Scoped by the same Model Access policy `ProviderModelAccess` previews above,
+ // so the Default Model + tier selects can't offer a model the policy hides —
+ // they used to read straight off `mergedModels` and ignore the policy entirely.
+ // `keep` preserves an already-configured tier's model even if the (possibly
+ // just-edited) policy would now exclude it, matching the editor's own preview.
+ const availableModels = scopeModelsByAccess(
+ filterHardwareCompatibleProviderModels(
+ filterGenerationModels(mergedModels),
+ capabilityProvider,
+ ),
+ normalizeModelAccess(formData.modelAccess),
+ { keep: modelAccessKeeps },
);
const configuredModels = [
formData.defaultModel,
diff --git a/client/src/components/providers/ProviderForm.test.jsx b/client/src/components/providers/ProviderForm.test.jsx
index b622b9c700..9640a0c165 100644
--- a/client/src/components/providers/ProviderForm.test.jsx
+++ b/client/src/components/providers/ProviderForm.test.jsx
@@ -337,6 +337,25 @@ describe('ProviderForm model access', () => {
expect(screen.getByText(/No patterns yet/)).toBeInTheDocument();
});
+ // The Default Model select used to be built from the raw catalog, ignoring
+ // the policy the "Catalog" checklist right above it already enforces — so a
+ // provider scoped to one model still offered the hidden one as the default.
+ it('scopes the Default Model select to the model access policy', () => {
+ renderForm({ provider: scopedProvider });
+ switchTab('Models');
+ const defaultModelSelect = screen.getByLabelText('Default Model');
+ const optionValues = Array.from(defaultModelSelect.options).map(o => o.value);
+ expect(optionValues).toContain('meta/llama-3.3-70b-instruct');
+ expect(optionValues).not.toContain('nvidia/nemotron-4-340b-instruct');
+ });
+
+ it('keeps an already-configured default model selectable even if the policy now hides it', () => {
+ renderForm({ provider: { ...scopedProvider, defaultModel: 'nvidia/nemotron-4-340b-instruct' } });
+ switchTab('Models');
+ const defaultModelSelect = screen.getByLabelText('Default Model');
+ expect(defaultModelSelect).toHaveValue('nvidia/nemotron-4-340b-instruct');
+ });
+
// #7565: a DERIVED preset says where its connection comes from; a legacy one
// the server reports convertible offers the one-click conversion and closes
// through onSave like any other save. Neither appears on a new record.
diff --git a/client/src/utils/providerModelAccess.js b/client/src/utils/providerModelAccess.js
index 99bcf61ecb..a5edd40c05 100644
--- a/client/src/utils/providerModelAccess.js
+++ b/client/src/utils/providerModelAccess.js
@@ -32,6 +32,9 @@ export {
// What the form submits, and what the catalog list marks as glob-covered.
normalizeModelAccess,
modelMatchesAccessPatterns,
+ // The scoping primitive itself, so other model pickers (Default Model, tier
+ // selects) can apply the same policy the editor already previews.
+ scopeModelsByAccess,
} from '../../../server/lib/aiToolkit/internal/modelAccess.js';
/** How each mode reads in the editor. Ordered as the mode selector renders them. */