Repository navigation
Commit a60d517
fix(catalog): match selectedModels the way the canonical resolver matches it (#2481)
* 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."
* test(catalog): pin the lossy collision and record the rejected alternative
The key comparison is right for the reported bug, but it is lossy in a
way worth writing down: "a/b" and "a-b" collapse to one equivalence key,
so a provider publishing both spellings has them selected together. That
behavior now has tests asserting what the code actually does, rather than
being left for someone to discover from a support thread.
It also has a rejected alternative recorded next to it. Resolving each
selection against the provider's current rows looks stricter and is not:
the roster is an incomplete dictionary, so when live discovery omits
"a-b" but returns "a/b", an exact "a-b" selection resolves onto "a/b" and
reproduces the same over-grant. It would additionally make fresh
filtering disagree with the equivalence relation sync.ts applies when
merging the persisted catalog — two catalog stages with different rules
is the bug class this change removes.
The real fix is one selection resolver shared by filtering, persisted
sync, CLI removal, and routing, evaluated against a complete known-id
set, with a single ambiguity policy. That is an architecture change and
does not belong in a bugfix-only release; tracked as #2491.
Tests: 242 pass across selected-models, codex-catalog, slug-codec, and
cli-models. tsc --noEmit clean.
---------
Co-authored-by: bitkyc08-arch <[email protected]>1 parent 3e3a028 commit a60d517
2 files changed
Lines changed: 94 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
1560 | 1560 | | |
1561 | 1561 | | |
1562 | 1562 | | |
1563 | | - | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
1564 | 1581 | | |
1565 | 1582 | | |
1566 | 1583 | | |
| |||
1572 | 1589 | | |
1573 | 1590 | | |
1574 | 1591 | | |
1575 | | - | |
| 1592 | + | |
1576 | 1593 | | |
1577 | 1594 | | |
1578 | 1595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments