AI model selector

mandatory

Dropdown/menu for choosing AI model mid-conversation. Capability chips (vision/tools/reasoning/long-context/voice), cost tier, recent-used, "auto" mode delegating to Kode Relay. Source-of-truth: registries/ai-model-recommendations.md. Required for Kortex/Talk power-user surfaces.

Spec — AI model selector

Backend: services/ai/modelreg/ + services/ai/gateway/ + services/ai/kode/ (Relay). Registry sourceoftruth: registries/ai-model-recommendations.md. Companion: cost-display.kmd (#112).

Princípios

  1. *apabilityfirst display*— user vê o que o model SUPORTA (visiontoolsreasoning/longcontext/voice), não só o nome.
  2. *ost transparency*— tier visible (1x10x100x); crosslink cost display permessage.
  3. *uto mode is the default*— Kode Relay routing escolhe modelo apropriado per task.
  4. *idconversation switch*— supported com warning de cache repriming cost.

R1 — Anatomia

Compact button (chat header chip): current model name + capability icons.

Tap → opens menu:

┌──────────────────────────────────────────┐
│ Auto · let Kode Relay decide            ✓ │
│ 1x cost · all capabilities                │
├──────────────────────────────────────────┤
│ Anthropic                                 │
│   Claude Opus 4.7  · 100x ✨🔧🧠📏       │
│   Claude Sonnet 4.6 · 10x  ✨🔧🧠📏      │
│   Claude Haiku 4.5  · 1x   ✨🔧🧠📏      │
├──────────────────────────────────────────┤
│ OpenAI                                    │
│   GPT-5            · 100x ✨🔧🧠📏       │
│   GPT-5 Mini       · 10x  ✨🔧🧠📏       │
├──────────────────────────────────────────┤
│ Google                                    │
│   Gemini 3 Pro     · 50x  ✨🔧🧠📏🔊    │
├──────────────────────────────────────────┤
│ Self-hosted Koder                        │
│   Koder LLM        · 1x   🔧🧠           │
├──────────────────────────────────────────┤
│ Recent: Claude Opus 4.7, GPT-5            │
└──────────────────────────────────────────┘

Slots:

Slot Content
Current chip name + cost tier + 3 prominent capability icons
Menu grouped by provider; capability chips per model; cost tier; recent

R2 — Capability chips

Icon Capability Description
vision Accepts image input
🔧 tools Native tool/function calling
🧠 reasoning Has thinking/reasoning mode
📏 long-context Context window > 200k tokens
🔊 voice Native voice input/output
🎨 multimodal Image generation, video, etc.

Source: model declared capabilities in modelreg. Refresh on session start.

R3 — Cost tier

Relative to baseline (base_cost-equivalent of cheapest available model in registry):

Tier Range
baseline
4-9× baseline
10× 9-30× baseline
50× 30-80× baseline
100× 80×+ baseline

Source: registries/ai-model-recommendations.md (per-model pricing). Tier displayed; absolute cost via cost-display.kmd (#112).

R4 — "Auto" mode

Default selection: "Auto · let Kode Relay decide".

Behavior:

  • Gateway request has model: "auto".
  • services/ai/kode/ Relay receives + analyzes task (prompt classification, attached content types, agent vs chat) + routes to best model.
  • Resulting model shown in response metadata; chip updates retroactively to show which model handled THIS message (not the next).

User can override (pick specific model); subsequent requests honor override.

R5 — Mid-conversation switch warning

Switching model mid-conversation has cost:

  • Previous context cached em old model (Anthropic prompt caching, OpenAI cached input, etc.) is lost.
  • New model needs full context re-priming.

When user switches mid-conversation:

┌─────────────────────────────────────────────┐
│ Switching model: warning                    │
│                                             │
│ The new model will need to re-read your    │
│ {N} message history. Estimated extra cost: │
│ {tokens} tokens (~{currency}).              │
│                                             │
│ [Cancel]                        [Switch]    │
└─────────────────────────────────────────────┘

Skip warning if context is empty (new conversation).

R6 — Recent-used

Maintain MRU list per (koder_user_id, workspace_id). Top 3 surfaced as quick-pick group.

R7 — Per-tenant default

Workspace settings allow default_model: "<model_id>" override of Auto. Per-user override possible. Cascade: user > workspace > stack default (Auto).

R8 — Surface bindings

Surface API
Flutter KoderModelPicker({onModelChange, currentModel}) em koder_kit/lib/src/ai/model_picker.dart
Web <koder-model-picker>
Compose Android KoderModelPicker (futuro)
SwiftUI iOS idem (futuro)
CLI / TUI koder model list + koder model use <id> + setting in TOML

R9 — Acessibilidade

  • Button: aria-haspopup="menu" aria-expanded="...".
  • Menu: role="menu" + items role="menuitem".
  • Provider groups: role="group" aria-label="<provider>".
  • Selected: aria-checked="true".
  • Keyboard nav: arrows + Enter + Esc.
  • Screen reader announces model name + cost tier + 3 capabilities.

R10 — i18n

Key en-US pt-BR
ai.model.auto.label "Auto" "Automático"
ai.model.auto.subtitle "Let Kode Relay decide" "Deixar a Kode Relay decidir"
ai.model.recent "Recent" "Recentes"
ai.model.capability.vision "Vision" "Visão"
ai.model.capability.tools "Tools" "Ferramentas"
ai.model.capability.reasoning "Reasoning" "Raciocínio"
ai.model.capability.long_context "Long context" "Contexto longo"
ai.model.capability.voice "Voice" "Voz"
ai.model.switch.warning_title "Switching model" "Trocando modelo"
ai.model.switch.warning_body "Re-reading history may add cost." "Reler o histórico pode adicionar custo."

R11 — Per-preset variation

Cosmetic: button shape per preset; menu fill; chip styles. Content fixed.

T-suite

  • *1*Mount: button shows current model + 3 capability icons; "Auto" by default.
  • *2*Open menu: tap button → menu populates from modelreg.
  • *3*Capability chips: model with vision+tools+reasoning shows correct icons.
  • *4*Cost tier display: model priced 50x baseline → "50×" badge.
  • *5*Switch: select different model → onModelChange callback fires.
  • *6*Switch warning: existing conversation + switch → confirmation dialog.
  • *7*Auto mode: select Auto → gateway request includes model="auto".
  • *8*Recent: switch twice → recent group has 2 entries.
  • *9*Per-tenant default: workspace sets default_model → loaded on new conversation.
  • *10*A11y: arrow keys nav menu; Enter selects.
  • *1*Modelreg unavailable: graceful fallback to Auto only.
  • Companion: cost-display.kmd (#112)
  • Backend: services/ai/modelreg/, services/ai/gateway/, services/ai/kode/
  • Registry: registries/ai-model-recommendations.md
  • Policies: multi-tenant-by-default.kmd (per-workspace default)

Source: ../home/koder/dev/koder/meta/docs/stack/specs/ai-ui/model-selector.kmd