Skip to content
Back

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
MCP
  1. Yesterday
  2. Sam09:00
    Did the deploy go out?
  3. Yes, 2.3.1 is live on staging.
  4. Today
  5. Sam09:00
    Auth tests are flaky again 😬
    Third time this week.
  6. Atlas09:02
    I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?
    auth-fix.diff
  7. 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-thread
Rust
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.

  1. Yesterday
  2. Sam09:00
    Did the deploy go out?
  3. Yes, 2.3.1 is live on staging.
  4. Today
  5. Sam09:00
    Auth tests are flaky again 😬
    Third time this week.
  6. Atlas09:02
    I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?
    auth-fix.diff
  7. 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.

  1. Yesterday
  2. Sam09:00
    Did the deploy go out?
  3. Yes, 2.3.1 is live on staging.
  4. Today
  5. Sam09:00
    Auth tests are flaky again 😬
    Third time this week.
  6. Atlas09:02
    I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?
    auth-fix.diff
  7. 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.

  1. Yesterday
  2. Sam09:00
    Did the deploy go out?
  3. Yes, 2.3.1 is live on staging.
  4. Today
  5. Sam09:00
    Auth tests are flaky again 😬
    Third time this week.
  6. Atlas09:02
    I traced it to the expiry check at second 59. Fix is two lines; want me to open a PR?
    auth-fix.diff
  7. 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

PropTypeDefaultDescription
participantsrequiredVec<Participant>—Participants.
merequiredString—Your id.
messagesrequiredVec<ChatMessage>—Messages, oldest first.
typingVec<String>Default::default()Typing ids.
read_byVec<(String, String)>Default::default()Last read message id per participant: (participant, message id).
now_msu64Default::default()"Now" for day labels (ms).
composerbooltrueComposer.
heightf32420.0Height px.
on_sendEventHandler<String>—Sent.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
EnterSend
ShiftEnterNew line
TabReaction buttons show on focus
EscapeClose 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) with aria-busy="true" while a page loads; each message is role="article" with aria-labelledby = author + time ("Agent, 14:02") and aria-posinset / aria-setsize (set size = -1 when unknown). No aria-live on the transcript (a role="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_delay 300 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 with dur.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.highlight at 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)

TokenValueUsed for
dur.actions.reveal120 ms fade, 80 ms hover intent delayfooter actions on hover / focus
dur.actions.hide160 ms, 300 ms after pointer leavesfooter actions hide
dur.copy.confirm1500 ms hold, then 160 ms revertcopy → ✓
dur.collapse200 ms (grid-rows 0fr ↔ 1fr style height spring)reasoning, long output, sources expand / collapse (Claude desktop expand .2 s, note 08)
delay.preview.open / .close300 ms / 150 ms gracecitation hover cards, timestamp tooltips
dur.version.swap180 ms crossfade + height spring.snapbranch ‹ 2/3 › switch
dur.row.enter180 ms, y +4 → 0system rows, source cards, chips
stagger.chips40 ms, cap 5follow-ups, starter prompts, source cards
highlight.flash600 ms hold + 900 ms fadedeep links, search hits, citation targets
Reduced motionall 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 after Done.
  • 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-panel at 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 ChatThread from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: ChatThreadEl in oxyn_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.

Guides

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