Model switcher
The model menu of an agent app: providers, favourites and recents, search, capability badges, a model that needs a key or is rate limited, Auto routing and a change that waits for the next turn.
oxyn add model-switcher⌘⇧M
AutoPicks per turn
Recent
GPT-6 Vision256KResets in 4:12
Favourites
Claude Haiku 5200K
Claude Opus 51M
LLocal Q 7B32K
Anthropic
Claude Haiku 5200K
Claude Opus 51M
OpenAI
GPT-6128KAdd API key
GPT-6 Vision256KResets in 4:12
On device
LLocal Q 7B32K
Context 200KSpeed Fast$1 / $5 per Mtok
Dioxus
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Rendered from Rust at build time · goes live when visible
When to use
- The model pill sits in the composer's control row (usually right of +, left of the send control).
- The user is choosing who does the next piece of work: a cheaper/faster model for a quick question, a reasoning model for a hard refactor, a vision model because an image is attached, or "Auto" so the app routes for them.
- The picker must answer three questions at a glance: *what will run next*, *can it do what my message needs* (images, tools, context length), and *what will it cost me in time and money*.
- It also has to be honest when a model cannot run right now (no key, rate-limited, down) and behave predictably when the user switches while an agent is mid-run.
When not to use
- How hard the model thinks: use Effort control instead.
- How full the context window is: use Context meter instead.
- Prompt composer with model picker, voice input, app connections and approval request: use Chat Composer instead.
Installation
Model switcher is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add model-switcherRust
use crate::oxyn::{ModelPicker, COMPOSER_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ModelPicker, COMPOSER_CSS};
Usage
Dioxus · rust
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Examples
Open
The full list.
⌘⇧M
AutoPicks per turn
Recent
GPT-6 Vision256KResets in 4:12
Favourites
Claude Haiku 5200K
Claude Opus 51M
LLocal Q 7B32K
Anthropic
Claude Haiku 5200K
Claude Opus 51M
OpenAI
GPT-6128KAdd API key
GPT-6 Vision256KResets in 4:12
On device
LLocal Q 7B32K
Context 200KSpeed Fast$1 / $5 per Mtok
Code
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Search
Searching "dp".
⌘⇧M
Claude Opus 51M
Code
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Pending
Deep 2 from the next turn.
→ Claude Opus 5
Code
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Favorites segmented
Favourites as segments.
Code
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
variant: "favorites-segmented",
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}Glyph
Terminal picker.
Select model
1. Auto
2. GPT-6 Vision 256K
›3. Claude Haiku 5 200K (current)
4. Claude Opus 5 1M
5. Local Q 7B 32K
6. GPT-6 128K
↑↓ move · enter select · esc close
Code
rsx! {
ModelPicker {
catalog: models(),
selected: model(),
picker: picker() // popover state: open, query, highlight,
favorites: favorites(),
variant: "glyph",
now: clock.now(),
on_choose: move |m: ModelSelection| model.set(m),
}
}API reference
ModelPicker
| Prop | Type | Default | Description |
|---|---|---|---|
catalogrequired | ModelCatalog | — | Host catalogue. |
selectedrequired | ModelSelection | — | Selected model. |
pending | Option<ModelSelection> | Default::default() | Waiting for the next turn (`→ Deep 4` badge). |
pickerrequired | Picker | — | Popover state. |
favorites | Vec<String> | Default::default() | Favourites (★, cycle order). |
recent | Vec<String> | Default::default() | Recently used, newest first. |
needs | DraftNeeds | Default::default() | What the draft needs (incompatibility notes). |
routing | bool | Default::default() | Auto is resolving during a run (three breathing dots). |
variant | String | "pill-popover" | `pill-popover` · `morph-list` · `command` · `glyph` · `compact` · `favorites-segmented`. |
nowrequired | ClockMs | — | Shared clock time (countdowns, routing dots). |
on_toggle | EventHandler<()> | — | Pill pressed. |
on_key | EventHandler<PickerKey> | — | A key in the popover. |
on_query | EventHandler<String> | — | Search text changed. |
on_choose | EventHandler<ModelSelection> | — | A row chosen. |
on_cancel_pending | EventHandler<()> | — | Pending badge × pressed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| ↑or↓ | Move through models |
| Enter | Choose |
| Esc | Close |
| Type | Search |
Accessibility
- The pill is a button with aria-haspopup=listbox and a full name ("Model: Claude Haiku 5. Change model").
- Search is a combobox controlling a listbox; unavailable models are aria-disabled with the reason.
- Capability badges have text alternatives, never colour only.
From the spec
- Pill:
button,aria-haspopup="listbox",aria-expanded. Label per state, e.g. "Model: Claude Sonnet 5. Change model", "Model: Auto, routed to Sonnet 5", "Model: Opus, rate limited, resets in 4 minutes", "Model locked by workspace policy". - Popover: search field is a
comboboxcontrolling alistbox; groups aregroupwith labels; rows areoptionwitharia-selectedandaria-disabled+aria-describedby→ reason text. - Capability badges are icons with text alternatives ("vision", "tools", "reasoning", "200 thousand token context", "fast", "cost: high"); never colour-only.
- Live region (polite): "12 models match", "No matches", "Switched to Opus", "Opus will be used from your next message", "Opus available again". Countdown is not announced every second; only at 60 s and 0.
- Focus order: search → Auto → Recent → Favourites → groups → footer link. Esc returns focus to the pill.
- Contrast: row text ≥ 4.5:1; dimmed unavailable rows keep reason text ≥ 4.5:1 (only the name dims).
- Reduced motion honoured from the global token.
Motion & interaction
- Hover: chip bg fades to
chip.hover; chevron translates +1 px y. No lift/shadow (control row stays flat). - Press: chip scales to 0.97 on pointer-down, springs back on release.
- Focus ring: 2 px
focus.ring, offset 2 px, appears without animation on keyboard focus only. - Open: the popover grows out of the pill: origin = pill's top-centre, scale 0.96 → 1, y +4 px → 0, opacity 0 → 1. Variant
morph-listinstead grows the pill surface itself into the list (corner - Rows enter: first 8 rows stagger 18 ms each (cap 144 ms); rows beyond 8 appear with the list.
- Highlight: one shared highlight rect glides between rows (spring) instead of per-row hover fades.
- Detail tray (footer strip, 44 px): shows context size, speed, cost for the highlighted row; numeric values roll (tabular digits) when the highlight moves.
- Capability badges: 16 px square icons with 1 px stroke; on search-filter toggle, matching badges pulse once (opacity 1 → 0.6 → 1).
- Select: the chosen row's name lifts and flies to the pill (shared-element, ≤ 260 ms), pill width springs to fit, label rolls up if the new model is above the old one in list order, down if Below.
- Close: reverse of open, faster, no overshoot.
- PendingNext badge: "→ Opus" slides out of the pill's right edge (x −6 → 0, opacity) with a dashed 1 px outline; on run end it merges into the pill (badge collapses, label rolls).
- Routing (Auto): three 3 px dots in the mark slot breathe in sequence; on resolve, dots collapse to the provider mark (scale 0 → 1) and the secondary label types in.
- RateLimited countdown:
m:ssdigits roll each second; at 0 the row's clock glyph morphs to the provider mark and the row un-dims. - Error (CatalogError): retry button shakes 2 cycles × 4 px only after a failed retry.
Timing
| Transition | Duration | Delay | Easing / spring | Notes |
|---|---|---|---|---|
| Hover bg | 80 ms | 0 | ease-out | — |
| Tooltip | 120 ms fade | 500 ms | ease-out | — |
| Press scale 0.97 ↔ 1 | ~120 ms | 0 | spring stiffness 600, damping 30 | close to button springs reported for Claude desktop [research 08 §1.4, RE] |
| Popover open (scale/opacity/y) | ~200 ms settle | 0 | spring 380 / 32 | no visible overshoot |
| Popover close | 120 ms | 0 | ease-in | — |
| Row stagger | 18 ms × index, cap 8 rows | 40 ms | ease-out 140 ms each | — |
| Highlight glide | ~120 ms | 0 | spring 500 / 40 | — |
| Detail tray digit roll | 320 ms | 0 | cubic-bezier(0.22, 1, 0.36, 1) | shorter cousin of OpenCode AnimatedNumber 560 ms [research 08 §1.5, MIT] |
| Name fly to pill | ≤ 260 ms | 0 | ease-in-out | — |
| Pill width | ~240 ms | 0 | spring 300 / 30 | — |
| Label roll | 220 ms | 0 | cubic-bezier(0.22, 1, 0.36, 1) | direction by list order |
| PendingNext badge in | 180 ms | 0 | ease-out | — |
| Routing dots | 1.2 s loop, 150 ms stagger | 0 | sine | shared motion clock |
| Skeleton rows | 1.6 s sweep | 150 ms grace | linear | — |
| Search filter | 0 ms (instant) | debounce 60 ms | — | list reorders without animation |
| Countdown digit | 200 ms | 0 | ease-out | 1 Hz |
| Frame rate | display rate (GPUI) / rAF (Dioxus); idle = no frames | — | — | — |
| Reduced motion | open/close = 100 ms opacity only; no stagger, no fly, no roll (labels swap); routing dots static …; highlight jumps | — | linear | — |
Responsive behaviour
- compact shows only the short name; the list opens upward from a bottom composer.
Edge cases (spec)
- Long names ("Claude Sonnet 5.5 Thinking 1M"): pill uses
short_nameif supplied, else end-ellipsis atmax_pill_width; popover rows wrap to 2 lines max, then ellipsis with full name in tooltip. - Many models (OpenRouter-style 300+): virtualised list (row height fixed 36 px / 48 px two-line), search auto-focused when
models.len() > 12, provider groups collapsible, group headers sticky. - Duplicate names across providers: always show provider mark + provider name in the row's second line.
- RTL: chevron moves to the left; list and tray mirror; digits stay LTR in tabular figures.
- Tiny sizes (16–20 px row):
compactvariant only: 16 px mark, no label, badge dots 4 px; the warning/limit state becomes a 4 px corner dot (amber/red) plus tooltip text. - Dense IDE panels: popover max height = min(420 px, 60 % of panel); opens below if above-space < 240 px.
- Touch: popover becomes a bottom sheet (snap points 50 % / 90 %), rows 44 px, ★ needs long-press.
- Slow networks: catalog fetched once and cached with timestamp; stale list usable, "Updated 3 h ago" in footer; validation calls never block selection.
- Very fast agents: if the run ends within 300 ms of a mid-run selection,
PendingNextis skipped and the switch applies directly (no badge flash). - Very slow agents:
PendingNextbadge persists for the whole run; hovering it explains "Applies to your next message". - Selected model removed from catalog: pill keeps the old label with warning dot and "No longer available · Choose another"; send control goes
Disabled(reason)until a choice is made. - Key added in another window: catalog event updates rows live;
NeedsKeyrows animate to available. - Attachments added after selection that the model can't read: pill shows warning dot; send control shows the reason; no automatic switch (we never change the model behind the user's back).
- Auto never resolves (adapter doesn't report): pill stays "Auto"; no fake model name.
Notes for AI
- Import
ModelPickerfromoxyn_dioxusand includeCOMPOSER_CSSplus the token stylesheet once. - A GPUI version exists:
ModelPickerElinoxyn_gpui. - Props to set first:
catalog,selected,picker,now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.