Skip to content
Back

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-switch
Tell the agent what to do…⇧⇥ to switch
The code is part of Oxyn Pro

The preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.

Get Pro

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.

Terminal
oxyn add mode-switch

Usage

Dioxus · rust
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Examples

Segmented

Ask · Plan · Agent segments.

Tell the agent what to do…⇧⇥ to switch
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Menu

A compact chip with a list.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Busy

Mid-run: the change waits for the next turn.

Tell the agent what to do…⇧⇥ to switch
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Plan

Plan mode changes the placeholder.

Describe what to plan…⇧⇥ to switch
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

API reference

ModeSwitch

PropTypeDefaultDescription
modesVec<Mode>default_modes()Modes (default Ask · Plan · Agent).
valueString"agent"Initial mode id.
busyboolDefault::default()The agent is running.
variantString"segmented"Variant: `segmented` or `menu` (a compact chip with a list).
previewbooltrueShow the composer preview (placeholder follows the mode).
on_changeEventHandler<(String, bool)>—Changed: (mode id, applied now).

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
TaborEnterReach and choose a mode
ShiftTab in the previewCycle modes
EscapeClose 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: radiogroup labelled "Mode", segments radio with aria-checked; chip-menu: button with aria-haspopup="menu", items menuitemradio.
  • 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
TransitionDurationDelayEasing / springNotes
Hover bg80 ms0ease-out—
Tooltip120 ms500 msease-out—
Segment indicator glide~220 ms0spring 420 / 34—
Tone crossfade (chip, border, send)200 ms0ease-in-outsame frame start
Label morph~240 ms0spring 300 / 30; 20 ms letter stagger—
Chip width~240 ms0spring 300 / 30—
Mode sheen900 ms60 msease-out[research 08 §1.18, MIT]
Placeholder crossfade160 ms out + 160 ms in (overlap 80 ms)0ease-out—
Shift+Tab nudge140 ms0spring 600 / 22—
Announcement / on_change debounce300 ms———
Menu open / close~200 ms / 120 ms0spring 380 / 32 / ease-in—
PendingNext badge180 ms0ease-out—
Restrict-now note in / hold / out160 / 2400 / 160 ms0ease-out / — / ease-in—
Suggested ghost in200 ms0ease-out—
Reduced motiontone, 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-menu when 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: minimal or glyph variant; 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 (ApplyNow adapters), 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: PendingNext persists; 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 ModeSwitch from oxyn_dioxus and include COMPOSER_CSS plus the token stylesheet once.
  • A GPUI version exists: ModeSwitchEl in oxyn_gpui.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI