Skip to content

fix(desktop): stop auto-populating empty model lists from provider API#3711

Merged
esengine merged 1 commit into
esengine:main-v2from
CVEngineer66:fix/provider-model-auto-populate
Jun 10, 2026
Merged

fix(desktop): stop auto-populating empty model lists from provider API#3711
esengine merged 1 commit into
esengine:main-v2from
CVEngineer66:fix/provider-model-auto-populate

Conversation

@CVEngineer66

Copy link
Copy Markdown
Contributor

Summary / 摘要

EN: Background auto-refresh calls FetchProviderModels for every configured provider and merges the result via mergedFetchedProviderModels(). When the user left the models list empty (common for custom providers), preserveCurated: true had no effect because saved.length === 0, causing every model from the API to be written into the config and polluting the model dropdown.

Now the background refresh skips providers whose models list is empty, preventing silent pollution of the model dropdown. Users can still manually fetch models via the "Refresh Models" button.

CN: 后台自动刷新会对每个配置了 API key 的 provider 调用 FetchProviderModels,然后将结果通过 mergedFetchedProviderModels() 合并到配置中。当用户未填写具体模型列表时(自定义 provider 的常见做法),preserveCurated: true 的保护条件因 saved.length === 0 而不生效,导致所有 API 返回的模型被写入配置,污染模型下拉框。

现在后台刷新会跳过模型列表为空的 provider,防止静默污染。用户仍然可以通过"刷新模型"按钮手动获取可用模型。

Root Cause

In SettingsPanel.tsx background auto-refresh (line 760-773):

```typescript
const models = mergedFetchedProviderModels(provider.models, fetched, { preserveCurated: true });
```

In mergedFetchedProviderModels() (`providerModels.ts:1-5`):

```typescript
if (options.preserveCurated && saved.length > 0) return saved;
return uniqueStrings([...saved, ...fetched]);
```

When `saved.length === 0` (user never filled in models), `preserveCurated` is a no-op and every API model enters the config.

Fix

Added early skip at the start of the auto-refresh loop:

```typescript
if (!provider.models || provider.models.length === 0) continue;
```

Testing

  • `npx tsc --noEmit` — clean
  • `pnpm build` — clean
  • Manual: empty model list no longer triggers auto-refresh write

Fixes #3705

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 9, 2026
Background auto-refresh calls FetchProviderModels for every configured
provider and merges the result via mergedFetchedProviderModels().
When the user left the models list empty (common for custom providers),
preserveCurated: true had no effect because saved.length === 0,
causing every model from the API to be written into the config.

Now the background refresh skips providers whose models list is empty,
preventing silent pollution of the model dropdown. Users can still
manually fetch models via the 'Refresh Models' button.

Fixes esengine#3705
@CVEngineer66 CVEngineer66 force-pushed the fix/provider-model-auto-populate branch from c6f4f92 to f67af6e Compare June 9, 2026 13:22

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — auto-refresh should only maintain a user-curated model list, not silently populate an empty one with every model the provider API returns. Clean guard, thanks.

@esengine esengine merged commit a672727 into esengine:main-v2 Jun 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows桌面版会话窗口模型选择重大BUG

2 participants