diff --git a/src/commands/models/list.auth-index.test.ts b/src/commands/models/list.auth-index.test.ts index b070a2b5cd8..aa5f0b081f3 100644 --- a/src/commands/models/list.auth-index.test.ts +++ b/src/commands/models/list.auth-index.test.ts @@ -144,6 +144,18 @@ describe("createModelListAuthIndex", () => { expect(index.hasProviderAuth("codex")).toBe(true); }); + it("keeps synthetic auth refs exact instead of applying auth-choice aliases", () => { + const index = createModelListAuthIndex({ + cfg: {}, + authStore: emptyStore, + env: {}, + syntheticAuthProviderRefs: ["claude-cli"], + }); + + expect(index.hasProviderAuth("claude-cli")).toBe(true); + expect(index.hasProviderAuth("anthropic")).toBe(false); + }); + it("ignores derived synthetic auth snapshots", () => { pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValueOnce({ source: "derived", diff --git a/src/commands/models/list.auth-index.ts b/src/commands/models/list.auth-index.ts index 39cf25de8e1..ba64321ca7b 100644 --- a/src/commands/models/list.auth-index.ts +++ b/src/commands/models/list.auth-index.ts @@ -57,12 +57,20 @@ export function createModelListAuthIndex( const aliasMap = resolveProviderAuthAliasMap({ config: params.cfg, env }); const envCandidateMap = resolveProviderEnvApiKeyCandidates({ config: params.cfg, env }); const authenticatedProviders = new Set(); + const syntheticAuthProviders = new Set(); const addProvider = (provider: string | undefined) => { if (!provider?.trim()) { return; } authenticatedProviders.add(normalizeAuthProvider(provider, aliasMap)); }; + const addSyntheticProvider = (provider: string | undefined) => { + const normalized = provider?.trim() ? normalizeProviderIdForAuth(provider) : ""; + if (!normalized) { + return; + } + syntheticAuthProviders.add(normalized); + }; for (const credential of Object.values(params.authStore.profiles ?? {})) { addProvider(credential.provider); @@ -94,12 +102,15 @@ export function createModelListAuthIndex( for (const provider of params.syntheticAuthProviderRefs ?? listValidatedSyntheticAuthProviderRefs({ cfg: params.cfg, env })) { - addProvider(provider); + addSyntheticProvider(provider); } return { hasProviderAuth(provider: string): boolean { - return authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap)); + return ( + authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap)) || + syntheticAuthProviders.has(normalizeProviderIdForAuth(provider)) + ); }, }; }