Chat thread
A conversation with grouped messages, day separators, reactions, read receipts, typing and a composer; agents join with their identity hue.
oxyn add chat-thread- Yesterday
- Sam09:00Did the deploy go out?
- Yes, 2.3.1 is live on staging.
- Today
- Sam09:00Auth tests are flaky again 😬Third time this week.
- Atlas09:02I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?auth-fix.diff
- Yes please, and add a regression test.Read · 09:03
Atlas is typing
Dioxus
rsx! {
ChatThread {
participants: vec![("me".into(), "Alex Rivera".into(), String::new()), ("atlas".into(), "Atlas".into(), "violet".into())],
me: "me",
messages: messages,
composer: true,
on_send: move |text: String| send(text),
}
}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
Chat thread 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 chat-threadRust
use crate::oxyn::{ChatThread, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ChatThread, STATUS_INDICATOR_CSS};
Usage
Dioxus · rust
rsx! {
ChatThread {
participants: vec![("me".into(), "Alex Rivera".into(), String::new()), ("atlas".into(), "Atlas".into(), "violet".into())],
me: "me",
messages: messages,
composer: true,
on_send: move |text: String| send(text),
}
}Examples
Team
A team thread with an agent.
- Yesterday
- Sam09:00Did the deploy go out?
- Yes, 2.3.1 is live on staging.
- Today
- Sam09:00Auth tests are flaky again 😬Third time this week.
- Atlas09:02I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?auth-fix.diff
- Yes please, and add a regression test.Read · 09:03
Atlas is typing
Code
rsx! {
ChatThread {
participants: vec![("me".into(), "Alex Rivera".into(), String::new()), ("atlas".into(), "Atlas".into(), "violet".into())],
me: "me",
messages: messages,
composer: true,
on_send: move |text: String| send(text),
}
}Failed
Your last message failed.
- Yesterday
- Sam09:00Did the deploy go out?
- Yes, 2.3.1 is live on staging.
- Today
- Sam09:00Auth tests are flaky again 😬Third time this week.
- Atlas09:02I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?auth-fix.diff
- Yes please, and add a regression test.Not delivered
Atlas is typing
Code
rsx! {
ChatThread {
participants: vec![("me".into(), "Alex Rivera".into(), String::new()), ("atlas".into(), "Atlas".into(), "violet".into())],
me: "me",
messages: messages,
composer: true,
on_send: move |text: String| send(text),
}
}Transcript
Read-only transcript.
- Yesterday
- Sam09:00Did the deploy go out?
- Yes, 2.3.1 is live on staging.
- Today
- Sam09:00Auth tests are flaky again 😬Third time this week.
- Atlas09:02I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?auth-fix.diff
- Yes please, and add a regression test.Read · 09:03
Code
rsx! {
ChatThread {
participants: vec![("me".into(), "Alex Rivera".into(), String::new()), ("atlas".into(), "Atlas".into(), "violet".into())],
me: "me",
messages: messages,
on_send: move |text: String| send(text),
}
}API reference
ChatThread
| Prop | Type | Default | Description |
|---|---|---|---|
participantsrequired | Vec<Participant> | — | Participants. |
merequired | String | — | Your id. |
messagesrequired | Vec<ChatMessage> | — | Messages, oldest first. |
typing | Vec<String> | Default::default() | Typing ids. |
read_by | Vec<(String, String)> | Default::default() | Last read message id per participant: (participant, message id). |
now_ms | u64 | Default::default() | "Now" for day labels (ms). |
composer | bool | true | Composer. |
height | f32 | 420.0 | Height px. |
on_send | EventHandler<String> | — | Sent. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Enter | Send |
| ShiftEnter | New line |
| Tab | Reaction buttons show on focus |
| Escape | Close the reaction picker |
Accessibility
- role=log, polite, additions; typing is a separate status.
- Reaction chips are toggles labelled “👍 3, including you”.
- Read receipts carry a label listing readers.
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
- Messages cap at 78 % width.
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
ChatThreadfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
ChatThreadElinoxyn_gpui. - Props to set first:
participants,me,messages. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.