Skip to content

The agent that grows with you

fix(desktop): harden catalog ModelPrice against partial pricing payloads

Brooklyn Nicholson81e28566c538
diff --git a/apps/desktop/src/app/shell/model-catalog-menu.test.tsx b/apps/desktop/src/app/shell/model-catalog-menu.test.tsx
index a436e79d798..ce224c72280 100644
--- a/apps/desktop/src/app/shell/model-catalog-menu.test.tsx
+++ b/apps/desktop/src/app/shell/model-catalog-menu.test.tsx
@@ -420,4 +420,25 @@ describe('the catalog renders per-model pricing', () => {
await screen.findByText('free')
})
+
+ it('renders no price span when the provider carries no pricing for the model', async () => {
+ getGlobalModelOptions.mockResolvedValue({
+ providers: [
+ {
+ models: ['anthropic/claude-sonnet-5'],
+ name: 'Nous Portal',
+ slug: 'nous'
+ }
+ ]
+ })
+
+ renderMenu()
+
+ // modelDisplayParts prettifies to the bare family name (vendor lives on
+ // the provider group row), so the row reads "Sonnet 5", not "Claude
+ // Sonnet 5".
+ await screen.findByText('Sonnet 5')
+ expect(screen.queryByText(/\/Mtok/)).toBeNull()
+ expect(screen.queryByText('free')).toBeNull()
+ })
})
diff --git a/apps/desktop/src/app/shell/model-catalog-menu.tsx b/apps/desktop/src/app/shell/model-catalog-menu.tsx
index 3ca83c44087..a442f25a55b 100644
--- a/apps/desktop/src/app/shell/model-catalog-menu.tsx
+++ b/apps/desktop/src/app/shell/model-catalog-menu.tsx
@@ -72,21 +72,32 @@ export const ModelMenuCloseContext = createContext<() => void>(() => {})
* portal reports a discounted list price. Rendered only when the provider's
* payload carries pricing (Nous Portal and others that ship it). */
function ModelPrice({ pricing }: { pricing: ModelPricing }) {
+ // Partial payloads: `_apply_pricing` ships "" for unknown, but a provider
+ // can report null — render nothing rather than "null/null" or "—/—".
+ const input = pricing.input || null
+ const output = pricing.output || null
if (pricing.free) {
return <span className="shrink-0 pl-2 text-[0.625rem] text-(--ui-green)">free</span>
}
+ if (!input && !output) {
+ return null
+ }
+
+ const discount = typeof pricing.discount_percent === 'number' && pricing.discount_percent > 0
+ ? pricing.discount_percent
+ : null
return (
<span
className="flex shrink-0 items-center gap-1.5 pl-2 text-[0.625rem] tabular-nums text-(--ui-text-tertiary)"
- title={`Input ${pricing.input}/Mtok · Output ${pricing.output}/Mtok`}
+ title={`Input ${input ?? '—'}/Mtok · Output ${output ?? '—'}/Mtok`}
>
<span>
- {pricing.input}/{pricing.output}
+ {input ?? '—'}/{output ?? '—'}
</span>
- {pricing.discount_percent ? (
+ {discount ? (
<span className="rounded bg-(--ui-green)/10 px-1 py-px font-medium text-(--ui-green)">
- −{pricing.discount_percent}%
+ −{discount}%
</span>
) : null}
</span>