Reasoning block
The thinking of a reply: a shimmering label counts seconds while the newest lines stream, then it folds to “Thought for 7s” and opens to the steps.
oxyn add reasoning-blockrsx! {
ReasoningBlock {
reasoning: thoughts,
status: "thinking",
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Reasoning models think before they answer — seconds to minutes.
- Users want two opposite things from that time: proof it is working and roughly on what ("Thinking 8s · Checking the auth flow"), and not to read it once the answer arrives.
- The converged pattern is a block that auto-opens while streaming and collapses to "Thought for Ns" when the answer starts; Warp streams a "Thinking…" header that collapses to "Thought for…"; Roo ticks a live seconds counter on its reasoning block; Cline expands its body into a 150 px scrolling area; Claude desktop offers a three-level transcript density switch Normal / Thinking / Verbose (all note 03 / 08).
- Agent runs add complications chat kits skip: reasoning resumes between tool calls, providers may send summaries instead of raw thought, or redacted / encrypted reasoning that must never be shown, and auto-collapse must not yank text out from under someone reading it.
When not to use
- The verb that says what the agent is doing, rotating through a verb pack while it works and settling into the past tense when it finishes: use Verb cycler instead.
- How long the agent has worked, without the time it spent waiting for you: use Elapsed timer instead.
- A label with light passing over it while the agent works: use Text shimmer instead.
Installation
Reasoning block 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.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add reasoning-blockuse crate::oxyn::{ReasoningBlock, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ReasoningBlock, STATUS_INDICATOR_CSS};
Usage
rsx! {
ReasoningBlock {
reasoning: thoughts,
status: "thinking",
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Examples
Thinking
Shimmering label, seconds and the latest lines.
Code
rsx! {
ReasoningBlock {
reasoning: thoughts,
status: "thinking",
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Done
Folded to “Thought for 7s”.
auth_refresh fails about one run in twenty, always when the token is minted at second 59.
The expiry check is a strict less-than against now(), with no leeway for skew between minting and checking.
A leeway of 30 seconds matches RFC 9068 guidance. Freezing the clock in the test makes the failure reproducible.
Patch token.rs, add a regression test, rerun three times.
Code
rsx! {
ReasoningBlock {
reasoning: thoughts,
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Open
Open: steps parsed from headings.
auth_refresh fails about one run in twenty, always when the token is minted at second 59.
The expiry check is a strict less-than against now(), with no leeway for skew between minting and checking.
A leeway of 30 seconds matches RFC 9068 guidance. Freezing the clock in the test makes the failure reproducible.
Patch token.rs, add a regression test, rerun three times.
Code
rsx! {
ReasoningBlock {
reasoning: thoughts,
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Error
Interrupted with Retry.
auth_refresh fails about one run in twenty, always when the token is minted at second 59.
The expiry check is a strict less-than against now(), with no leeway for skew between minting and checking.
A leeway of 30 seconds matches RFC 9068 guidance. Freezing the clock in the test makes the failure reproducible.
Patch token.rs, add a regression test, rerun three times.
Code
rsx! {
ReasoningBlock {
reasoning: thoughts,
status: "error",
seconds: Some(7),
on_stop: move |_| run.abort(),
}
}Verbose
Verbose display level stays open (Oxyn plus).
auth_refresh fails about one run in twenty, always when the token is minted at second 59.
The expiry check is a strict less-than against now(), with no leeway for skew between minting and checking.
A leeway of 30 seconds matches RFC 9068 guidance. Freezing the clock in the test makes the failure reproducible.
Patch token.rs, add a regression test, rerun three times.
Code
rsx! {
ReasoningBlock {
reasoning: thoughts,
seconds: Some(7),
level: "verbose",
on_stop: move |_| run.abort(),
}
}API reference
ReasoningBlock
| Prop | Type | Default | Description |
|---|---|---|---|
reasoningrequired | String | — | Full reasoning (revealed over `elapsed_ms` while thinking). |
status | String | "done" | `thinking` · `done` · `stopped` · `error`. |
seconds | Option<u64> | Default::default() | Seconds spent (done); measured from `elapsed_ms` while thinking. |
elapsed_ms | u64 | Default::default() | Milliseconds since thinking started. |
cps | f32 | 60.0 | Characters per second while thinking. |
model | String | "Atlas" | Model name. |
variant | String | "card" | `card` · `plain`. |
level | String | "normal" | `normal` · `thinking` · `verbose`. |
open | bool | Default::default() | Start open. |
error | Option<String> | Default::default() | Error reason. |
on_stop | EventHandler<()> | — | Stop pressed. |
on_retry | EventHandler<()> | — | Retry pressed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| EnterorSpace | Open or close the reasoning |
| Tab | Header, Stop / Retry, Copy reasoning |
Accessibility
- The header is a button with aria-expanded and the visible label as its name.
- A polite region announces status changes only, never each chunk or second.
- The live preview is aria-hidden; the full region is aria-busy while streaming.
From the spec
- Header is a disclosure button (
aria-expanded,aria-controls→ body region). Accessible name by state: "Thinking, 8 seconds" (live) / "Thought for 12 seconds, summary, collapsed" / "Thought for 12 seconds, reasoning hidden by the provider". - Body:
role="region"labelled "Reasoning"; while livearia-busy="true"; neveraria-live— reasoning is not read aloud as it streams. - Announcements (composer polite live region): "Thinking" when the block appears (only if no other status announcement in the last 10 s), "Thought for 12 seconds" once at the roll (throttled with the status-text rules); level switch: "Reasoning display: Verbose".
- Auto-collapse never moves focus. If focus is inside the body when a collapse would happen, the reader guard defers it; if the user collapses manually, focus returns to the header.
- Contrast: body text uses
text.secondary≥ 4.5:1; the live fade mask covers only already-read lines and never sits over the newest line; the 🔒 and "Summary" chips carry text labels. - Reduced motion: §5 last row; the live timer is the liveness cue.
- Keyboard: Tab reaches the header; Enter/Space toggles; inside the body, arrow keys scroll the live window; Ctrl+O level cycle is announced and remappable.
Motion & interaction
- Appear (Pending → Live): header fades + rises 4 px (180 ms,
dur.row.enter); inThinkinglevel the body window opens 0 → first line height, then grows with content up to 160 px. - Header while live: verb shimmer (
text-shimmer/calm, status-text family timings), timer ticks at 1 Hz with digit roll; chevron ▾ static (no idle motion). - Body window: text reveals with the message's reveal effect (word-level
fade-tokenby default; terminalline-commit); auto-follows the tail inside the window; 24 px top fade mask; user scroll inside detaches the window's follow (re-attach at bottom). - Toggle: chevron rotates 90° (› ↔ ▾) 160 ms
spring.snap; body height animatesdur.collapse(grid 0fr ↔ 1fr style; Claude desktop expands in .2 s, Cline 250 ms max-height, note 08); body opacity 0 ↔ 1 over 120 ms, starting 40 ms after height on open, ending before height on close. - Auto-collapse: 400 ms wait → header verb rolls to past tense (240 ms) while the body folds (200 ms); shimmer finishes its current sweep ≤ 400 ms or fades.
- Hover (done): header text to full fg (from 85 %), chevron nudges 2 px in the open direction (120 ms); tooltip after 600 ms: "Thought for 12 s · 1,240 tokens" when known.
- Redacted 🔒: lock fades in with the past-tense roll; no special animation.
- Interrupted: header swaps to "Stopped thinking after 8s" with the status strip's drop timing (220 ms
ease.firm); body collapses immediately (no 400 ms wait). - Level switch: all unpinned blocks animate together (one batch, no stagger) plus the 1.5 s toast.
Timing
| Transition | Duration | Delay | Easing / spring | Stagger | Frame rate |
|---|---|---|---|---|---|
| Appear (header) | 180 ms, y +4 → 0 | show_delay 300 ms | ease.out | — | 60 Hz |
| Body window grow | continuous with content, cap 160 px | — | spring.snap per line | — | 60 Hz |
| Header shimmer | per text-shimmer/calm | 600 ms after text change | ease.coast | — | 30 Hz |
| Timer tick | 1 Hz, digit roll 280 ms | — | ease.out | 30 ms | 30 Hz |
| Live subtitle swap | 180 ms | ≥ 2 s since last swap | ease.out | — | 30 Hz |
| Toggle chevron | 160 ms | 0 | spring.snap | — | 60 Hz |
| Expand / collapse height | 200 ms (dur.collapse) | 0 | cubic-bezier(0.22, 1, 0.36, 1) (ease.out) | — | 60 Hz |
| Body opacity (open / close) | 120 ms | 40 ms / 0 | ease.out / ease.in | — | 60 Hz |
| Auto-collapse | 400 ms wait + 200 ms | reader guard + 1500 ms | ease.in-out | — | 60 Hz |
| Present → past roll | 240 ms (dur.tense.roll) | after shimmer ends | ease.out | — | 60 Hz |
| Interrupted swap | 220 ms | 0 | ease.firm | — | 60 Hz |
| Level-switch batch | 200 ms + toast 1.5 s | 0 | ease.in-out | none | 60 Hz |
| Reduced motion | no shimmer (plain "Thinking"), timer digits swap without roll, height snaps with an 80 ms opacity crossfade, no chevron rotation (glyph swap), subtitle swaps by 80 ms crossfade every ≥ 4 s, auto-collapse still waits 400 ms then snaps | — | linear | none | 1 Hz timer |
Responsive behaviour
- The header is 44 px in every state; actions never shift it.
Edge cases (spec)
- Very short thinking (< 300 ms): never shown. 300 ms – 1 s: "Thought briefly".
- Very long thinking (> 10 min): timer switches format (
10m 04s,1h 02mper elapsed-timer); live window keeps the tail only (older lines virtualised); subtitle swaps slow to every 4 s (proposed). - Huge reasoning bodies (> 50 KB): expanded
Doneview virtualises like any message body; "Show all" past 40 lines. - Thinking ↔ tool bouncing every few hundred ms: the 400 ms collapse delay absorbs it; if a turn produces > 6 segments, segments after the 6th auto-merge into the previous block with a thin divider (proposed) to avoid a wall of headers.
- Reasoning after the answer started (some models interleave): the new segment appears below the answer text so far, collapsed in
Normal/Thinkinglevels ("Thought for 3s ›"), never above it. - Redacted then raw in the same turn: each segment keeps its own kind.
- Timestamps missing: header "Thought" without a duration; never show "Thought for 0s".
- Offline / stalled mid-thinking: the status row and header stall ramp handle it; the block keeps its partial body.
- RTL: header mirrors (chevron points to the inline-start when collapsed: ‹ in RTL), duration in a bidi isolate; body follows text direction; leading rule moves to the right.
- CJK: subtitle truncation counts graphemes ×1.6 weight (status-text §5.6).
- Tiny sizes:
reasoning-block/dense20 px row; at < 240 px the header shows only the timer and a 12 px glyph. - Dense IDE: default level
Normalfor IDE presets (proposed) — side panels are short. - Touch: whole header is the toggle (≥ 44 px tall on mobile); live window scrolls inside with axis lock.
- Background tab: body reveal pauses; on return, received text appears with one block fade (text-reveal); the collapse that would have happened applies instantly.
- Copy: message copy excludes reasoning except in
Verbose; the block's own⋯ → Copy reasoningcopies visible (non-redacted) text only.
Notes for AI
- Import
ReasoningBlockfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
ReasoningElinoxyn_gpui. - Props to set first:
reasoning. - 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.