Mode switchPro
Switch the agent between Ask, Plan and Agent: segmented or as a menu, a placeholder that follows the mode, and a change that waits for the next turn while it runs.
oxyn add mode-switchThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Agent apps let the user say *what kind of work* the next message asks for: Ask (answer, read-only, no edits), Plan (research and produce a plan to approve before anything changes), Agent (also called Act / Build / Code: edit files and run tools).
- Apps add their own (Debug, Review, Research, Spec, Mission).
- The mode switch sits at the left of the composer row.
- The user wants to change mode in one key without leaving the keyboard, see the current mode from the corner of their eye (colour, placeholder, send-button tint), and trust what happens if they switch while the agent is running.
When not to use
- How much the agent may do without asking: use Permission selector instead.
- Prompt composer with model picker, voice input, app connections and approval request: use Chat Composer instead.
- The model menu of an AI chat: use Model Picker instead.
Installation
Mode switch is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add mode-switchUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Segmented
Ask · Plan · Agent segments.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Menu
A compact chip with a list.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Busy
Mid-run: the change waits for the next turn.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Plan
Plan mode changes the placeholder.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
ModeSwitch
| Prop | Type | Default | Description |
|---|---|---|---|
modes | Vec<Mode> | default_modes() | Modes (default Ask · Plan · Agent). |
value | String | "agent" | Initial mode id. |
busy | bool | Default::default() | The agent is running. |
variant | String | "segmented" | Variant: `segmented` or `menu` (a compact chip with a list). |
preview | bool | true | Show the composer preview (placeholder follows the mode). |
on_change | EventHandler<(String, bool)> | — | Changed: (mode id, applied now). |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| TaborEnter | Reach and choose a mode |
| ShiftTab in the preview | Cycle modes |
| Escape | Close the menu variant |
Accessibility
- Segments are a radiogroup with aria-checked; the menu is a listbox.
- A queued change is announced: “Plan from the next turn”.
From the spec
- Segmented:
radiogrouplabelled "Mode", segmentsradiowitharia-checked; chip-menu:buttonwitharia-haspopup="menu", itemsmenuitemradio. - Labels per state: "Mode: Plan. The agent will plan before changing anything. Shift+Tab to change", "Mode: Ask, switching to Agent from your next message", "Mode Plan unavailable: needs a reasoning model".
- Live region (polite, debounced 300 ms): "Plan mode", "Agent mode from your next message", "Plan mode: remaining edits will ask first".
- The send button's accessible name follows mode ("Plan", "Ask", "Run") while its role stays "send".
- Colour is never the only signal: glyph + label + placeholder change with the tone. Mode tones meet 3:1 for the chip border/indicator and 4.5:1 for labels in both themes (Studio contrast check).
- Focus order: model → effort → mode (or first in row if the app puts it left) → permission → context → send. Shift+Tab cycling does not move focus.
Motion & interaction
- Segment indicator: a single pill-shaped indicator glides between segments (shared layout) and its colour crossfades from old to new mode tone.
- Label morph (chip variants): shared letters glide, new letters blur in (blur 4 px → 0) with a re-implemented).
- Mode sheen: on apply, one 900 ms ease-out sheen sweeps across the chip label (the MonoCode composer mode shimmer: single sweep, gradient at 100°, peak
color-mix(currentColor 25 %, white)[research 08 §1.18, MIT]). - Composer follow: focus border colour crossfades; placeholder crossfades (old fades out y 0 → −3 px, new fades in y +3 px → 0); send control accent crossfades. All three start on the same frame.
- Shift+Tab feedback: each press nudges the chip 2 px in the cycle direction and springs back, so rapid cycling feels like a detented wheel.
- PendingNext badge: slides out of the chip with a dashed outline; merges back at run end.
- Restrict-now note: slides down from the chip; any tool row currently "queued for auto-run" in the transcript flips to "Awaiting approval" (that row animation belongs to the tool-call spec).
- Suggested: ghost chip fades in at 60 % opacity with a 1 px dashed outline; accept morphs it into the real chip (the old chip slides away).
- Plan approved → Agent: the plan card's "Build" button flies a small spark to the mode chip, then the chip morphs Plan → Agent (one choreography shared with the plan card spec).
Timing
| Transition | Duration | Delay | Easing / spring | Notes |
|---|---|---|---|---|
| Hover bg | 80 ms | 0 | ease-out | — |
| Tooltip | 120 ms | 500 ms | ease-out | — |
| Segment indicator glide | ~220 ms | 0 | spring 420 / 34 | — |
| Tone crossfade (chip, border, send) | 200 ms | 0 | ease-in-out | same frame start |
| Label morph | ~240 ms | 0 | spring 300 / 30; 20 ms letter stagger | — |
| Chip width | ~240 ms | 0 | spring 300 / 30 | — |
| Mode sheen | 900 ms | 60 ms | ease-out | [research 08 §1.18, MIT] |
| Placeholder crossfade | 160 ms out + 160 ms in (overlap 80 ms) | 0 | ease-out | — |
| Shift+Tab nudge | 140 ms | 0 | spring 600 / 22 | — |
Announcement / on_change debounce | 300 ms | — | — | — |
| Menu open / close | ~200 ms / 120 ms | 0 | spring 380 / 32 / ease-in | — |
| PendingNext badge | 180 ms | 0 | ease-out | — |
| Restrict-now note in / hold / out | 160 / 2400 / 160 ms | 0 | ease-out / — / ease-in | — |
| Suggested ghost in | 200 ms | 0 | ease-out | — |
| Reduced motion | tone, label, placeholder swap with 80 ms opacity; no glide (indicator jumps), no sheen, no nudge, no letter morph | — | linear | — |
Responsive behaviour
- Use the menu variant where the segments do not fit.
Edge cases (spec)
- Long custom labels ("Security Review"): segmented truncates at 96 px per segment and falls back to
chip-menuwhen segments don't fit; full label in tooltip. - More than 4 modes: segmented shows the cycle-order first 3 + "More ⌄".
- RTL: segment order mirrors; Shift+Tab still moves "forward" in the logical cycle order.
- Tiny sizes (16–20 px): glyph-only chip; tone shown as a 3 px left bar plus glyph shape (never colour alone).
- Dense IDE panels:
minimalorglyphvariant; placeholder follow can be turned off. - Touch: segments ≥ 44 px tall; no Shift+Tab, so the chip is always tappable; long-press opens menu.
- Slow networks: mode is local; switching never waits on the network. If the app must tell the agent (
ApplyNowadapters), the chip applies optimistically and reverts with a note on failure. - Very fast agents: if the run ends < 300 ms after a pending switch, skip the badge.
- Very slow agents:
PendingNextpersists; repeated cycling updates the badge, not the run. - Shift+Tab conflicts: inside an autocomplete or mention list Shift+Tab belongs to that list; in a multi-field form it is reverse-tab. Apps can rebind (
shortcuts.cycle). - Mode + permission merged (Claude-style): the cycle includes permission presets; the dangerous ones (full access, bypass) are never in the cycle (see permission spec).
- Mode unavailable for current model: cycle skips it; if the current mode becomes unavailable after a model switch, fall back to the next lower-rank mode and show the reason.
- Queued messages: each queued chip keeps the mode it was queued in; its chip shows the mode tone.
Notes for AI
- Import
ModeSwitchfromoxyn_dioxusand includeCOMPOSER_CSSplus the token stylesheet once. - A GPUI version exists:
ModeSwitchElinoxyn_gpui. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.