# chat: the chat building blocks and the AI patterns

`kit/chat.mote` is shadcn/ui's chat primitives (Attachment, Bubble, Marker,
Message, Message Scroller, Questionnaire, Trace) and its AI Elements
patterns (the 21 at ui.shadcn.com/docs/ai-elements), under the original's
part names: 257 components. Gallery: `examples/kit/chat.mote`, a whole
working chat at the top and then every part in every state. Test:
`tests/kit_chat.real.mjs` (239 checks).

    mote dev examples/kit/chat.mote --port 5015 &
    node tests/real.mjs http://localhost:5015/ tests/kit_chat.real.mjs

Nothing here uses the AI SDK, a hook, a provider or a context. Plain page
state drives every component.

## A chat: state shape → components

There is no `createChat` and no `useChat`. The page holds the thread as a
list, each part is given the piece it shows, and the model's stream writes
the same fields. The gallery's chat is this, whole (copy it to start one):

    shape Reply                    // one version of the assistant's turn
      reasoning: string            //   → Reasoning / ReasoningContent text=
      thinking: bool               //   → Reasoning isStreaming=, ReasoningTrigger isStreaming=
      tool: ToolCall               //   → Tool state=, ToolHeader, ToolInput value=, ToolOutput output=
                                   //     Confirmation state= approved=
      plan: string[]               //   → Plan isStreaming=planning
      planning: bool
      text: string                 //   → MessageResponse text= streaming=
      streaming: bool
      sources: Source[]            //   → Sources / Source, InlineCitation…
      tasks: string[]              //   → Task / TaskItem

    shape Turn
      id: string                   //   → MessageScrollerItem messageId=
      role: string                 //   → Message from=
      text: string                 //   → Bubble / BubbleContent (the person's)
      files: File[]                //   → Attachments / Attachment data=
      replies: Reply[]             //   retry pushes one
      branch: number               //   → MessageBranchSelector branch= count=replies.length
      vote: string                 //   → MessageAction pressed=

    state turns: Turn[] = []       // the thread
    state draft = ""               // → PromptInput value=
    state files: File[] = []       // → PromptInput files=
    state status = "ready"         // → PromptInput status=, PromptInputSubmit status=
    state atEnd = true             // → Chat stuck=  (or MessageScrollerViewport / …Button stuck=)
    state model = "mote-large"     // → ModelSelector value=
    state queued: string[] = []    // → Queue (what was sent while a reply streamed)

    Chat stuck=atEnd
      for t in turns key=t.id
        MessageScrollerItem messageId=t.id scrollAnchor=(t.role == "user")
          if t.role == "user"
            Message from="user"
              MessageContent
                Bubble align="end" variant="muted"
                  BubbleContent
                    text t.text
          else
            let r = t.replies[t.branch]
            Message from="assistant"
              MessageContent
                Reasoning isStreaming=r.thinking
                  ReasoningTrigger isStreaming=r.thinking
                  ReasoningContent text=r.reasoning
                MessageResponse text=r.text streaming=r.streaming
                MessageToolbar
                  MessageBranchSelector branch=t.branch count=t.replies.length
                  MessageActions
                    MessageAction tooltip="Copy" press={copy(r.text)}
                      icon "copy" size=14
    PromptInput value=draft files=files status=status submit=send
      PromptInputFooter
        PromptInputTools
          ModelSelector value=model models=models
        PromptInputSubmit status=status press=stop

    action send(m: {text: string, files: File[]})   // what `submit` hands over
      turns.push({id: uid(), role: "user", text: m.text, files: m.files, …})
      …start the reply: push an assistant turn, set status = "submitted"

A stream is then nothing but writes: `turns[i].replies[b].text += chunk`,
`…tool.state = "output-available"`. What reads a field follows it: the tool
opens by itself when its state says it has finished, the reasoning closes
when `thinking` turns false, the thread stays at its end while `atEnd`.
In the gallery the "model" is a script on a timer (`step`, every 30 ms):
replace it with your stream.

## How the parts share state

The original's parts find each other through React context. Mote has none,
so the parts are given what they show. Four things keep that quiet:

1. **What opens and closes is the browser's own `details`.** The root is the
   `details`, its trigger the `summary`: they share open and closed through
   the element, with no props and no state: `Task` / `TaskTrigger`, `Tool`
   / `ToolHeader`, `Sources`, `Reasoning`, `Plan`, `ChainOfThought`,
   `TraceCollapsible`, `QueueSection`, `TestSuite`, `StackTrace`,
   `AgentTool`. To hold it on the page, give the root and its trigger the
   same `open=`:

       TraceCollapsible open=shown
         TraceCollapsibleTrigger open=shown      // a press writes `shown`

   The root's `open` drives the element; the trigger's makes a press write
   it back (and its chevron turn: a trigger that does not know `open` shows
   the two-way mark instead, since only the element knows). `defaultOpen`
   starts it open. `Reasoning isStreaming=` and `Tool state=` open and close
   it by themselves until the reader presses.
2. **What floats is a `popover` under its root.** `Context` /
   `ContextContent`, `InlineCitationCard` / `…CardBody`,
   `AttachmentHoverCard` / `…Content`, `PromptInputHoverCard` /
   `…Content` (hover cards), `PromptInputSelect` / `…Content`,
   `PromptInputActionMenu` / `…Content` (opened by a press). No props.
3. **A root given the data draws the usual parts itself.** `Attachment
   data=`, `FileTree files=`, `ModelSelector models=`, `StackTrace trace=`,
   `Terminal output=`, `Questionnaire items=`, `TestResults summary=`,
   `Test name=`, `PromptInputSelect options=`, `MessageBranchSelector
   branch= count=`, `InlineCitationCarousel count=`, and `PromptInput`
   (attachments and the text field). The root then also holds what its parts
   would otherwise share (a search, the place of the keyboard, which
   question is on show). Leave the data out and the root is only the frame:
   compose the parts under it, giving each what it shows. (The original
   decides by whether it was given children, which a Mote component cannot
   see.)
4. **What only changes how a part looks comes down through the element.**
   A `Message`'s side reaches its `MessageFooter` as `text-align`; a
   `TraceLine`'s status reaches its icon and title as `color`; and "shimmer
   now" (a running `TraceLine`, a streaming `Plan`, an uploading
   `Attachment`) reaches the titles inside as `border-spacing`, a property
   every element hands to its children and only a table uses (the shimmer's
   band is a table two spacings wide). So `TraceTitle`, `PlanTitle` and
   `AttachmentTitle` take no props, as in the original.

Everything else is a prop on the part that shows it: `ContextTrigger
usedTokens= maxTokens=`, `ConfirmationRequest state=`, `ToolHeader state=`.

Handlers. `press`, `submit`, `change` and `key` are events, so they take an
action or a `{block}`, and an action is handed what the component has for
it: `Suggestion press=ask` with `action ask(s: string)`; `PromptInput
submit=send` with `action send(m: {text: string, files: File[]})`;
`FileTree press=opened` (the path); `StackTrace press=opened` ({file, line,
col}); `ModelSelector change=picked` (the id); `Questionnaire submit=done`
(the answers). `remove` (Attachment) and `clear` (Terminal) are not events:
give them a `{block}` or an action's bare name.

A prop cannot be called `input` (on a component that is the event), so
`ToolInput` takes `value=`.

## The families

One usage per family; the table at the end has every part and its props.

### Bubble, Marker, Message

    Message from="user"                    // or align="end"; from: user | assistant | system
      MessageAvatar
      MessageContent
        MessageHeader
        Bubble align="end" variant="muted" // variant: default secondary muted tinted outline ghost destructive
          BubbleContent "Hello"
          BubbleReactions side="bottom" align="end"
        MessageFooter                      // follows the message's side
    MessageGroup · BubbleGroup             // consecutive ones, closer together
    Marker variant="separator"             // default | border | separator
      MarkerIcon
      MarkerContent shimmer=true "Today"
    MessageResponse text=reply streaming=live      // the `markdown` element
    MessageActions
      MessageAction tooltip="Good" label="Good reply" pressed=up press={up = !up}
    MessageToolbar
    MessageBranch branch=t.branch
      MessageBranchContent                 // the page shows versions[branch] in it
      MessageBranchSelector branch=t.branch count=3    // previous, "2 of 3", next; wraps
      // or by hand: MessageBranchPrevious / MessageBranchPage / MessageBranchNext branch= count=

Differs: `defaultBranch` / `onBranchChange` are the one prop `branch`,
written back. `MessageBranchContent` does not pick the child to show: the
page does (`t.replies[t.branch]`). The avatar sits at the bottom of the row
(it does not move up past a footer).

### Message Scroller, Chat

    MessageScrollerProvider autoScroll=true
      MessageScroller
        MessageScrollerViewport stuck=atEnd          // the `feed` element
          MessageScrollerContent                     // role=log
            MessageScrollerItem messageId=t.id scrollAnchor=true
        MessageScrollerButton stuck=atEnd            // shown when not at the end
    Chat stuck=atEnd                                 // all of the above in one; its children are the items

`stuck` is whether the thread is at its end, written back; setting it true
goes there. Differs: there are no hooks (`useMessageScroller`…): to go to a
message use `scroll("id", "message-<messageId>")`. `scrollAnchor` only marks
the item (the feed keeps to the end; it does not bring a new anchor to the
top with a peek). A long thread is the page's `for … virtual` under
`MessageScrollerContent` ([long lists](../markup.md#long-lists)): only the
messages in view are drawn, older ones put in at the top leave the one being
read where it was (`preserveScrollOnPrepend`, always), and `seen=` on a line
above them asks for more. `defaultScrollPosition` is left out. AI Elements'
`Conversation…` names for the same thing are in `kit/ai.mote`.

### Attachment

    Attachments variant="inline"                     // grid | inline | list
      for f in files key=f.id
        Attachment data=f variant="inline" remove={files = files.filter(x => x.id != f.id)}
    // by hand (shadcn's parts): state idle | uploading | processing | error | done; size default | sm | xs
    Attachment state="uploading"
      AttachmentMedia · AttachmentPreview type= url=
      AttachmentContent
        AttachmentTitle · AttachmentDescription      // or AttachmentInfo name= type= size=
      AttachmentActions
        AttachmentAction label="Cancel" · AttachmentRemove press=
      AttachmentTrigger label="Open" press=           // covers the card, under its actions
    AttachmentHoverCard
      AttachmentHoverCardTrigger
      AttachmentHoverCardContent
    AttachmentGroup · AttachmentEmpty

A file is `{id, name, type, url?, size?}`. The preview is the picture at
`url` for an `image/…` type, else an icon for the kind (image, video, audio,
text and pdf, `source-document`, anything else). Differs: `variant` is given
to each `Attachment` (and to `AttachmentPreview` / `AttachmentInfo` /
`AttachmentRemove` when composing by hand), not only to `Attachments`.

### Trace

    Trace
      TraceLine status="running"           // running | error | pending; none (or "done") is finished work
        TraceIcon status="running"         // the usual icon for a status, or an icon of your own inside
        TraceTitle "Running the tests"     // shimmers while its line runs
        TraceDescription "42 so far"
      TraceCollapsible open=o defaultOpen=false
        TraceCollapsibleTrigger open=o
          TraceLine …
        TraceCollapsibleContent

A rule joins the lines behind their icons (the icons are drawn on the page's
background: on another surface give `TraceIcon background=…`). Differs:
`keepMounted` is always so (it is a `details`).

### Questionnaire

    Questionnaire items=questions answers=given shortcuts="letters" submit=done
    // an item: {name, prompt, description?, required?, multiple?, choices?: [{value, label?, description?}], input?: {placeholder?, type?}}

It shows one item at a time with its progress. Single choice is the
browser's radios, `multiple` its checkboxes, `input` a free answer beside or
instead of them. Next refuses an unanswered item (it says why and puts the
keyboard on the first answer); Skip shows on items that are not `required`;
the last item has Submit. `answers` is written as they are given (a name to
its text, or to a list for `multiple`; a skipped item is absent), and
`submit` is handed the same once every item is answered or skipped. Keys:
a shortcut letter or number picks an answer; left and right move between
items (right only from an answered or skipped one); Enter in a field goes
on; the radios' own arrows. By hand: `QuestionnaireProgress current= total=`,
`QuestionnaireItem`, `…Title`, `…Description`, `…Choices`, `…Choice value=
name= checked= multiple= shortcut= change=`, `…Input value= input=`,
`…Error invalid=`, `…Actions`, `…Previous / Skip / Next / Submit visible=
press=`, with the stepping the page's own. Differs: answers are page state,
not `FormData`; `item` is written back but does not drive; no
Command/Ctrl+Enter (a key handler is not told the modifiers); the
`ChoiceInput` / `ChoiceLabel` / `ChoiceShortcut` sub-parts are inside
`QuestionnaireChoice`.

### Reasoning, Sources, Task, Chain of Thought, Checkpoint

    Reasoning isStreaming=r.thinking              // opens while it streams, closes when done
      ReasoningTrigger isStreaming=r.thinking duration=4    // "Thinking…", then "Thought for 4 seconds"
      ReasoningContent text=r.reasoning streaming=r.thinking // markdown
    Sources
      SourcesTrigger count=3                      // "Used 3 sources"
      SourcesContent
        Source href="https://…" title="…"
    Task defaultOpen=true
      TaskTrigger title="Found the files"
      TaskContent
        TaskItem
          TaskItemFile "card.md"
    ChainOfThought defaultOpen=true
      ChainOfThoughtHeader "Chain of Thought"
      ChainOfThoughtContent
        ChainOfThoughtStep label="Searching" description="…" status="active" icon="search"
          ChainOfThoughtSearchResults
            ChainOfThoughtSearchResult "mote.dev"
          ChainOfThoughtImage caption="…"
    Checkpoint
      CheckpointIcon
      CheckpointTrigger tooltip="Restore to here" press=restore

Without `duration` the trigger measures the seconds itself (from
`isStreaming` turning true to its turning false). Differs: `isStreaming`
and `duration` are given to the trigger as well as the root; it closes at
once when the stream ends (no one-second wait). A step's `icon` is a word
from a short list (dot, search, image, check, brain, file, globe, code,
terminal, wrench, sparkles, database), since an icon's name is written out
in Mote. `CheckpointIcon` always draws the bookmark first.

### Tool, Confirmation

    Tool state=t.state                            // opens by itself once the tool has finished
      ToolHeader type="tool-read_file" state=t.state   // or toolName= / title=
      ToolContent
        ToolInput value=t.input                   // highlighted JSON
        ToolOutput output=t.output errorText=t.error
    Confirmation state=t.state approved=t.approved
      ConfirmationTitle
        ConfirmationRequest state=t.state         // shown while approval-requested
        ConfirmationAccepted state=t.state approved=t.approved
        ConfirmationRejected state=t.state approved=t.approved
      ConfirmationActions state=t.state
        ConfirmationAction variant="outline" press=deny
        ConfirmationAction press=approve

The badge (`ToolStatus state=`): input-streaming "Pending", input-available
"Running", approval-requested "Awaiting Approval", approval-responded
"Responded", output-available "Completed", output-error "Error",
output-denied "Denied". Differs: `Tool` takes `state` (to open by itself);
`ToolInput input=` is `value=`; the Confirmation parts are each given the
state they show for (the original's `approval` object is `approved`, a bool).

### Plan, Queue, Suggestion

    Plan isStreaming=planning defaultOpen=true
      PlanHeader                                  // the whole header is the trigger
        column
          PlanTitle "Rewrite the parser"          // both shimmer while it streams
          PlanDescription "Three steps"
        PlanAction
          PlanTrigger                             // the mark that says it folds
      PlanContent
      PlanFooter
    Queue
      QueueSection defaultOpen=true
        QueueSectionTrigger
          QueueSectionLabel label="Todo" count=3
            icon "list-todo" size=14
        QueueSectionContent
          QueueList
            QueueItem
              row
                QueueItemIndicator completed=done
                QueueItemContent completed=done
                QueueItemActions
                  QueueItemAction label="Remove" press=…
              QueueItemDescription completed=done
              QueueItemAttachment
                QueueItemImage src=… · QueueItemFile "a.pdf"
    Suggestions
      Suggestion suggestion="What is Mote?" press=ask      // `label=` to show other words

Differs: `PlanTrigger` is a mark, not a button of its own (the header it
sits in is the trigger), and `PlanFooter` folds away with the content.
`QueueSectionLabel`'s icon is its child.

### Context

    Context
      ContextTrigger usedTokens=used maxTokens=max        // "37.5%" and a ring
      ContextContent                                      // a hover card
        ContextContentHeader usedTokens=used maxTokens=max // "48K / 128K" and a Progress
        ContextContentBody
          ContextInputUsage tokens=32000 cost="$0.10"
          ContextOutputUsage · ContextReasoningUsage · ContextCacheUsage
        ContextContentFooter cost="$0.14"

Numbers are shortened (1.2K, 1.5M, 2B: `ChatCompact value=`); a usage of no
tokens is left out. Differs: each part is given the numbers it shows, and
costs are the page's words (nothing here knows a model's prices; `modelId`
is accepted on `Context` and only marks the element).

### Inline Citation

    InlineCitation
      InlineCitationText "Mote has no dependencies"
      InlineCitationCard
        InlineCitationCardTrigger sources=["https://mote.dev/a", "https://example.com/b"]   // "mote.dev +1"
        InlineCitationCardBody
          InlineCitationCarousel count=2          // draws previous, next and "1/2"
            InlineCitationCarouselContent
              InlineCitationCarouselItem
                InlineCitationSource title= url= description=
                InlineCitationQuote "…"

With `count` the carousel keeps its own place; `index=` holds it on the
page. By hand, without `count`: `InlineCitationCarouselHeader` with
`…Prev index= count=`, `…Next index= count=`, `…Index index= count=`, and
the same `index` on the carousel. Differs: no swipe (it moves by its
buttons).

### File Tree

    FileTree files=paths expanded=open selectedPath=chosen press=opened
    // by hand:
    FileTree
      FileTreeFolder path="src" name="src" expanded=open     // without `expanded` it opens by itself
        FileTreeFile path="src/app.mote" name="app.mote" selectedPath=chosen press=opened
          FileTreeActions

`files` are paths with "/" between folders; folders are found from them (a
path ending in "/" is an empty folder), in the order given. It is a `tree`
of `treeitem`s with `aria-level`, `aria-expanded`, `aria-selected`, and one
item in the tab order. Keys: up and down move, right opens a folder or goes
into it, left closes it or goes to its parent, Home and End, Enter or Space
chooses. `expanded` (the open folders' paths; `defaultExpanded` to start)
and `selectedPath` are written back. Differs: the arrow keys work in the
`files=` form only (a tree composed by hand has Tab, Enter and Space: its
root cannot see its rows).

### Model Selector

    ModelSelector models=models value=model open=picking change=picked
    // a model: {id, name, provider, group?}
    // by hand:
    ModelSelector
      ModelSelectorTrigger open=picking
        ModelSelectorLogoGroup
          ModelSelectorLogo provider="mote"
        ModelSelectorName "Mote Large"
      ModelSelectorContent open=picking title="Models"      // ModelSelectorDialog is the same
        ModelSelectorInput value=query
        ModelSelectorList
          ModelSelectorEmpty "No models found."
          ModelSelectorGroup heading="Mote"
            ModelSelectorItem value="mote-large" selected=(model == "mote-large") press={…}
              ModelSelectorShortcut "⌘1"
          ModelSelectorSeparator

A modal window with a search: type to narrow (name, provider, id), up and
down (round the ends), Home and End, Enter to choose, Escape to leave; the
search is a `combobox` with `aria-activedescendant` on the option the
keyboard is on. `ModelSelectorLogo` draws a roundel with the provider's
first letter (no one's logo is drawn or fetched). Differs: the keyboard
works in the `models=` form (by hand, the page narrows the list by
`ModelSelectorInput value=` and the items are in the tab order).

### Prompt Input

    PromptInput value=draft files=files status=status error=problem submit=send accept="image/*,.pdf" maxFiles=4 maxFileSize=5000000
      PromptInputFooter
        PromptInputTools
          PromptInputActionMenu
            PromptInputActionMenuTrigger
            PromptInputActionMenuContent
              PromptInputActionAddAttachments files=files maxFiles=4      // fs.pick
              PromptInputActionMenuItem press=…
          PromptInputSpeechButton value=draft                              // speech.listen
          PromptInputButton tooltip="Search the web" pressed=web press={web = !web}
          PromptInputSelect value=mode options=["Agent", "Ask"]
          // or PromptInputSelect / …Trigger / …Value value= / …Content / …Item value= selected=
          PromptInputHoverCard
            PromptInputHoverCardTrigger
            PromptInputHoverCardContent
              PromptInputTabsList
                PromptInputTab
                  PromptInputTabLabel "Open files"
                  PromptInputTabBody
                    PromptInputTabItem
        PromptInputSubmit status=status press=stop
    PromptInputCommand
      PromptInputCommandInput value=query
      PromptInputCommandList
        PromptInputCommandEmpty · PromptInputCommandGroup heading= · PromptInputCommandItem press= · PromptInputCommandSeparator

The root is a form. It draws the attachments (from `files`, as inline
pills with remove buttons) and the text field; its children are the footer.
The field grows with its text up to 192px, then scrolls. Enter sends,
Shift+Enter breaks the line, and the Enter that settles an input method's
text does neither. `submit` is handed `{text, files}`, then `value` and
`files` are emptied; an empty prompt is not sent. Files let go over the
form are added, within `accept`, `maxFiles` and `maxFileSize`; what is
refused is said under the field and written to `error`. The submit button
follows `status`: ready (an arrow), submitted (a spinner), streaming (a
square: a press calls `press`, to stop), error (a cross). Sending while a
reply streams still calls `submit`: the page may queue it.

Differs: the root draws the header and the body (`bare` leaves them to you:
`PromptInputHeader`, `PromptInputBody`, `PromptInputTextarea value=
submit=`); the error handler is the `error` prop, written back; pasting a
picture is left out (there is no paste event); the media type of a dropped
or picked file is read from its name. There is no
`PromptInputProvider` / `usePromptInputAttachments`: `files` is page state.

### Stack Trace

    StackTrace trace=text defaultOpen=true showInternalFrames=true maxHeight=400 press=opened

Read from a JavaScript error's text: the kind and message from its first
line (`Uncaught ` is dropped), and each frame as `{fn, file, line, col}`
from `at fn (file:line:col)`, `at file:line:col`, `at async fn (…)`, `at new
Fn (…)`, `at eval (eval at …)`, `file://` and Windows paths, and
`fn@file:line:col` (Firefox, Safari). Frames whose file is in
`node_modules`, starts with `node:`, or is `<anonymous>` are internal:
dimmed, and left out with `showInternalFrames=false`. A press on a path
hands the page `{file, line, col}`. By hand: `StackTraceHeader`,
`StackTraceError`, `StackTraceErrorType trace=`, `StackTraceErrorMessage
trace=`, `StackTraceActions`, `StackTraceCopyButton trace=`,
`StackTraceExpandButton`, `StackTraceContent maxHeight=`, `StackTraceFrames
trace= showInternalFrames= press=`. Differs: each part reads `trace` itself;
it folds by its header and is not held by the page (`open=` drives it only).

### Terminal

    Terminal output=text isStreaming=running autoScroll=true title="Build" clear={text = ""}

A command's output, read-only: SGR colours (the 16, the 256, 24-bit), bold,
dim, italic, underline, inverse and their resets; a carriage return goes
back to the start of the line and what follows overwrites it; erase-line
(`K`, `1K`, `2K`), backspace; any other escape (cursor moves, titles) is
dropped. It stays at its end as output arrives, shows a spinner and a
cursor while `isStreaming`, and is dark in both schemes. By hand:
`TerminalHeader`, `TerminalTitle`, `TerminalStatus isStreaming=`,
`TerminalActions`, `TerminalCopyButton output=`, `TerminalClearButton
press=`, `TerminalContent output= isStreaming= autoScroll= maxHeight=`.
This is not a terminal to type into: that is the `terminal` element
(docs/kit/terminal.md), a full emulator.

### Test Results

    TestResults summary=totals                     // {passed, failed, skipped, total, duration?} (ms)
      TestResultsContent
        TestSuite name="auth" status="failed" defaultOpen=true
          TestSuiteName name="auth" status="failed"
            TestSuiteStats passed=1 failed=1
          TestSuiteContent
            Test name="logs out" status="failed" duration=40      // passed | failed | skipped | running
              TestError
                TestErrorMessage "Expected 200, got 500"
                TestErrorStack "  at …"

By hand: `TestResultsHeader`, `TestResultsSummary passed= failed= skipped=`,
`TestResultsDuration duration=`, `TestResultsProgress passed= failed=
total=`; `TestStatus status=`, `TestName`, `TestDuration duration=`.
Differs: the suite's name and status are given to `TestSuiteName` too.

### Subagent

    Agent
      AgentHeader name="Researcher" model="mote-small"
      AgentContent
        AgentInstructions "Find what the docs say."
        AgentTools
          AgentTool name="search" description="Search the docs" schema=schema   // folds; the schema as JSON
        AgentOutput schema="z.object({ … })"                                    // highlighted

## Left out, and why

| What | Why |
|---|---|
| `className`, `asChild`, `render`, `ref` on every part | React's. What is not a prop falls through to a part's first element (`id`, `class`, `aria-*`, events, styles). |
| `createChat`, `useChat`, the AI SDK's message parts | No SDK: the thread is page state (above). |
| `useMessageScroller`, `useMessageScrollerVisibility`, `useMessageScrollerScrollable` | Hooks. `stuck` and `scroll("id", …)` do the work. |
| MessageScroller: anchor-to-top with a peek, `defaultScrollPosition` | `Feed` keeps to the end and no more. (Virtualised rows and a place kept as older ones come in are the page's `for … virtual`.) |
| `markerVariants` | A class-variance helper; `Marker variant=` is the component. |
| Questionnaire: `ChoiceInput`, `ChoiceLabel`, `ChoiceShortcut`; `FormData`; Command/Ctrl+Enter; `item=` driving | Inside `QuestionnaireChoice`; answers are state; a key handler is not told modifiers. |
| `PromptInputProvider`, `usePromptInputAttachments`, `PromptInputAttachments` / `PromptInputAttachment` | `files` is page state, drawn with `Attachment`. |
| PromptInput: paste of pictures | Left out of the component. A page takes them with `paste` / `pastefiles` on an element around it ([events.md](../events.md#the-events)) and adds them to `files`. |
| PromptInput: Backspace on an empty field removing the last file | Left out. |
| Context: cost worked out from `modelId` (tokenlens) | No price list here: the page gives `cost=` as words. |
| ModelSelector: providers' real logos | No third-party logos: a lettered roundel. |
| InlineCitation: swipe | It moves by its buttons (Embla is not rebuilt here; the Carousel proper is `kit/more.mote`'s). |
| Reasoning: the one-second wait before it closes | It closes when the stream ends. |
| Trace: `keepMounted` | Always so. |
| Shimmer: stopping for reduced motion | There is no `reduced-motion` line in Mote yet. |
| FileTree / ModelSelector composed by hand: arrow keys | A root cannot see the rows composed under it; the data forms have them. |
| Arrow keys not scrolling the page while they move within the tree | A handler cannot stop a key's own doing. |
| `Conversation`, `ConversationContent`, `ConversationScrollButton`… | In `kit/ai.mote` (the same thing as Message Scroller / `Chat`). |

## Every part

Shared pieces are named `Chat…` so that they collide with nothing; pages may
use them too.

**Shared pieces**

| Part | | Props |
|---|---|---|
| `ChatShimmer` | done | `on`: bool?. A band of light over what is inside. `on` says so; without it, a running TraceLine / streaming Plan above it does. |
| `ChatIconButton` | done | `label`: string?, `tooltip`: string?, `press` (handler), `pressed`: bool?, `disabled`: bool?, `size`: number?. A quiet icon button with a tip; `pressed` makes it a toggle. |
| `ChatDisclosure` | done | `open`: bool?, `auto`: bool?. The `details` behind every root that folds. |
| `ChatSummary` | done | `open`: bool?, `pad`: string?, `gap`: number?, `justify`: string?. Its `summary`; with `open` a press writes it back. |
| `ChatChevron` | done | `open`: bool?. Turns when it knows `open`; else the two-way mark. |
| `ChatCompact` | done | `value`: number. 1234 → 1.2K, 1500000 → 1.5M, 2000000000 → 2B. |

**Bubble**

| Part | | Props |
|---|---|---|
| `Bubble` | done | `align`: string?, `variant`: string? |
| `BubbleContent` | done | — |
| `BubbleReactions` | done | `side`: string?, `align`: string? |
| `BubbleGroup` | done | — |

**Marker**

| Part | | Props |
|---|---|---|
| `Marker` | done | `variant`: string? |
| `MarkerIcon` | done | — |
| `MarkerContent` | done | `shimmer`: bool? |

**Message**

| Part | | Props |
|---|---|---|
| `Message` | done | `align`: string?, `from`: string? |
| `MessageGroup` | done | — |
| `MessageAvatar` | done | — |
| `MessageContent` | done | — |
| `MessageHeader` | done | — |
| `MessageFooter` | done | — |
| `MessageResponse` | done | `text`: string, `streaming`: bool? |
| `MessageActions` | done | — |
| `MessageAction` | done | `tooltip`: string?, `label`: string?, `press` (handler), `pressed`: bool?, `disabled`: bool? |
| `MessageToolbar` | done | — |
| `MessageBranch` | done | `branch`: number? |
| `MessageBranchContent` | done | —. The page shows `versions[branch]` in it. |
| `MessageBranchSelector` | done | `branch`: number?, `count`: number? |
| `MessageBranchPrevious` | done | `branch`: number?, `count`: number |
| `MessageBranchNext` | done | `branch`: number?, `count`: number |
| `MessageBranchPage` | done | `branch`: number?, `count`: number |

**Message Scroller**

| Part | | Props |
|---|---|---|
| `MessageScrollerProvider` | done | `autoScroll`: bool?. A frame only: there is nothing to provide. |
| `MessageScroller` | done | — |
| `MessageScrollerViewport` | done | `stuck`: bool, `autoScroll`: bool? |
| `MessageScrollerContent` | done | — |
| `MessageScrollerItem` | done | `messageId`: string, `scrollAnchor`: bool?. `scrollAnchor` marks it and no more. |
| `MessageScrollerButton` | done | `stuck`: bool |
| `Chat` | done | `stuck`: bool. Provider, scroller, viewport, content and button in one. |

**Attachment**

| Part | | Props |
|---|---|---|
| `Attachments` | done | `variant`: string? |
| `Attachment` | done | `data`: File?, `variant`: string?, `state`: string?, `size`: string?, `orientation`: string?, `remove` (handler) |
| `AttachmentPreview` | done | `type`: string?, `url`: string?, `name`: string?, `variant`: string? |
| `AttachmentInfo` | done | `name`: string, `type`: string?, `size`: number?, `variant`: string? |
| `AttachmentRemove` | done | `press` (handler), `variant`: string?, `label`: string? |
| `AttachmentMedia` | done | `variant`: string? |
| `AttachmentContent` | done | — |
| `AttachmentTitle` | done | — |
| `AttachmentDescription` | done | — |
| `AttachmentActions` | done | — |
| `AttachmentAction` | done | `label`: string?, `tooltip`: string?, `press` (handler), `disabled`: bool? |
| `AttachmentTrigger` | done | `press` (handler), `label`: string? |
| `AttachmentGroup` | done | — |
| `AttachmentHoverCard` | done | — |
| `AttachmentHoverCardTrigger` | done | — |
| `AttachmentHoverCardContent` | done | `placement`: string? |
| `AttachmentEmpty` | done | — |

**Trace**

| Part | | Props |
|---|---|---|
| `Trace` | done | — |
| `TraceLine` | done | `status`: string? |
| `TraceIcon` | done | `status`: string? |
| `TraceTitle` | done | — |
| `TraceDescription` | done | — |
| `TraceCollapsible` | done | `open`: bool?, `defaultOpen`: bool? |
| `TraceCollapsibleTrigger` | done | `open`: bool? |
| `TraceCollapsibleContent` | done | — |

**Questionnaire**

| Part | | Props |
|---|---|---|
| `Questionnaire` | done | `items`: record[]?, `answers`: json?, `item`: string?, `shortcuts`: string?, `submit` (handler, given a) |
| `QuestionnaireProgress` | done | `current`: number, `total`: number |
| `QuestionnaireItem` | done | `name`: string?, `invalid`: bool?, `required`: bool?, `multiple`: bool?, `active`: bool? |
| `QuestionnaireTitle` | done | — |
| `QuestionnaireDescription` | done | — |
| `QuestionnaireChoices` | done | — |
| `QuestionnaireChoice` | done | `value`: string, `name`: string?, `checked`: bool?, `multiple`: bool?, `shortcut`: string?, `disabled`: bool?, `change` (handler), `id`: string?. Radio, or checkbox with `multiple`; holds the original's ChoiceInput / ChoiceLabel / ChoiceShortcut. |
| `QuestionnaireInput` | done | `value`: string, `placeholder`: string?, `type`: string?, `invalid`: bool?, `disabled`: bool?, `input` (handler), `id`: string? |
| `QuestionnaireError` | done | `invalid`: bool? |
| `QuestionnaireActions` | done | — |
| `QuestionnairePrevious` | done | `press` (handler), `disabled`: bool?, `visible`: bool? |
| `QuestionnaireSkip` | done | `press` (handler), `disabled`: bool?, `visible`: bool? |
| `QuestionnaireNext` | done | `press` (handler), `disabled`: bool?, `visible`: bool? |
| `QuestionnaireSubmit` | done | `press` (handler), `disabled`: bool?, `visible`: bool? |

**Reasoning**

| Part | | Props |
|---|---|---|
| `Reasoning` | done | `isStreaming`: bool?, `open`: bool?, `defaultOpen`: bool? |
| `ReasoningTrigger` | done | `isStreaming`: bool?, `duration`: number?, `open`: bool? |
| `ReasoningContent` | done | `text`: string?, `streaming`: bool? |

**Sources**

| Part | | Props |
|---|---|---|
| `Sources` | done | `open`: bool?, `defaultOpen`: bool? |
| `SourcesTrigger` | done | `count`: number, `open`: bool? |
| `SourcesContent` | done | — |
| `Source` | done | `href`: string, `title`: string? |

**Task**

| Part | | Props |
|---|---|---|
| `Task` | done | `open`: bool?, `defaultOpen`: bool? |
| `TaskTrigger` | done | `title`: string, `open`: bool? |
| `TaskContent` | done | — |
| `TaskItem` | done | — |
| `TaskItemFile` | done | — |

**Tool**

| Part | | Props |
|---|---|---|
| `Tool` | done | `open`: bool?, `defaultOpen`: bool?, `state`: string? |
| `ToolStatus` | done | `state`: string?. The badge for a tool's state (the original's `getStatusBadge`). |
| `ToolHeader` | done | `type`: string?, `toolName`: string?, `title`: string?, `state`: string?, `open`: bool? |
| `ToolContent` | done | — |
| `ToolInput` | done | `value`: json. `value`, not `input` (an event on a component). |
| `ToolOutput` | done | `output`: json?, `errorText`: string? |

**Plan**

| Part | | Props |
|---|---|---|
| `Plan` | done | `isStreaming`: bool?, `open`: bool?, `defaultOpen`: bool? |
| `PlanHeader` | done | `open`: bool? |
| `PlanTitle` | done | — |
| `PlanDescription` | done | — |
| `PlanAction` | done | — |
| `PlanTrigger` | done | —. A mark; the header is the trigger. |
| `PlanContent` | done | — |
| `PlanFooter` | done | — |

**Chain of Thought**

| Part | | Props |
|---|---|---|
| `ChainOfThought` | done | `open`: bool?, `defaultOpen`: bool? |
| `ChainOfThoughtHeader` | done | `open`: bool? |
| `ChainOfThoughtContent` | done | — |
| `ChainOfThoughtStep` | done | `label`: string, `description`: string?, `status`: string?, `icon`: string? |
| `ChainOfThoughtSearchResults` | done | — |
| `ChainOfThoughtSearchResult` | done | — |
| `ChainOfThoughtImage` | done | `caption`: string? |

**Checkpoint**

| Part | | Props |
|---|---|---|
| `Checkpoint` | done | — |
| `CheckpointIcon` | done | —. Draws the bookmark. |
| `CheckpointTrigger` | done | `tooltip`: string?, `press` (handler), `disabled`: bool? |

**Confirmation**

| Part | | Props |
|---|---|---|
| `Confirmation` | done | `state`: string?, `approved`: bool? |
| `ConfirmationTitle` | done | — |
| `ConfirmationRequest` | done | `state`: string? |
| `ConfirmationAccepted` | done | `state`: string?, `approved`: bool? |
| `ConfirmationRejected` | done | `state`: string?, `approved`: bool? |
| `ConfirmationActions` | done | `state`: string? |
| `ConfirmationAction` | done | `press` (handler), `variant`: string?, `disabled`: bool? |

**Agent (a subagent's card)**

| Part | | Props |
|---|---|---|
| `Agent` | done | — |
| `AgentHeader` | done | `name`: string, `model`: string? |
| `AgentContent` | done | — |
| `AgentInstructions` | done | — |
| `AgentTools` | done | — |
| `AgentTool` | done | `name`: string, `description`: string?, `schema`: json? |
| `AgentOutput` | done | `schema`: string |

**Queue**

| Part | | Props |
|---|---|---|
| `Queue` | done | — |
| `QueueSection` | done | `open`: bool?, `defaultOpen`: bool? |
| `QueueSectionTrigger` | done | `open`: bool? |
| `QueueSectionLabel` | done | `label`: string, `count`: number?, `open`: bool? |
| `QueueSectionContent` | done | — |
| `QueueList` | done | — |
| `QueueItem` | done | — |
| `QueueItemIndicator` | done | `completed`: bool? |
| `QueueItemContent` | done | `completed`: bool? |
| `QueueItemDescription` | done | `completed`: bool? |
| `QueueItemActions` | done | — |
| `QueueItemAction` | done | `label`: string?, `tooltip`: string?, `press` (handler), `disabled`: bool? |
| `QueueItemAttachment` | done | — |
| `QueueItemImage` | done | `src`: string, `alt`: string? |
| `QueueItemFile` | done | — |

**Suggestion**

| Part | | Props |
|---|---|---|
| `Suggestions` | done | — |
| `Suggestion` | done | `suggestion`: string, `label`: string?, `press` (handler, given s), `disabled`: bool? |

**Context**

| Part | | Props |
|---|---|---|
| `Context` | done | `usedTokens`: number?, `maxTokens`: number?, `modelId`: string? |
| `ContextTrigger` | done | `usedTokens`: number, `maxTokens`: number |
| `ContextContent` | done | — |
| `ContextContentHeader` | done | `usedTokens`: number, `maxTokens`: number |
| `ContextContentBody` | done | — |
| `ContextContentFooter` | done | `cost`: string? |
| `ContextUsageLine` | done | `label`: string, `tokens`: number?, `cost`: string?. One line of usage; the four usage parts are it with a label. |
| `ContextInputUsage` | done | `tokens`: number?, `cost`: string? |
| `ContextOutputUsage` | done | `tokens`: number?, `cost`: string? |
| `ContextReasoningUsage` | done | `tokens`: number?, `cost`: string? |
| `ContextCacheUsage` | done | `tokens`: number?, `cost`: string? |

**Inline Citation**

| Part | | Props |
|---|---|---|
| `InlineCitation` | done | — |
| `InlineCitationText` | done | — |
| `InlineCitationCard` | done | — |
| `InlineCitationCardTrigger` | done | `sources`: string[] |
| `InlineCitationCardBody` | done | — |
| `InlineCitationCarousel` | done | `count`: number?, `index`: number? |
| `InlineCitationCarouselContent` | done | —. Groups the items; the carousel lays them out. |
| `InlineCitationCarouselItem` | done | — |
| `InlineCitationCarouselHeader` | done | — |
| `InlineCitationCarouselIndex` | done | `index`: number, `count`: number |
| `InlineCitationCarouselPrev` | done | `index`: number, `count`: number |
| `InlineCitationCarouselNext` | done | `index`: number, `count`: number |
| `InlineCitationSource` | done | `title`: string?, `url`: string?, `description`: string? |
| `InlineCitationQuote` | done | — |

**File Tree**

| Part | | Props |
|---|---|---|
| `FileTree` | done | `files`: string[]?, `expanded`: string[]?, `selectedPath`: string?, `defaultExpanded`: string[]?, `press` (handler, given path) |
| `FileTreeFolder` | done | `path`: string, `name`: string, `expanded`: string[]?, `defaultOpen`: bool? |
| `FileTreeFile` | done | `path`: string, `name`: string, `selectedPath`: string?, `press` (handler, given path) |
| `FileTreeIcon` | done | `kind`: string? |
| `FileTreeName` | done | — |
| `FileTreeActions` | done | — |

**Model Selector**

| Part | | Props |
|---|---|---|
| `ModelSelector` | done | `models`: record[]?, `value`: string?, `open`: bool?, `placeholder`: string?, `change` (handler, given id) |
| `ModelSelectorTrigger` | done | `open`: bool?, `press` (handler), `disabled`: bool? |
| `ModelSelectorContent` | done | `open`: bool, `title`: string? |
| `ModelSelectorDialog` | done | `open`: bool, `title`: string?. The same as ModelSelectorContent. |
| `ModelSelectorInput` | done | `value`: string, `placeholder`: string?, `key` (handler, given k), `active`: string?, `list`: string? |
| `ModelSelectorList` | done | — |
| `ModelSelectorEmpty` | done | — |
| `ModelSelectorGroup` | done | `heading`: string? |
| `ModelSelectorItem` | done | `value`: string?, `active`: bool?, `selected`: bool?, `press` (handler), `disabled`: bool? |
| `ModelSelectorShortcut` | done | — |
| `ModelSelectorSeparator` | done | — |
| `ModelSelectorLogo` | done | `provider`: string. A lettered roundel. |
| `ModelSelectorLogoGroup` | done | — |
| `ModelSelectorName` | done | — |

**Stack Trace**

| Part | | Props |
|---|---|---|
| `StackTrace` | done | `trace`: string?, `open`: bool?, `defaultOpen`: bool?, `showInternalFrames`: bool?, `maxHeight`: number?, `press` (handler, given f) |
| `StackTraceHeader` | done | — |
| `StackTraceError` | done | — |
| `StackTraceErrorType` | done | `trace`: string? |
| `StackTraceErrorMessage` | done | `trace`: string? |
| `StackTraceActions` | done | — |
| `StackTraceCopyButton` | done | `trace`: string |
| `StackTraceExpandButton` | done | — |
| `StackTraceContent` | done | `maxHeight`: number? |
| `StackTraceFrames` | done | `trace`: string, `showInternalFrames`: bool?, `press` (handler, given f) |

**Terminal**

| Part | | Props |
|---|---|---|
| `Terminal` | done | `output`: string?, `isStreaming`: bool?, `autoScroll`: bool?, `title`: string?, `clear` (handler) |
| `TerminalHeader` | done | — |
| `TerminalTitle` | done | — |
| `TerminalStatus` | done | `isStreaming`: bool? |
| `TerminalActions` | done | — |
| `TerminalButton` | done | `label`: string, `press` (handler). The console's own small button. |
| `TerminalCopyButton` | done | `output`: string |
| `TerminalClearButton` | done | `press` (handler) |
| `TerminalContent` | done | `output`: string, `isStreaming`: bool?, `autoScroll`: bool?, `maxHeight`: number? |

**Test Results**

| Part | | Props |
|---|---|---|
| `TestResults` | done | `summary`: record? |
| `TestResultsHeader` | done | — |
| `TestResultsSummary` | done | `passed`: number, `failed`: number, `skipped`: number |
| `TestResultsDuration` | done | `duration`: number |
| `TestResultsProgress` | done | `passed`: number, `failed`: number, `skipped`: number?, `total`: number |
| `TestResultsContent` | done | — |
| `TestSuite` | done | `name`: string?, `status`: string?, `open`: bool?, `defaultOpen`: bool? |
| `TestSuiteName` | done | `name`: string?, `status`: string?, `open`: bool? |
| `TestSuiteStats` | done | `passed`: number?, `failed`: number?, `skipped`: number? |
| `TestSuiteContent` | done | — |
| `Test` | done | `name`: string?, `status`: string?, `duration`: number? |
| `TestStatus` | done | `status`: string? |
| `TestName` | done | — |
| `TestDuration` | done | `duration`: number |
| `TestError` | done | — |
| `TestErrorMessage` | done | — |
| `TestErrorStack` | done | — |

**Prompt Input**

| Part | | Props |
|---|---|---|
| `PromptInput` | done | `value`: string, `files`: File[]?, `status`: string?, `placeholder`: string?, `accept`: string?, `maxFiles`: number?, `maxFileSize`: number?, `error`: string?, `disabled`: bool?, `bare`: bool?, `submit` (handler, given m) |
| `PromptInputHeader` | done | — |
| `PromptInputBody` | done | — |
| `PromptInputTextarea` | done | `value`: string, `placeholder`: string?, `disabled`: bool?, `maxHeight`: number?, `minHeight`: number?, `label`: string?, `submit` (handler) |
| `PromptInputFooter` | done | — |
| `PromptInputTools` | done | — |
| `PromptInputButton` | done | `tooltip`: string?, `label`: string?, `variant`: string?, `press` (handler), `disabled`: bool?, `pressed`: bool? |
| `PromptInputSubmit` | done | `status`: string?, `disabled`: bool?, `press` (handler) |
| `PromptInputSelect` | done | `value`: string?, `options`: string[]? |
| `PromptInputSelectTrigger` | done | — |
| `PromptInputSelectValue` | done | `value`: string?, `placeholder`: string? |
| `PromptInputSelectContent` | done | — |
| `PromptInputSelectItem` | done | `value`: string, `selected`: string?, `press` (handler) |
| `PromptInputActionMenu` | done | — |
| `PromptInputActionMenuTrigger` | done | `label`: string? |
| `PromptInputActionMenuContent` | done | — |
| `PromptInputActionMenuItem` | done | `press` (handler), `disabled`: bool? |
| `PromptInputActionAddAttachments` | done | `files`: File[], `label`: string?, `accept`: string?, `maxFiles`: number?, `maxFileSize`: number?, `error`: string?. fs.pick; give it the limits too. |
| `PromptInputSpeechButton` | done | `value`: string, `lang`: string?, `disabled`: bool?. speech.listen into `value`. |
| `PromptInputHoverCard` | done | — |
| `PromptInputHoverCardTrigger` | done | — |
| `PromptInputHoverCardContent` | done | — |
| `PromptInputTabsList` | done | — |
| `PromptInputTab` | done | — |
| `PromptInputTabLabel` | done | — |
| `PromptInputTabBody` | done | — |
| `PromptInputTabItem` | done | — |
| `PromptInputCommand` | done | — |
| `PromptInputCommandInput` | done | `value`: string, `placeholder`: string?, `key` (handler, given k), `active`: string?, `list`: string? |
| `PromptInputCommandList` | done | — |
| `PromptInputCommandEmpty` | done | — |
| `PromptInputCommandGroup` | done | `heading`: string? |
| `PromptInputCommandItem` | done | `value`: string?, `active`: bool?, `press` (handler), `disabled`: bool? |
| `PromptInputCommandSeparator` | done | — |
