Chat Components

Agent-grade chat UI you own. A shadcn/ui registry of the primitives an agent app needs — reasoning streams, tool-call rows, artifacts, streaming markdown, a session sidebar with drag-and-drop. Install one atom or the whole kit; the code lands in your repo and stays yours.

Built for agent turns

A chatbot renders one text stream. An agent turn is a transcript: it thinks, calls tools, fails and retries, produces files, and runs long enough that the session itself becomes something you manage. Each of those has a real surface here.

  • Reasoning. Collapsed “Thought for N seconds” above the answer, from an explicit reasoning prop or parsed out of <think> tags.
  • Tool calls. Rows with a pending / running / done / error lifecycle, collapsible input and output, and readable headlines. Many calls fold behind “Used N tools”.
  • Ask the user. AskQuestion is the Cursor questionnaire — radios, checkboxes, Other…, Skip and Continue. A pending Ask Question tool call renders it in the transcript.
  • Real ordering. parts interleaves text and tool segments, so the turn reads in the order the agent produced it.
  • Artifacts and code. Titled artifact cards with an optional preview and onOpen handoff, plus Streamdown markdown — GFM, Shiki, Mermaid, KaTeX.
  • Long streams. The message list sticks to the bottom while tokens arrive and lets go the moment the reader scrolls up; the composer swaps send for stop.
  • Sessions. A sidebar with rename, pin, delete, status dots, multi-line rows, drag-to-reorder, declarative drop zones, and keyboard dragging.

Quick start

In a project that already ran shadcn init, one command installs the starter block and every atom it composes.

npx shadcn@latest add miskibin/chat-components/chat

Prefer to pick and choose? Every item on the left installs on its own. See Installation for the full list and the two build settings the markdown renderer needs.

What this is

This is a custom registry, not an npm package. Running shadcn add copies real TypeScript files into components/ui — you own them, you can edit them, and nothing upgrades behind your back.

  • Standard tokens. Only the shadcn CSS variables — --background, --muted, --primary, --sidebar, --radius. Drop them into any shadcn theme and they take its colors.
  • className merges last. Every component runs its classes through cn(), so your overrides win.
  • Internals are addressable. Elements carry data-slot and state attributes, so a parent can restyle a composer surface or a tool row without a fork.
  • Slots, not config. The sidebar and navbar take nodes — no hard-wired product navigation.

Why not the AI SDK?

Vercel’s AI SDK is a good stack, and this is not a replacement for it — it is a different bet about where the seam belongs.

  • Protocol-agnostic. These components take plain props and callbacks. No useChat, no UIMessage, no required stream format — the ai package isn’t even a dependency. AI Elements is designed around the AI SDK’s message parts and hooks, which is zero glue if your backend speaks that protocol. If it doesn’t — a CLI agent, a LangChain service, a raw SSE endpoint, your own event union — you write one small adapter and the rest is normal React.
  • Agent-first depth. The tool-call lifecycle, reasoning disclosure, artifacts, and the session sidebar are the core of this registry, not extras around a message bubble.
  • UI only. The flip side: the AI SDK also gives you providers, tool calling, structured output, and a server runtime. This gives you none of that. Bring your own backend.
  • Not exclusive. Keep useChat and map its parts onto ChatMessageData — the README has the adapter.

Components

Messages

MessageOne conversation turn: a user bubble with inline editing, or an assistant answer that assembles reasoning, tool calls, markdown, code, and artifacts.Message ListScroll container with smart auto-scroll: it follows a streaming answer, and stops the moment the reader scrolls away.Message PartsThe atoms an assistant turn is made of — reasoning, tool calls, ask questions, highlighted code, and artifact cards. Use them directly when you build your own turn layout.Ask QuestionCursor-style questionnaire the agent can drop into a turn: single-select radios, multi-select checkboxes, an Other… field, Skip, and Continue.Plan CardThe plan a harness wrote before it started work — its markdown, its checklist, and the one Build button that moves the conversation on.Message MarkdownStreamdown renderer tuned for streaming answers: GFM, Shiki code, Mermaid diagrams, and KaTeX math, with incomplete markdown parsed safely.Render Error BoundaryOne block, isolated: a render that throws falls back to plain text instead of unmounting the message around it, and retries when its inputs change.Change SummaryThe card Cursor shows after a coding turn: file count, a Review action, a few rows with +/- stats, and “Show N more”. Pair it with WorkedFor for the elapsed-time badge.File PreviewThe right-hand panel Cursor opens when you click an edited file: the agent's diff, or the whole file with the edited lines marked and scrolled into view — both rendered by Diff View, so a megabyte costs the same as a page.Diff ViewA file or a diff rendered by @pierre/diffs — virtualized, syntax highlighted, split or unified — bound to the app's own tokens.File TreeA directory tree over a flat file list — git status colours, +/- counts, keyboard navigation, type-to-filter and per-node menus, virtualized by @pierre/trees.File IconMaterial Icon Theme file glyphs, inlined as SVG: a curated subset resolved by filename, then by extension, with a generic document fallback.Generation StatusA single breathing dot with an optional label, for the gap between sending a message and the first token.

Try it first