Skip to content

Commit 0af42e1

Browse files
committed
Parse colon-less picker ids without truncating the provider
slice(0, indexOf(":")) drops the last character when the id has no colon, mis-attributing the row. split(":")[0] keeps the full id.
1 parent cf4760f commit 0af42e1

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/tui/model-catalog.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,14 @@ describe("describeModelCatalogOption", () => {
244244
expect(description?.impact).not.toMatch(/pricing unknown/i);
245245
expect(description?.impact).toMatch(/subscription/);
246246
});
247+
248+
test("colon-less ids keep the full provider instead of dropping the last character", () => {
249+
// slice(0, indexOf(":")) truncates a colon-less id (indexOf is -1), so
250+
// "codex/" became "code" and missed subscription billing.
251+
const description = describeModelCatalogOption(
252+
{ id: "codex/", label: "default * [Codex default]" },
253+
{ pricing: null },
254+
);
255+
expect(description?.impact).toMatch(/ChatGPT subscription/);
256+
});
247257
});

src/tui/model-catalog.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ export function describeModelCatalogOption(
324324
what: whatLine(model),
325325
impact: pricingImpact(
326326
pricing,
327-
option.id.slice(0, option.id.indexOf(":")),
327+
// Exact provider parse: slice(0, indexOf(":")) drops the last
328+
// character of a colon-less id (indexOf returns -1).
329+
option.id.split(":")[0] ?? option.id,
328330
model,
329331
),
330332
tone: "plain",

0 commit comments

Comments
 (0)