Skip to content

fix(providers): model list empty in settings panel (#581)#591

Merged
su8su merged 4 commits intoValueCell-ai:mainfrom
kagura-agent:fix/581-bug
Mar 21, 2026
Merged

fix(providers): model list empty in settings panel (#581)#591
su8su merged 4 commits intoValueCell-ai:mainfrom
kagura-agent:fix/581-bug

Conversation

@kagura-agent
Copy link
Contributor

Problem

Settings panel model dropdown shows empty list even though providers are properly configured in openclaw.json and the gateway works fine for chat. Closes #581.

Root Cause

Two issues in ProviderService.listAccounts():

  1. Destructive cleanup on empty config: When getActiveOpenClawProviders() returned an empty Set (transient condition during gateway restart, config file lock, first launch before config sync), the code deleted all provider accounts from the electron-store, including builtin ones. Next time the settings panel loaded — empty list.

  2. No seeding from OpenClaw config: Users who configured providers via CLI or openclaw.json directly (not through ClawX UI) had no corresponding ProviderAccount entries in the electron-store. The settings panel only reads from the store, so it showed nothing.

Fix

Defensive cleanup (commits 1-2)

  • When activeProviders.size === 0, skip cleanup entirely and return existing accounts as-is (with logger.warn() for diagnostics)
  • Move builtin-provider skip (if (isBuiltin) continue) earlier in the loop — builtin accounts should never be candidates for deletion

Config seeding (commit 3)

  • When the electron-store is empty but openclaw.json has configured providers, seed ProviderAccount entries from the config
  • New getOpenClawProvidersConfig() reads the raw provider config
  • New seedAccountsFromOpenClawConfig() creates account entries with correct vendor IDs, base URLs, and inferred model names
  • One-time operation — subsequent calls find existing accounts and skip seeding

Tests

5 unit tests covering:

  1. Preserves all accounts when activeProviders is empty (defensive path)
  2. Removes stale non-builtin accounts when config has active providers (normal cleanup)
  3. Never removes builtin providers even if not in activeProviders
  4. Returns empty and calls getActiveOpenClawProviders when account list is empty (seed check)
  5. Matches accounts by vendorId, id, or openClawKey

All 254 existing tests pass.

Kagura Chen and others added 4 commits March 19, 2026 15:04
…els.providers (ValueCell-ai#581)

The stale-account cleanup in listAccounts() deleted ALL provider accounts
(including builtin ones like Anthropic) whenever openclaw.json had an empty
models.providers section. This happened because:

1. Builtin providers (e.g. anthropic) don't register in models.providers —
   the OpenClaw runtime recognises them natively
2. getActiveOpenClawProviders() only reads models.providers keys, so it
   returned an empty set for users with only builtin providers
3. The configMissing flag (activeProviders.size === 0) caused ALL accounts
   to be deleted, bypassing the isBuiltin safety check

The fix removes the configMissing override so builtin provider accounts are
always retained regardless of whether models.providers is populated. Only
non-builtin, non-active accounts are cleaned up.

Closes ValueCell-ai#581
…s when config is empty

When getActiveOpenClawProviders() returns an empty Set (e.g. during gateway
restart, file lock, or before initial config sync), the stale-account cleanup
in listAccounts() would mark every non-builtin account for deletion — causing
configured models to disappear from the settings panel.

Fix: skip cleanup entirely when activeProviders is empty and log a warning,
preserving all existing accounts during transient states. Also skip builtin
providers earlier in the loop for clarity.

Closes ValueCell-ai#581
…ty (ValueCell-ai#581)

When users configure providers externally (via CLI or editing
openclaw.json directly), the ClawX settings panel shows an empty
provider list because it reads from its own store which was never
populated.

Add a one-time seed operation in ProviderService.listAccounts(): when
the ClawX store is empty but getActiveOpenClawProviders() returns
active providers, read models.providers from openclaw.json and create
corresponding ProviderAccount entries. Subsequent calls use the store
directly.

Also add getOpenClawProvidersConfig() helper to openclaw-auth.ts to
read models.providers and agents.defaults.model without exposing the
private readOpenClawJson function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When no ProviderAccounts exist, listAccounts() now calls
getActiveOpenClawProviders() to decide whether to seed from
openclaw.json. Updated test assertion accordingly.
@su8su su8su merged commit 5836ba6 into ValueCell-ai:main Mar 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 模型列表不显示 - 设置面板无法选择/切换已配置的模型

2 participants