feat: dedupe model picker and gate premium models behind upgrade prompt

SW
4mo ago
+152-19

What

Cleans up the chat model picker for anonymous and free users (item C6 of the web UX conversion audit):

  1. Dedupe the model list. The AI Gateway list (~200 entries) contains alias ids that render as duplicate rows (e.g. alibaba/qwen3-235b-a22b-thinking and alibaba/qwen3-vl-thinking both display as "Qwen3 VL 235B A22B Thinking"). New lib/ai/dedupeModels.ts dedupes by id and by normalized display name (trim, lowercase, collapse whitespace), keeping the first occurrence. Ids in the live list are unique; the duplicates differ only by alias id, so normalized name is the effective dedupe key.
  2. "Pro" chip on premium models. New lib/ai/isPremiumModel.ts badges every premium model with a small achromatic pill chip (matches the existing featured-pill styling and the DESIGN.md badge spec). Replaces the previous Lock/Crown icons, so the picker now visibly matches the sidebar's "premium AI models" pitch.
  3. Upgrade flow on gated selection. When a non-subscribed user picks a premium model, the picker no longer just shows an error toast and dead-ends. It keeps the current model selected, shows a short info toast, and triggers the existing upgrade flow (useSubscribeClick.handleClick, the same Stripe checkout the sidebar "Start Free Trial" card uses).

How premium is derived

Tier metadata already exists on the gateway model objects: pricing.input / pricing.output. isPremiumModel is the negation of the existing isFreeModel pricing threshold (input <= $0.50/M and output <= $2.50/M is free), so no curated model-id list was needed. Models with missing or unparseable pricing are treated as premium, matching the previous lock behavior.

Files changed

  • lib/ai/dedupeModels.ts (new)
  • lib/ai/isPremiumModel.ts (new)
  • lib/ai/__tests__/dedupeModels.test.ts (new, 5 tests)
  • lib/ai/__tests__/isPremiumModel.test.ts (new, 4 tests)
  • components/ModelSelect/ModelSelect.tsx (dedupe + gate to upgrade flow)
  • components/ModelSelect/ModelSelectItem.tsx (Pro chip, drop Lock/Crown icons)

How to test

  1. Open the preview signed out (or as a free account) and open the model picker in the chat prompt bar.
  2. Search/scroll for "Qwen3 VL 235B A22B Thinking" and "Qwen3 VL 235B A22B Instruct": each appears exactly once.
  3. Premium models (Claude Opus, GPT-5.5, Grok, etc.) show a small "Pro" chip; free models (Kimi K3, Gemini Flash) do not.
  4. As a non-subscribed user, click a Pro model: the selection does not change, a toast appears, and the Stripe checkout opens in a new tab (signed-out users see the toast only, same as the sidebar card behavior).
  5. As a subscribed user, Pro models select normally.

pnpm exec vitest run: 76 files / 285 tests passing. pnpm exec tsc --noEmit: no errors in changed files.

Part of recoupable/chat#1902.

Preview verification to follow in a PR comment.

🤖 Generated with Claude Code


Summary by cubic

Dedupes the chat model picker and gates premium models behind an upgrade prompt to improve clarity for anonymous and free users. Adds a "Pro" chip and routes gated selections to the existing upgrade flow; addresses C6 in recoupable/chat#1902.

  • New Features
    • Remove alias duplicates in the model list by id and normalized display name.
    • Badge premium models with a "Pro" chip based on pricing via isPremiumModel (missing/unparseable pricing is treated as premium).
    • For non‑subscribers selecting a premium model: keep current selection, show an info toast, and trigger useSubscribeClick (Stripe checkout).