fix(model-picker): use preferredProvider presence for filtering instead of catalog check

When auth choice explicitly sets a preferred provider (e.g., volcengine-api-key or byteplus-api-key), the model picker should always filter by that provider. Previously, it relied on providerIds.includes(preferredProvider), which could be false if the catalog hadn't loaded that provider's models yet due to a race condition between auth choice setup and catalog loading.

This ensures that selecting a provider via auth choice consistently filters the model list to only that provider's models, rather than showing all providers.
This commit is contained in:
Mingxuan
2026-04-01 12:58:00 +08:00
committed by Peter Steinberger
parent 6b82140336
commit 792558de01

View File

@@ -215,9 +215,7 @@ async function maybeFilterModelsByProvider(params: {
const providerIds = Array.from(new Set(params.models.map((entry) => entry.provider))).toSorted(
(a, b) => a.localeCompare(b),
);
const hasPreferredProvider = params.preferredProvider
? providerIds.includes(params.preferredProvider)
: false;
const hasPreferredProvider = !!params.preferredProvider;
const shouldPromptProvider =
!hasPreferredProvider &&
providerIds.length > 1 &&