From 70c25ba3ff0a14d437b00a94f52e9ed1be871e5a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 25 May 2026 12:06:29 +0100 Subject: [PATCH] fix: honor provider aliases in model rows --- src/commands/models/list.rows.ts | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/commands/models/list.rows.ts b/src/commands/models/list.rows.ts index 86eeb39d05c..eb05c594139 100644 --- a/src/commands/models/list.rows.ts +++ b/src/commands/models/list.rows.ts @@ -17,6 +17,7 @@ import type { ModelListAuthIndex } from "./list.auth-index.js"; import type { ListRowModel } from "./list.model-row.js"; import { toModelRow } from "./list.model-row.js"; import type { ConfiguredEntry, ModelRow } from "./list.types.js"; +import { canonicalizeModelCatalogProviderAlias } from "./provider-aliases.js"; import { isLocalBaseUrl, modelKey } from "./shared.js"; type ConfiguredByKey = Map; @@ -64,11 +65,26 @@ function loadProviderCatalogModule(): Promise { return providerCatalogModuleLoader.load(); } -function matchesRowFilter(filter: RowFilter, model: { provider: string; baseUrl?: string }) { - if (filter.provider && normalizeProviderId(model.provider) !== filter.provider) { +function matchesProviderFilter(context: RowBuilderContext, provider: string): boolean { + const providerFilter = context.filter.provider; + if (!providerFilter) { + return true; + } + const canonicalProvider = canonicalizeModelCatalogProviderAlias(provider, { + cfg: context.cfg, + metadataSnapshot: context.metadataSnapshot, + }); + return normalizeProviderId(canonicalProvider) === providerFilter; +} + +function matchesRowFilter( + context: RowBuilderContext, + model: { provider: string; baseUrl?: string }, +) { + if (!matchesProviderFilter(context, model.provider)) { return false; } - if (filter.local && !isLocalBaseUrl(model.baseUrl ?? "")) { + if (context.filter.local && !isLocalBaseUrl(model.baseUrl ?? "")) { return false; } return true; @@ -163,7 +179,7 @@ async function appendVisibleRow(params: { if (params.seenKeys?.has(params.key)) { return false; } - if (!matchesRowFilter(params.context.filter, params.model)) { + if (!matchesRowFilter(params.context, params.model)) { return false; } const normalizedModel = normalizeListRowWithProviderPlugin({ @@ -438,10 +454,7 @@ export async function appendCatalogSupplementRows(params: { metadataSnapshot: params.context.metadataSnapshot, }); for (const entry of catalog) { - if ( - params.context.filter.provider && - normalizeProviderId(entry.provider) !== params.context.filter.provider - ) { + if (!matchesProviderFilter(params.context, entry.provider)) { continue; } const key = modelKey(entry.provider, entry.id); @@ -525,10 +538,7 @@ export async function appendConfiguredRows(params: { ? (await loadModelResolverModule()).resolveModelWithRegistry : undefined; for (const entry of params.entries) { - if ( - params.context.filter.provider && - normalizeProviderId(entry.ref.provider) !== params.context.filter.provider - ) { + if (!matchesProviderFilter(params.context, entry.ref.provider)) { continue; } const resolvedModel =