AI chatPro
A full AI chat block: a user turn, the assistant thinking, searching and streaming a cited answer, then actions.
oxyn add ai-chatWhy does auth.rs fail at the minute boundary?
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.
Rendered from Rust at build time · goes live when visible
When to use
- The transcript is where the user reads what the agent did and decides what to do next.
- In an agent app it is not a chat log: one user message can produce minutes of interleaved reasoning, tool rows, approvals, partial answers and a final answer, and the user will scroll back through hours of it, copy code out of it, branch it, and grade it.
- Every product we studied converges on the same pieces — message action bars, "Thought for Ns" reasoning, inline citations, follow-up chips, edit-to-branch arrows, auto-scroll with a "jump to latest" button — and the free agent layer is commoditised across 6–12 React kits (note 01).
- What none of them gives a Rust app is the agent-shaped transcript: turns that hold a whole run, a scroller that never fights the reader while tokens stream, and every part driven by the same AgentState.
When not to use
- The prompt box for an agent, in six layouts: use Composer instead.
- Streamed text arriving: use Text Reveal instead.
- Grey shapes the size of what they stand in for, one sheen sweeping across all of them in step (or a staggered pulse), shown only after a short delay, then a crossfade into the content: use Skeleton instead.
Installation
AI chat 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 ai-chatUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Full
Reasoning, sources and a streamed answer.
Why does auth.rs fail at the minute boundary?
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Plain
Just the answer.
Why does auth.rs fail at the minute boundary?
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Done
Finished.
Why does auth.rs fail at the minute boundary?
The failure only shows when the token is minted at :59.
The expiry check uses a strict less-than with no leeway.
Add a 30 second leeway and a regression test that freezes the clock.
- Rrfc-editor.org1RFC 9068: JWT Profile for OAuth 2.0 Access Tokens
- Ddocs.rs2jsonwebtoken crate: Validation::leeway
- github.com3Flaky tests at the minute boundary
The test fails when a token is minted in the last second of a minute: exp is checked a few milliseconds later and the strict comparison rejects it .
Fix: add a small leeway to the expiry check, as the crate supports :
let mut v = Validation::new(Algorithm::RS256);
v.leeway = 30; // seconds
This matches the issue reported in #482 .
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
AiChat
| Prop | Type | Default | Description |
|---|---|---|---|
elapsed_ms | u64 | u64::MAX | ms since the reply started. |
reasoning | bool | true | Show the reasoning block. |
sources | bool | true | Show sources. |
height | f32 | 520.0 | Height px. |
children | Element | Default::default() | Composer (rendered under the log). |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Through the transcript to the composer |
Accessibility
- The transcript is a polite log; each turn is an article.
From the spec
- Transcript:
role="feed"(WAI-ARIA feed pattern) witharia-busy="true"while a page loads; each message isrole="article"witharia-labelledby= author + time ("Agent, 14:02") andaria-posinset/aria-setsize(set size = -1 when unknown). Noaria-liveon the transcript (arole="log"would read tokens aloud — rejected). - Keyboard: PageDown / PageUp move focus between articles (feed pattern);
[/]previous / next turn (proposed); within an article, Tab reaches links, code-block buttons, citations, then actions. Esc returns focus to the composer. - Announcements (via the composer's single polite live region): "Response complete" once per turn; "3 new messages" when detached (throttled 1 per 10 s); errors and "Needs your approval" assertive.
- Focus never jumps because content arrived; streaming never steals focus from the composer.
- Contrast: body text ≥ 4.5:1 on every bubble fill; muted system rows ≥ 4.5:1 (muted is a hue/ weight choice, not a contrast cut); the 60 % "unread" fade on mid-run messages keeps ≥ 4.5:1 by dimming the fill, not the text (proposed).
- Reduced motion: §6 table; scrolls instant.
- Zoom 200 %: bubbles reflow, max-width becomes 100 %; no horizontal page scroll (code blocks scroll internally).
Motion & interaction
- New user message: arrives via the composer's fly-up (≤ 260 ms, composer.md §4); the transcript reserves its final height in the same frame so nothing jumps.
- Agent message appears: the status line / thinking row occupies the agent slot first (loaders.md §3.3
show_delay300 ms); first content replaces it in place (no slide). - System / event row: fades in with a 4 px rise, 180 ms.
- Hover: message footer actions fade from 0 → 100 % (desktop); timestamp appears in the header. Touch surfaces show actions persistently on the last agent turn and on long-press for others (pattern "hover on desktop, persistent on mobile", note 04 §2g).
- Jump pill: slides up 8 px + fade (160 ms
ease.out); count rolls withdur.digit.roll; on click the pill shrinks to 0.9 and fades as the scroll begins. - Deep-link flash: target block background tints with
color.highlightat 24 % alpha, holds 600 ms, fades 900 ms. - Day separator: sticky header crossfades between days (120 ms) rather than pushing.
Family-E motion tokens (proposed; shared tokens keep their composer.md values)
| Token | Value | Used for |
|---|---|---|
dur.actions.reveal | 120 ms fade, 80 ms hover intent delay | footer actions on hover / focus |
dur.actions.hide | 160 ms, 300 ms after pointer leaves | footer actions hide |
dur.copy.confirm | 1500 ms hold, then 160 ms revert | copy → ✓ |
dur.collapse | 200 ms (grid-rows 0fr ↔ 1fr style height spring) | reasoning, long output, sources expand / collapse (Claude desktop expand .2 s, note 08) |
delay.preview.open / .close | 300 ms / 150 ms grace | citation hover cards, timestamp tooltips |
dur.version.swap | 180 ms crossfade + height spring.snap | branch ‹ 2/3 › switch |
dur.row.enter | 180 ms, y +4 → 0 | system rows, source cards, chips |
stagger.chips | 40 ms, cap 5 | follow-ups, starter prompts, source cards |
highlight.flash | 600 ms hold + 900 ms fade | deep links, search hits, citation targets |
| Reduced motion | all of the above → 0–80 ms opacity crossfades; heights snap; no stagger; scrolls instant; the copy ✓ still holds 1500 ms (it carries meaning) | — |
Responsive behaviour
- Fills its container up to 760 px.
Edge cases (spec)
- Very long threads (10 000+ messages, 100 MB text): block virtualisation (§4.1); history paged in 50-turn pages (proposed); search runs on the store.
- Very long single turns (hour-long runs): older blocks inside the turn virtualise; the turn header ("Turn 7 · Worked for 1h 02m") becomes sticky while the turn is in view (proposed).
- Very fast agent: answer completes before the status row's 300 ms
show_delay— the row never shows; footer actions fade in afterDone. - Very slow agent: status row and loaders handle liveness; transcript only follows.
- Out-of-order / late events (a tool result arriving after the next prose block): blocks are ordered by the adapter's sequence id, not arrival time; a late block inserts in place and the anchor rule compensates if above the viewport.
- Edits of earlier messages while a run is active: see message-bubble §edit (stop-then-branch).
- RTL: chat layout mirrors (user bubbles on the left); code, numbers, diff stats stay LTR in bidi isolates; the jump pill stays centred.
- Tiny / dense:
transcript/ide-panelat 280 px: avatars and headers off, actions in a⋯menu. - Touch: long-press a message → action sheet; swipe-right on a user message = quote/reply (Pro).
- Slow networks / offline: cached pages render; uncached older pages show "Offline · Earlier messages unavailable"; sends queue in the composer (composer edge cases).
- Mixed content heights (images arriving late): images reserve aspect-ratio boxes from metadata; unknown ratio = 16:9 at 40 % column width (same rule as text-reveal §5) and the anchor compensates.
Notes for AI
- Import
AiChatfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - There is no GPUI version yet; use the Dioxus component.
- 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.