Repository navigation
fix(ui): saving a provider key says when the model policy hides its models - #189917
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesAfter saving a provider key, Models settings warns when model policy hides every model from that provider. Example: Save a Particle key while the selected agent's model policy allows only openai/*.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused repair still missing from main; the latest head resolves the previous policy-scope finding, and no new blocking defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherModels settings saves credentials through the existing mutation owner, refreshes provider data, then consumes Gateway-owned model visibility flags to display feedback. flowchart TD
A[Provider key dialog] --> B[Credential mutation owner]
B --> C[Gateway credential save]
C --> D[Provider refresh]
D --> E[Provider scoped model catalog]
E --> F[Policy warning or dialog close]
Technical reviewBest possible solution: Keep the Gateway as the visibility owner and present its provider-specific policy result through the existing saved-key warning path. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the silent-close path under a restrictive model policy, and inspected browser screenshots demonstrate the presentation difference with mocked catalog responses; this read-only review ran no reproduction. Is this the best way to solve the issue? The patch is appropriately small: it consumes existing Gateway visibility flags, preserves discovery-warning precedence and mutation settlement, and adds no competing policy implementation or persisted state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 418bb925ca47. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +42. Total +65 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 31, 2026, 10:07 PM ET / November 1, 2026, 02:07 UTC (Revision 2). |
…ning Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in afe8191. Bug: saving a provider key closed the dialog silently when the model policy hid every model of that provider. Fix: after the save, the page reads the Gateway's per-model policy marks for that provider and keeps the dialog open with a warning that names both policy levels. Proof: focused page tests (35 passed, both new cases fail with the fix reverted), mocked-Gateway before/after screenshots, green CI and ClawSweeper ready on 58b3200. |
…odels (openclaw#189917) ## What Problem This Solves Fixes: saving an API key in **Settings → Models → Connect provider** succeeds silently when `agents.defaults.modelPolicy.allow` hides every model of that provider, so the provider never appears in the model picker and nothing says why. ## User Impact User impact: after the key saves, the dialog stays open and says that the model policy hides the provider's models, with the `provider/*` entry to add: to `agents.entries.<agent>.modelPolicy.allow` when the selected agent sets its own policy (it replaces the default), otherwise to `agents.defaults.modelPolicy.allow`. Saves for providers the policy allows close the dialog as before. ## Why This Change Was Made The Gateway already decides policy visibility: `models.list` with `view: "all"` marks each model `manualSelectionAllowed` from the agent's model policy. After a successful key save, the provider page reads that list for the saved provider and warns only when the Gateway marks every model hidden. The UI does not match allowlist patterns itself. `models.list` does not say which config level owns the policy, so the warning names both instead of adding a protocol field. The warning uses the existing post-save warning path, which already keeps the dialog open for discovery failures. ## Evidence Mocked-Gateway Control UI run of the real dialog flow (policy `allow: ["openai/*"]`, save a Particle key; `models.list view=all provider=particle` returns `manualSelectionAllowed: false`): Before (main): the dialog closes with no explanation.  After: the dialog stays open with the policy warning.  - `pnpm test ui/src/pages/model-providers/model-providers-page.test.ts --maxWorkers=1`: 35 passed, 1.8 s wall. The new cases check the warning when every model is hidden and no warning when one model is allowed; both fail with the fix reverted. - Gateway side is existing coverage: `src/gateway/server-methods/models.prepared.test.ts` publishes `modelPolicy.allow: ["test/first"]` and checks `view: "all"` marks other models `manualSelectionAllowed: false`. - `pnpm check:changed` (dead-code skipped) and `pnpm ui:i18n:verify` pass. - No overlap with Pash/Sarah changes. Merge danger: two-way door. UI-only; a revert restores the silent close. Blast radius: the Models settings key dialogs (add and edit) gain one extra `models.list` read per successful save; a failure of that read shows as a warning, not a failed save. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…#190019) ## What Problem This Solves Adding a provider did not make it usable when a model allowlist (`modelPolicy.allow`) existed. On the Team server, saving a Particle API key in **Settings → Models → Connect provider** succeeded, but no Particle model appeared in the model picker: the allowlist hid them all. Sign-in flows (CLI, chat `/login`, Telegram, Control UI wizard) asked **Show all <Provider> models / Keep current restrictions** with Keep as the default. The API-key save path skipped even that, and #189917 only added a text warning that told the user to edit config by hand. ## Fix Saving credentials for a provider is now the request to use its models. When the allowlist that governs the agent hides **every** model of that provider, the save adds `<provider>/*` to that allowlist, through the existing model-policy owner (`src/commands/models/auth-model-policy.ts`): - per-agent `agents.entries.<id>.modelPolicy.allow` when the agent sets its own policy, otherwise `agents.defaults.modelPolicy.allow`; - an unmigrated legacy `agents.defaults.models` allowlist gets the wildcard key, so none of its models is dropped. Nothing changes when there is no allowlist, or when the allowlist already names some of the provider's models (an exact ref such as `openai/gpt-x`, or a narrower wildcard such as `clawrouter/anthropic/*`). The policy owner decides that: the check reads providers from `createModelVisibilityPolicy(...).allowedKeys`, which resolves exact refs, aliases and bare legacy refs (inferring their provider from configured provider rows) the same way the picker does. A deliberate exact list is never widened. Paths: - API key / token save (`models.authSetApiKey`, `openclaw models auth paste-api-key`, `paste-token`): the wildcard is added in the same config write as the credential's auth profile. - Sign-in (`openclaw models auth login`, Control UI wizard, chat `/login`, Telegram `/login`): after the credential is saved, one write adds the wildcard. The login result carries `modelAccess: { message, applied }`; chat and Telegram append "Added `<provider>/*` to allowed models." to the completion message; the Control UI wizard reports an unconfirmed apply as before. Removed: the post-save select prompt, the deferred `onModelAccessRequested` request, `offerProviderLoginModelAccess` / `answerProviderLoginModelAccess`, the `/login access` and `/login choice` model-access commands, `createLoginChoicePrompt`, `ProviderModelPolicyChangedError`, and the #189917 Control UI warning. `provider-auth-login-flow-runtime` is a private-local SDK subpath (docs/plugins/sdk-subpaths.md), so its only consumers are bundled (core chat `/login`, Telegram), migrated here. Authority: every `models.authSetApiKey` save now checks live requester authority (`readGatewayRequestMutationAuthority`, the guard `config.patch` uses) before its credential and config writes. Before, browser saves without `expectedOwnerId` passed no guard; the save now also widens the allowlist, so a requester whose connection or scopes end mid-save cannot commit it. Owner-bound CLI saves keep their owner check and add the same requester check. Plugin setup defaults still cannot change restrictions (`withoutProviderModelPolicy` is unchanged); only the credential save does. This reverses the ask-first default from #144468 by maintainer decision. No undo button: the `models.authSetApiKey` result has no field for the change, and adding one is a protocol change; the change is a single visible `provider/*` allowlist entry. ## User Impact Add a provider key or sign in → its models show in the model picker, even under an existing allowlist that did not mention the provider. Operators who listed specific models of that provider keep exactly their list. ## Evidence Real Gateway, real config write (`src/gateway/server-methods/models-auth-api-key.integration.test.ts`): config `agents.defaults.modelPolicy.allow: ["other/*"]`, `models.authSetApiKey` for `fixture` → saved config `["other/*", "fixture/*"]`. Negative control: with the new line disabled, the test fails `expected [ 'other/*' ] to deeply equal [ 'other/*', 'fixture/*' ]`. Policy owner (`src/commands/models/auth-model-policy.test.ts`, real config file): - per-agent policy widened, defaults untouched; - no allowlist / provider already allowed → config bytes unchanged; - allowlist with exact `sample/one`, `sample/two` → unchanged; with `sample/family/*` → unchanged (both fail when the check is reverted to "literal `sample/*` missing"); - deferred legacy map keeps `existing-model` and gains `sample/*`; - migrated model map is not treated as an allowlist; - authority revoked during the writer's preflight → no write. Sign-in end to end against a real plugin and config (`src/commands/models.auth.provider-resolution.test.ts`): `access`, `access-legacy`, `access-legacy-set-default` cases save the credential, add `authstore-proof/*` with no prompt, and log the notice. Real key writer under revocation (`src/commands/models/auth-api-key.test.ts`, real auth store and config file): with an allowlist present, authority revoked inside the config write leaves the config bytes unchanged (no auth binding, no `sample/*`); unrevoked, the same write saves the binding and `["other/*", "sample/*"]`. Gateway-to-writer revocation chain (`src/commands/models/auth-api-key.test.ts`): the real `models.authSetApiKey` handler, its `readGatewayRequestMutationAuthority` guard and the real key/config writer, with the requester's authority ending inside the config write. The RPC fails with "Gateway requester authority changed"; the config file bytes are unchanged (no auth binding, allowlist still `["other/*"]`). The key itself committed earlier, while the requester was still authorized, and stays saved. Negative control: with the handler guard replaced by a no-op, the test fails. Run output (synthetic keys only): ``` ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=false) 1511ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=true) 914ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=false) 1392ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=true) 1067ms ✓ |commands| src/commands/models/auth-api-key.test.ts > models.authSetApiKey writes no binding or allowlist once the requester is revoked 977ms Tests 5 passed | 42 skipped (47) ``` Upgrade compatibility: no stored schema or config shape changes. Existing configs load as before and keep working: explicit `modelPolicy.allow` (defaults and per-agent), unmigrated legacy `agents.defaults.models` allowlists (wildcard added as a map key, every existing model kept), migrated maps with the `modelPolicyAllowlist` marker (not treated as an allowlist), and configs without an allowlist (never written). Each case runs against a real config file in `auth-model-policy.test.ts` and `models.auth.provider-resolution.test.ts`. The removed chat model-access questions were in-memory only, so no stored state refers to them. Existing data, real CLI entry point: a temporary state directory seeded with the Team server's pre-change allowlist shape (exact `openai/...` refs plus `clawrouter/anthropic/...` refs, and a legacy `agents.defaults.models` map), then `openclaw models auth paste-api-key` from this branch for three providers (synthetic keys, the first run's output trimmed to the resulting list): ``` Team pre-change allowlist (exact openai refs + clawrouter/anthropic refs), no Gateway running == openclaw models auth paste-api-key --provider openai allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5'] == openclaw models auth paste-api-key --provider particle Auth profile: particle:manual (particle/api_key) Added particle/* to allowed models. allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*'] == openclaw models auth paste-api-key --provider clawrouter Auth profile: clawrouter:manual (clawrouter/api_key) allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*'] ``` OpenAI and ClawRouter keep the operator's exact lists; only Particle, which the list did not mention, gains `particle/*`. Bare legacy ref (`auth-model-policy.test.ts`): legacy map `{ tiny: {} }` with a configured `sample` provider that has `tiny` → saving a `sample` credential leaves config unchanged (fails against the earlier `DEFAULT_PROVIDER` parse). Requester authority (`src/gateway/server-methods/models-auth-status.set-api-key.test-support.ts`): authority ends during the save → the RPC fails with "Gateway requester authority changed" and the writer's `assertCurrent` throws before commit. Negative control: with the handler's default guard replaced by a no-op, the test fails. Surface tests: chat `/login` and Telegram completion messages include the notice; Control UI wizard reports unconfirmed apply; mocked-Gateway Control UI E2E (`model-provider-login.e2e.test.ts`) passes. Control UI, mocked Gateway, policy `allow: ["openai/*"]`, save a Particle key: Before (main, #189917): the dialog stays open with a config-editing instruction.  After: the Gateway widens the policy during the save; the dialog closes like any successful save.  Commands: - `pnpm test src/commands/models/auth-model-policy.test.ts --maxWorkers=1`: 7 passed. - `pnpm test src/gateway/server-methods/models-auth-api-key.integration.test.ts --maxWorkers=1`: 1 passed (~12.5 s, real Gateway, existing test extended; no new boot). - `pnpm test src/commands/models/auth.test.ts src/commands/models.auth.provider-resolution.test.ts --maxWorkers=1`: 80 passed. - Chat/Gateway/Telegram/UI suites: passed. - `pnpm tsgo:core`, `pnpm tsgo:extensions`, `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 pnpm check:changed`. No overlap with Pash/Sarah changes. Merge danger: one-way for configs: a credential save can now write `<provider>/*` into a model allowlist. A revert stops new writes but does not remove entries already added. Blast radius: operators who rely on an allowlist that does not mention a provider to keep that provider hidden after someone adds its credentials. Only admins can save credentials. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…openclaw#190019) ## What Problem This Solves Adding a provider did not make it usable when a model allowlist (`modelPolicy.allow`) existed. On the Team server, saving a Particle API key in **Settings → Models → Connect provider** succeeded, but no Particle model appeared in the model picker: the allowlist hid them all. Sign-in flows (CLI, chat `/login`, Telegram, Control UI wizard) asked **Show all <Provider> models / Keep current restrictions** with Keep as the default. The API-key save path skipped even that, and openclaw#189917 only added a text warning that told the user to edit config by hand. ## Fix Saving credentials for a provider is now the request to use its models. When the allowlist that governs the agent hides **every** model of that provider, the save adds `<provider>/*` to that allowlist, through the existing model-policy owner (`src/commands/models/auth-model-policy.ts`): - per-agent `agents.entries.<id>.modelPolicy.allow` when the agent sets its own policy, otherwise `agents.defaults.modelPolicy.allow`; - an unmigrated legacy `agents.defaults.models` allowlist gets the wildcard key, so none of its models is dropped. Nothing changes when there is no allowlist, or when the allowlist already names some of the provider's models (an exact ref such as `openai/gpt-x`, or a narrower wildcard such as `clawrouter/anthropic/*`). The policy owner decides that: the check reads providers from `createModelVisibilityPolicy(...).allowedKeys`, which resolves exact refs, aliases and bare legacy refs (inferring their provider from configured provider rows) the same way the picker does. A deliberate exact list is never widened. Paths: - API key / token save (`models.authSetApiKey`, `openclaw models auth paste-api-key`, `paste-token`): the wildcard is added in the same config write as the credential's auth profile. - Sign-in (`openclaw models auth login`, Control UI wizard, chat `/login`, Telegram `/login`): after the credential is saved, one write adds the wildcard. The login result carries `modelAccess: { message, applied }`; chat and Telegram append "Added `<provider>/*` to allowed models." to the completion message; the Control UI wizard reports an unconfirmed apply as before. Removed: the post-save select prompt, the deferred `onModelAccessRequested` request, `offerProviderLoginModelAccess` / `answerProviderLoginModelAccess`, the `/login access` and `/login choice` model-access commands, `createLoginChoicePrompt`, `ProviderModelPolicyChangedError`, and the openclaw#189917 Control UI warning. `provider-auth-login-flow-runtime` is a private-local SDK subpath (docs/plugins/sdk-subpaths.md), so its only consumers are bundled (core chat `/login`, Telegram), migrated here. Authority: every `models.authSetApiKey` save now checks live requester authority (`readGatewayRequestMutationAuthority`, the guard `config.patch` uses) before its credential and config writes. Before, browser saves without `expectedOwnerId` passed no guard; the save now also widens the allowlist, so a requester whose connection or scopes end mid-save cannot commit it. Owner-bound CLI saves keep their owner check and add the same requester check. Plugin setup defaults still cannot change restrictions (`withoutProviderModelPolicy` is unchanged); only the credential save does. This reverses the ask-first default from openclaw#144468 by maintainer decision. No undo button: the `models.authSetApiKey` result has no field for the change, and adding one is a protocol change; the change is a single visible `provider/*` allowlist entry. ## User Impact Add a provider key or sign in → its models show in the model picker, even under an existing allowlist that did not mention the provider. Operators who listed specific models of that provider keep exactly their list. ## Evidence Real Gateway, real config write (`src/gateway/server-methods/models-auth-api-key.integration.test.ts`): config `agents.defaults.modelPolicy.allow: ["other/*"]`, `models.authSetApiKey` for `fixture` → saved config `["other/*", "fixture/*"]`. Negative control: with the new line disabled, the test fails `expected [ 'other/*' ] to deeply equal [ 'other/*', 'fixture/*' ]`. Policy owner (`src/commands/models/auth-model-policy.test.ts`, real config file): - per-agent policy widened, defaults untouched; - no allowlist / provider already allowed → config bytes unchanged; - allowlist with exact `sample/one`, `sample/two` → unchanged; with `sample/family/*` → unchanged (both fail when the check is reverted to "literal `sample/*` missing"); - deferred legacy map keeps `existing-model` and gains `sample/*`; - migrated model map is not treated as an allowlist; - authority revoked during the writer's preflight → no write. Sign-in end to end against a real plugin and config (`src/commands/models.auth.provider-resolution.test.ts`): `access`, `access-legacy`, `access-legacy-set-default` cases save the credential, add `authstore-proof/*` with no prompt, and log the notice. Real key writer under revocation (`src/commands/models/auth-api-key.test.ts`, real auth store and config file): with an allowlist present, authority revoked inside the config write leaves the config bytes unchanged (no auth binding, no `sample/*`); unrevoked, the same write saves the binding and `["other/*", "sample/*"]`. Gateway-to-writer revocation chain (`src/commands/models/auth-api-key.test.ts`): the real `models.authSetApiKey` handler, its `readGatewayRequestMutationAuthority` guard and the real key/config writer, with the requester's authority ending inside the config write. The RPC fails with "Gateway requester authority changed"; the config file bytes are unchanged (no auth binding, allowlist still `["other/*"]`). The key itself committed earlier, while the requester was still authorized, and stays saved. Negative control: with the handler guard replaced by a no-op, the test fails. Run output (synthetic keys only): ``` ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=false) 1511ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=true) 914ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=false) 1392ms ✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=true) 1067ms ✓ |commands| src/commands/models/auth-api-key.test.ts > models.authSetApiKey writes no binding or allowlist once the requester is revoked 977ms Tests 5 passed | 42 skipped (47) ``` Upgrade compatibility: no stored schema or config shape changes. Existing configs load as before and keep working: explicit `modelPolicy.allow` (defaults and per-agent), unmigrated legacy `agents.defaults.models` allowlists (wildcard added as a map key, every existing model kept), migrated maps with the `modelPolicyAllowlist` marker (not treated as an allowlist), and configs without an allowlist (never written). Each case runs against a real config file in `auth-model-policy.test.ts` and `models.auth.provider-resolution.test.ts`. The removed chat model-access questions were in-memory only, so no stored state refers to them. Existing data, real CLI entry point: a temporary state directory seeded with the Team server's pre-change allowlist shape (exact `openai/...` refs plus `clawrouter/anthropic/...` refs, and a legacy `agents.defaults.models` map), then `openclaw models auth paste-api-key` from this branch for three providers (synthetic keys, the first run's output trimmed to the resulting list): ``` Team pre-change allowlist (exact openai refs + clawrouter/anthropic refs), no Gateway running == openclaw models auth paste-api-key --provider openai allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5'] == openclaw models auth paste-api-key --provider particle Auth profile: particle:manual (particle/api_key) Added particle/* to allowed models. allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*'] == openclaw models auth paste-api-key --provider clawrouter Auth profile: clawrouter:manual (clawrouter/api_key) allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*'] ``` OpenAI and ClawRouter keep the operator's exact lists; only Particle, which the list did not mention, gains `particle/*`. Bare legacy ref (`auth-model-policy.test.ts`): legacy map `{ tiny: {} }` with a configured `sample` provider that has `tiny` → saving a `sample` credential leaves config unchanged (fails against the earlier `DEFAULT_PROVIDER` parse). Requester authority (`src/gateway/server-methods/models-auth-status.set-api-key.test-support.ts`): authority ends during the save → the RPC fails with "Gateway requester authority changed" and the writer's `assertCurrent` throws before commit. Negative control: with the handler's default guard replaced by a no-op, the test fails. Surface tests: chat `/login` and Telegram completion messages include the notice; Control UI wizard reports unconfirmed apply; mocked-Gateway Control UI E2E (`model-provider-login.e2e.test.ts`) passes. Control UI, mocked Gateway, policy `allow: ["openai/*"]`, save a Particle key: Before (main, openclaw#189917): the dialog stays open with a config-editing instruction.  After: the Gateway widens the policy during the save; the dialog closes like any successful save.  Commands: - `pnpm test src/commands/models/auth-model-policy.test.ts --maxWorkers=1`: 7 passed. - `pnpm test src/gateway/server-methods/models-auth-api-key.integration.test.ts --maxWorkers=1`: 1 passed (~12.5 s, real Gateway, existing test extended; no new boot). - `pnpm test src/commands/models/auth.test.ts src/commands/models.auth.provider-resolution.test.ts --maxWorkers=1`: 80 passed. - Chat/Gateway/Telegram/UI suites: passed. - `pnpm tsgo:core`, `pnpm tsgo:extensions`, `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 pnpm check:changed`. No overlap with Pash/Sarah changes. Merge danger: one-way for configs: a credential save can now write `<provider>/*` into a model allowlist. A revert stops new writes but does not remove entries already added. Blast radius: operators who rely on an allowlist that does not mention a provider to keep that provider hidden after someone adds its credentials. Only admins can save credentials. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: saving an API key in Settings → Models → Connect provider succeeds silently when
agents.defaults.modelPolicy.allowhides every model of that provider, so the provider never appears in the model picker and nothing says why.User Impact
User impact: after the key saves, the dialog stays open and says that the model policy hides the provider's models, with the
provider/*entry to add: toagents.entries.<agent>.modelPolicy.allowwhen the selected agent sets its own policy (it replaces the default), otherwise toagents.defaults.modelPolicy.allow. Saves for providers the policy allows close the dialog as before.Why This Change Was Made
The Gateway already decides policy visibility:
models.listwithview: "all"marks each modelmanualSelectionAllowedfrom the agent's model policy. After a successful key save, the provider page reads that list for the saved provider and warns only when the Gateway marks every model hidden. The UI does not match allowlist patterns itself.models.listdoes not say which config level owns the policy, so the warning names both instead of adding a protocol field. The warning uses the existing post-save warning path, which already keeps the dialog open for discovery failures.Evidence
Mocked-Gateway Control UI run of the real dialog flow (policy
allow: ["openai/*"], save a Particle key;models.list view=all provider=particlereturnsmanualSelectionAllowed: false):Before (main): the dialog closes with no explanation.
After: the dialog stays open with the policy warning.
pnpm test ui/src/pages/model-providers/model-providers-page.test.ts --maxWorkers=1: 35 passed, 1.8 s wall. The new cases check the warning when every model is hidden and no warning when one model is allowed; both fail with the fix reverted.src/gateway/server-methods/models.prepared.test.tspublishesmodelPolicy.allow: ["test/first"]and checksview: "all"marks other modelsmanualSelectionAllowed: false.pnpm check:changed(dead-code skipped) andpnpm ui:i18n:verifypass.Merge danger: two-way door. UI-only; a revert restores the silent close. Blast radius: the Models settings key dialogs (add and edit) gain one extra
models.listread per successful save; a failure of that read shows as a warning, not a failed save.🤖 Generated with Claude Code