Skip to content

Commit a81275f

Browse files
committed
fix(catalog): match selectedModels the way the canonical resolver matches it
`filterCatalogVisibleModels` built the per-provider allowlist as a plain `Set(selectedModels)` and tested it with `allow.has(m.id)` — the native model id, exactly. The canonical resolution of the same list keys it through the slug equivalence: sync.ts:819-821 new Set([...models].map(m => slugEquivalenceKey(routedSlug(provider, m)))) sync.ts:1039 selected === undefined || selected.has(slugEquivalenceKey(slug)) so the two disagree for any provider whose native ids contain a slash: stored "moonshotai/kimi-k3-free" sync accepts=true catalog filter accepts=true stored "moonshotai-kimi-k3-free" sync accepts=true catalog filter accepts=false The second is the Codex-facing slug `routedSlug()` produces and the picker displays, and `ocx models remove` already accepts it (tests/cli-models.test.ts:332, "models remove accepts raw and encoded slash selectors"). An allowlist written from what the user sees therefore blanked the provider's catalog silently, while `routeModel` decoded the same string back and served the model happily. Affects providers with slash-bearing native ids: openrouter, zenmux, nvidia, together, fireworks. The `disabledModels` loop three lines above is already tolerant of both forms via `slugEquals`, and slug-codec.ts:20-21 states the rule this restores: "Config comparisons are tolerant … so legacy raw values keep working regardless of which form was stored."
1 parent c44e43f commit a81275f

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎src/codex/catalog/provider-fetch.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import type { FastPolicyAuthority } from "../../providers/fastwire";
4141
import { effectiveGoogleMode, getProviderRegistryEntry, providerMatchesRegistryTransport } from "../../providers/registry";
4242
import { parseAntigravityAvailableModels, registerAntigravityDiscoveredWireModels } from "../../providers/antigravity-models";
4343
import { applyProviderContextCap, providerContextCap, resolveUnknownRoutedContextWindow } from "../../providers/context-cap";
44-
import { routedSlug, slugEquals, slugsEquivalent } from "../../providers/slug-codec";
44+
import { routedSlug, slugEquals, slugEquivalenceKey, slugsEquivalent } from "../../providers/slug-codec";
4545
import { CODEX_GPT5_IDENTITY_LINE } from "../../adapters/identity";
4646
import { filterCursorConfiguredModelsByLiveDiscovery } from "../../adapters/cursor/discovery";
4747
import { fetchCursorUsableModels } from "../../adapters/cursor/live-models";
@@ -1560,7 +1560,13 @@ export function filterCatalogVisibleModels(
15601560
const allowByProvider = new Map<string, Set<string>>();
15611561
for (const [name, prov] of Object.entries(config.providers)) {
15621562
const sel = prov.selectedModels;
1563-
if (Array.isArray(sel) && sel.length > 0) allowByProvider.set(name, new Set(sel));
1563+
// Keyed the way `sync.ts` keys the same list, so a slash-bearing native id and
1564+
// the encoded slug the Codex picker displays are one entry rather than two. A
1565+
// bare `Set(sel)` matched only the native form, so an allowlist written from the
1566+
// displayed slug hid every model it was meant to keep.
1567+
if (Array.isArray(sel) && sel.length > 0) {
1568+
allowByProvider.set(name, new Set(sel.map(model => slugEquivalenceKey(routedSlug(name, model)))));
1569+
}
15641570
}
15651571
return models.filter(m => {
15661572
const nativeAlias = m.provider === COMBO_NAMESPACE && m.nativeAlias === true;
@@ -1572,7 +1578,7 @@ export function filterCatalogVisibleModels(
15721578
if (slugEquals(stored, m.provider, m.id)) return false;
15731579
}
15741580
const allow = allowByProvider.get(m.provider);
1575-
return !allow || allow.has(m.id);
1581+
return !allow || allow.has(slugEquivalenceKey(routedSlug(m.provider, m.id)));
15761582
});
15771583
}
15781584

‎tests/selected-models.test.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,42 @@ describe("filterCatalogVisibleModels — per-provider allowlist", () => {
4747
expect(out.map(x => x.id).sort()).toEqual(["model-1999", "model-7"]);
4848
});
4949
});
50+
51+
describe("filterCatalogVisibleModels — slash-bearing ids", () => {
52+
// `sync.ts` keys this same list through `slugEquivalenceKey(routedSlug(...))`, so
53+
// the native id and the encoded slug the Codex picker displays are one entry there.
54+
// A bare `Set(selectedModels)` here matched only the native form, so an allowlist
55+
// written from the displayed slug — which `ocx models remove` also accepts — hid
56+
// every model it was meant to keep.
57+
const native = "moonshotai/kimi-k3-free";
58+
const encoded = "moonshotai-kimi-k3-free";
59+
const rows = [m("zenmux", native), m("zenmux", "openai/gpt-5.5")];
60+
61+
test("an allowlist written with the encoded slug keeps the model", () => {
62+
const visible = filterCatalogVisibleModels(rows, cfg({
63+
zenmux: { selectedModels: [encoded] },
64+
}));
65+
expect(visible.map(v => v.id)).toEqual([native]);
66+
});
67+
68+
test("the native form keeps working", () => {
69+
const visible = filterCatalogVisibleModels(rows, cfg({
70+
zenmux: { selectedModels: [native] },
71+
}));
72+
expect(visible.map(v => v.id)).toEqual([native]);
73+
});
74+
75+
test("a mixed allowlist keeps both, without duplicating either", () => {
76+
const visible = filterCatalogVisibleModels(rows, cfg({
77+
zenmux: { selectedModels: [encoded, "openai/gpt-5.5"] },
78+
}));
79+
expect(visible.map(v => v.id).sort()).toEqual([native, "openai/gpt-5.5"].sort());
80+
});
81+
82+
test("a model outside the allowlist is still hidden", () => {
83+
const visible = filterCatalogVisibleModels(rows, cfg({
84+
zenmux: { selectedModels: [encoded] },
85+
}));
86+
expect(visible.map(v => v.id)).not.toContain("openai/gpt-5.5");
87+
});
88+
});

0 commit comments

Comments
 (0)