diff --git a/services/platform/app/features/settings/providers/components/model-allowlist-field.test.tsx b/services/platform/app/features/settings/providers/components/model-allowlist-field.test.tsx
new file mode 100644
index 0000000000..13b7a69801
--- /dev/null
+++ b/services/platform/app/features/settings/providers/components/model-allowlist-field.test.tsx
@@ -0,0 +1,82 @@
+import { useState } from 'react';
+import { describe, expect, it } from 'vitest';
+
+import { checkAccessibility } from '@/tests/utils/a11y';
+import { render, screen } from '@/tests/utils/render';
+
+import { ModelAllowlistField } from './model-allowlist-field';
+
+/**
+ * The free-entry field keeps the reader's raw text (in-progress commas and
+ * all), but what it shows must always be the list it holds — the list a Save
+ * sends. A custom provider's form swaps ONE instance of this field between
+ * free entry and the catalog picker, so the picker can change the list while
+ * the free-entry draft is out of sight (#3664).
+ */
+
+function Harness({ initial }: { initial: string[] }) {
+ const [freeText, setFreeText] = useState(true);
+ const [value, setValue] = useState(initial);
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
+
+const field = () => screen.getByRole('textbox', { name: /^Model allowlist/ });
+const held = () => screen.getByRole('status', { name: 'Held list' });
+
+describe('ModelAllowlistField', () => {
+ it('shows the list the picker left when it returns to free entry', async () => {
+ const { container, user } = render();
+ expect(field()).toHaveValue('alpha, beta');
+
+ await user.click(screen.getByRole('button', { name: 'Switch source' }));
+ await user.click(screen.getByRole('button', { name: 'Remove alpha' }));
+ expect(held()).toHaveTextContent('["beta"]');
+ await user.click(screen.getByRole('button', { name: 'Switch source' }));
+
+ expect(field()).toHaveValue('beta');
+ expect(held()).toHaveTextContent('["beta"]');
+ await checkAccessibility(container);
+ });
+
+ it('keeps the reader’s draft, in-progress commas and all, while it holds the same list', async () => {
+ const { user } = render();
+ await user.type(field(), 'alpha, beta,');
+ expect(field()).toHaveValue('alpha, beta,');
+ expect(held()).toHaveTextContent('["alpha","beta"]');
+
+ // A trip through the picker that changes nothing leaves the draft alone.
+ await user.click(screen.getByRole('button', { name: 'Switch source' }));
+ await user.click(screen.getByRole('button', { name: 'Switch source' }));
+ expect(field()).toHaveValue('alpha, beta,');
+
+ await user.type(field(), ' gamma');
+ expect(field()).toHaveValue('alpha, beta, gamma');
+ expect(held()).toHaveTextContent('["alpha","beta","gamma"]');
+ });
+
+ it('shows a list replaced from outside, then edits on from it', async () => {
+ const { user } = render();
+ await user.click(screen.getByRole('button', { name: 'Replace list' }));
+ expect(field()).toHaveValue('gamma');
+
+ await user.type(field(), ', delta');
+ expect(field()).toHaveValue('gamma, delta');
+ expect(held()).toHaveTextContent('["gamma","delta"]');
+ });
+});
diff --git a/services/platform/app/features/settings/providers/components/model-allowlist-field.tsx b/services/platform/app/features/settings/providers/components/model-allowlist-field.tsx
index 3747f77e0f..61470d183c 100644
--- a/services/platform/app/features/settings/providers/components/model-allowlist-field.tsx
+++ b/services/platform/app/features/settings/providers/components/model-allowlist-field.tsx
@@ -23,6 +23,10 @@ interface ModelAllowlistFieldProps {
disabled?: boolean;
}
+/** Whether two allowlists hold the same ids in the same order. */
+export const sameList = (a: readonly string[], b: readonly string[]) =>
+ a.length === b.length && a.every((id, index) => id === b[index]);
+
/** Comma-separated ids → trimmed, deduplicated list. */
function parseFreeTextIds(raw: string): string[] {
const seen = new Set();
@@ -49,9 +53,14 @@ export function ModelAllowlistField({
}: ModelAllowlistFieldProps) {
const { t } = useT('settings');
// Free-text drafts keep the raw string (in-progress commas and all) and
- // push the parsed list up on every change. The dialogs unmount this field
- // on close, so the draft can never go stale against a reopened form.
- const [text, setText] = useState(value.join(', '));
+ // push the parsed list up on every change. The draft is shown only while
+ // it still holds `value`: a custom provider's form keeps this one field
+ // across its Models choice, so the picker can change the list while the
+ // draft is out of sight — the field then shows the list a Save sends.
+ const [draft, setDraft] = useState(value.join(', '));
+ const text = sameList(parseFreeTextIds(draft), value)
+ ? draft
+ : value.join(', ');
const options = useMemo(() => {
const catalogIds = new Set(models.map((model) => model.id));
@@ -70,7 +79,7 @@ export function ModelAllowlistField({
placeholder={t('providers.dialog.allowlistFreeTextPlaceholder')}
value={text}
onChange={(e) => {
- setText(e.target.value);
+ setDraft(e.target.value);
onValueChange(parseFreeTextIds(e.target.value));
}}
disabled={disabled}
diff --git a/services/platform/app/features/settings/providers/components/providers-settings.test.tsx b/services/platform/app/features/settings/providers/components/providers-settings.test.tsx
index 02138cef3d..940ed5a07b 100644
--- a/services/platform/app/features/settings/providers/components/providers-settings.test.tsx
+++ b/services/platform/app/features/settings/providers/components/providers-settings.test.tsx
@@ -1096,5 +1096,49 @@ describe('ProvidersSettings', () => {
'The provider changed since it was loaded. Reopen the dialog and try again.',
);
});
+
+ it('shows back in manual entry the model ids Save sends after discovery removed one', async () => {
+ fixtures.catalogs = [
+ anthropicProvider,
+ { ...customVendor, catalogSource: 'none', models: [] },
+ ];
+ fixtures.credentials = [
+ { ...customCredential, modelAllowlist: ['alpha', 'beta'] },
+ ];
+ updateCredential.mockResolvedValue(null);
+ const { user } = renderPage();
+ await user.click(
+ screen.getByRole('button', { name: 'Actions for Qwen CN' }),
+ );
+ await user.click(
+ within(await screen.findByRole('menu')).getByRole('menuitem', {
+ name: 'Edit credential',
+ }),
+ );
+ const dialog = within(
+ await screen.findByRole('dialog', { name: 'Edit credential' }),
+ );
+ const ids = () =>
+ dialog.getByRole('textbox', { name: /^Model allowlist/ });
+ expect(ids()).toHaveValue('alpha, beta');
+
+ await user.click(
+ dialog.getByRole('radio', { name: /Discover from the endpoint/ }),
+ );
+ await user.click(dialog.getByRole('button', { name: 'Remove alpha' }));
+ await user.click(dialog.getByRole('radio', { name: /Enter model IDs/ }));
+ // The field says what the Save below sends, not what it opened with.
+ expect(ids()).toHaveValue('beta');
+
+ await user.click(dialog.getByRole('button', { name: 'Save' }));
+ await waitFor(() =>
+ expect(updateCredential).toHaveBeenCalledWith(
+ expect.objectContaining({
+ modelAllowlist: ['beta'],
+ customProvider: expect.objectContaining({ catalogSource: 'none' }),
+ }),
+ ),
+ );
+ });
});
});
diff --git a/services/platform/app/features/settings/providers/credential-adapter.tsx b/services/platform/app/features/settings/providers/credential-adapter.tsx
index 39ba0093d7..564d5357ac 100644
--- a/services/platform/app/features/settings/providers/credential-adapter.tsx
+++ b/services/platform/app/features/settings/providers/credential-adapter.tsx
@@ -26,7 +26,10 @@ import {
isBrokerDraftComplete,
type BrokerDraft,
} from './components/broker-form';
-import { ModelAllowlistField } from './components/model-allowlist-field';
+import {
+ ModelAllowlistField,
+ sameList,
+} from './components/model-allowlist-field';
import {
CUSTOM_VENDOR_KEY,
emptyCustomProviderFacts,
@@ -242,9 +245,6 @@ export interface ProviderCredentialExtras {
reviewed?: ReviewedVersions;
}
-const sameList = (a: readonly string[], b: readonly string[]) =>
- a.length === b.length && a.every((id, index) => id === b[index]);
-
const sameFacts = (a: CustomProviderFacts, b: CustomProviderFacts) =>
a.apiFormat === b.apiFormat &&
a.baseUrl === b.baseUrl &&
diff --git a/services/platform/tests/manual/reference/automation.md b/services/platform/tests/manual/reference/automation.md
index f6b9d16e4c..ba67be5da2 100644
--- a/services/platform/tests/manual/reference/automation.md
+++ b/services/platform/tests/manual/reference/automation.md
@@ -150,7 +150,7 @@ Legend: ✅ fully automated · 🔶 partially automated · ⛔ manual-only (no s
| [projects](../suites/projects.md) | Project-agent model search accepts the API model ID as well as the display name and provider, and saves the selected provider/model pair | ✅ component | `app/features/projects/components/project-agent-dialog.test.tsx` |
| [projects](../suites/projects.md) | `PROJ-F35`'s catalog lifecycle: a project that cannot see a document skill gets only the ones it can; a default unticked by hand stays unticked when the catalog refreshes and returns on reopening; a catalog that loaded with no document skills adds none when it later refreshes; defaults wait for the first `listProjectCapabilities` answer and keep equipment picked while it loads; an edited agent never gains defaults; navigating to another project or organization closes an open create or edit form | ✅ component | `app/features/projects/components/project-agent-dialog.test.tsx`, `app/routes/dashboard/$id/projects/$projectId/agents.test.tsx`; `lib/shared/config/document-skills-catalog.test.ts` holds the slugs to the builtin catalog |
| [projects](../suites/projects.md) | REST project tasks, threads, files, installed automations, runs and token webhooks: path isolation, member/editor roles, archived-project refusals, strict bodies, MCP access and opaque private resources | ✅ automated | `backend/rest/project-scope-check.ts` (the real HTTP/Postgres checks — including the `Idempotency-Key` replay, reuse and concurrent pair, the run delete, and the webhook door's one 403 — plus concurrent archive/queued-turn checks in `checkRestProjectAgents`), `backend/rest/v1-tasks.test.ts`, `backend/rest/v1-threads.scope.test.ts`, `backend/rest/v1-automations.project-scope.test.ts`, `backend/rest/v1-automations.contract.test.ts` (version reads, run summaries with `status`/`include`/cursor, `Idempotency-Key`, run delete), `backend/domains/automations/triggers.webhook.test.ts` (the 403 collapse, statuses by code, the sender and trigger budgets), `backend/domains/automations/store.idempotent-start.test.ts`, `backend/domains/automations/store.delete-run.test.ts`, `lib/shared/event-types.test.ts` (an event trigger binds only an event a producer raises), `backend/rest/v1-core.contract.test.ts` (knowledge scope), `backend/domains/chat/store.test.ts` (queued-turn scope) |
-| [settings](../suites/settings.md) | `SET-F43` custom providers from the credential dialog: the pinned entry survives the search, the setup step collects the provider's facts beside the key and refuses to submit without a base URL (or without model ids in manual mode), the composition writes the definition first and rolls it back when the credential is refused, an organization-defined provider's credential saves the facts and itself in one write against the hashes the dialog read (the listing carries the definition's, the dialog seeds both when it opens), and a refused name or a newer definition or credential writes neither, its last credential retires the provider (dialog warning + server cascade), and the model check reports the count; the backend refuses reserved names and disallowed hosts, archives the preimage, flags `origin`, and fetches a custom provider's listing with the organization's key and serves a bare OpenAI-style `/models` listing (id only) under the assumed 128k window | ✅ component + backend | `app/features/settings/providers/components/providers-settings.test.tsx`, `app/features/settings/providers/hooks/custom-provider-mutations.test.tsx`, `app/features/settings/credentials/credential-edit-dialog.test.tsx`, `app/features/settings/providers/components/provider-definition-form.test.ts`, `backend/domains/providers/config-routes.test.ts`, `backend/domains/provider_credentials/custom-provider-edit.test.ts`, `backend/domains/provider_credentials/routes.with-definition.test.ts`, `backend/domains/configuration-writes.test.ts`, the `checkCustomProviderCredentialEdit` lane of `backend:integration` (real-Postgres rollback and committed-save readback after an injected lost acknowledgement), `backend/core/lib/providers/catalog_fetch.test.ts`, `lib/shared/providers/catalog_normalize.test.ts`, `backend/core/lib/providers/chat_catalog.test.ts`; the live endpoint listing, the picker after a reload, the archived history file and `SET-B21`'s two tabs stay manual |
+| [settings](../suites/settings.md) | `SET-F43` custom providers from the credential dialog: the pinned entry survives the search, the setup step collects the provider's facts beside the key and refuses to submit without a base URL (or without model ids in manual mode), shows in manual mode the model ids a Save sends after a switch through discovery changed them (#3664), the composition writes the definition first and rolls it back when the credential is refused, an organization-defined provider's credential saves the facts and itself in one write against the hashes the dialog read (the listing carries the definition's, the dialog seeds both when it opens), and a refused name or a newer definition or credential writes neither, its last credential retires the provider (dialog warning + server cascade), and the model check reports the count; the backend refuses reserved names and disallowed hosts, archives the preimage, flags `origin`, and fetches a custom provider's listing with the organization's key and serves a bare OpenAI-style `/models` listing (id only) under the assumed 128k window | ✅ component + backend | `app/features/settings/providers/components/providers-settings.test.tsx`, `app/features/settings/providers/components/model-allowlist-field.test.tsx`, `app/features/settings/providers/hooks/custom-provider-mutations.test.tsx`, `app/features/settings/credentials/credential-edit-dialog.test.tsx`, `app/features/settings/providers/components/provider-definition-form.test.ts`, `backend/domains/providers/config-routes.test.ts`, `backend/domains/provider_credentials/custom-provider-edit.test.ts`, `backend/domains/provider_credentials/routes.with-definition.test.ts`, `backend/domains/configuration-writes.test.ts`, the `checkCustomProviderCredentialEdit` lane of `backend:integration` (real-Postgres rollback and committed-save readback after an injected lost acknowledgement), `backend/core/lib/providers/catalog_fetch.test.ts`, `lib/shared/providers/catalog_normalize.test.ts`, `backend/core/lib/providers/chat_catalog.test.ts`; the live endpoint listing, the picker after a reload, the archived history file and `SET-B21`'s two tabs stay manual |
| [settings](../suites/settings.md) | `SET-F61` (Automation alerts): offered to owners and admins only, a flip saves `automationAlerts`, and the preferences door persists it | 🔶 component + route | `app/features/settings/notifications/components/notification-preferences-settings.test.tsx`, `backend/domains/collab/routes.test.ts`; the state after a reload remains manual |
| [settings](../suites/settings.md) | `SET-B11` (REST model discovery) | 🔶 backend | `backend/rest/v1-threads.contract.test.ts`, `backend/rest/v1-threads.test.ts` — org/user scoping, empty catalog, credential-free response, provider forwarded; live provider response stays manual |
| [knowledge](../suites/knowledge.md) | Product details dialog (`products.view.title`); writers get **Edit** in the header which opens **Edit product**. Copyable product ID | ✅ automated | `app/features/products/components/products-table.test.tsx`, `product-view-dialog.test.tsx` |