fix(desktop): stop auto-populating empty model lists from provider API#3711
Merged
esengine merged 1 commit intoJun 10, 2026
Merged
Conversation
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
c6f4f92 to
f67af6e
Compare
esengine
approved these changes
Jun 10, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
EN: Background auto-refresh calls
FetchProviderModelsfor every configured provider and merges the result viamergedFetchedProviderModels(). When the user left the models list empty (common for custom providers),preserveCurated: truehad no effect becausesaved.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.tsxbackground 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
Fixes #3705