# Thread

- **[App UI](/app/)**
- **[Assistant](/app/assistant/)**
- **Thread**

A conversation with an assistant: drawn as the agent chat kit draws it (the person in a bubble on the right, the reply as plain text, no avatars or visible names)…

## Notes

- **When to use it**: The message log of an assistant: user and assistant turns, optional code, and idle, streaming, error and empty states. Use `app-assistant-showcase` when you only want a picture of a conversation on a landing page.
- **Writing for it**: - Each turn takes `text` up to 4000 characters and an optional `code` up to 20000. Put commands and file contents in `code` so they get their own scrollable, labelled region instead of running into the prose.
- Names matter: `userName` and `assistantName` (30 characters) name each turn for a screen reader, and the user's avatar shows the first letter of the name.
- For the empty state, give up to 3 `suggestions` of 80 characters as full questions someone would actually ask, since each becomes a button.
- **Watch out for**: With `height` set to fixed the log scrolls inside the block at about 28rem and takes focus from the keyboard, so a fixed thread inside a page with other scrolling content can trap people. Suggestion and Retry buttons do nothing until a host passes handlers.

## Pairs well with

- **[App, assistant composer](/blocks/app/assistant-composer)**
- **[App, assistant tool call](/blocks/app/assistant-tool-call)**
- **[App, assistant approval](/blocks/app/assistant-approval)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppAssistantThread from '@/components/klarhimmel/blocks/app-assistant-thread';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppAssistantThread props={{
          "label": "Name who the conversation is with",
          "state": "idle",
          "height": "auto",
          "codeLabel": "Code",
          "userName": "You",
          "assistantName": "Assistant",
          "turns": [
            {
              "role": "user",
              "text": "Write what a person asks the assistant."
            },
            {
              "role": "assistant",
              "text": "Say what the assistant found, in a sentence or two.\nAdd a second line with the detail that matters most.",
              "code": "First line of the example\nSecond line of the example",
              "sources": [
                {
                  "label": "Name a source",
                  "href": "#rooms"
                }
              ]
            }
          ],
          "typing": "Writing…",
          "error": {
            "title": "Say the answer is missing",
            "message": "Say what went wrong and that the message is saved.",
            "retry": "Try again"
          },
          "empty": {
            "title": "Say what a person can ask about",
            "hint": "Say what the assistant can do for a person, and say when it asks before changing anything.",
            "suggestions": [
              "Suggest a first question",
              "Suggest a second request"
            ]
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## Props

The turns, the speaker names and the four states are the content; height switches between growing with the conversation and a fixed scroll box. The error and empty groups are the words for those two states.

- **label**: Text, up to 60 characters.
- **state**: One of 'idle', 'streaming', 'error', 'empty'.
- **height**: One of 'auto', 'fixed'.
- **userName**: Text, up to 30 characters.
- **assistantName**: Text, up to 30 characters.
- **turns**: List of up to 50. Each item: role ('user' | 'assistant'), text, code (optional), sources (optional), note (optional).
- **sourcesLabel**: Text, up to 30 characters. Optional; empty is not rendered.
- **codeLabel**: Text, up to 30 characters.
- **typing**: Text, up to 40 characters.
- **error**: Fields: title, message, retry.
- **empty**: Fields: title, hint, suggestions.

## Other states

The states of every assistant component, side by side.

- **[Every state](/app/assistant/states)**

## Install

- **CLI**

  ```
  npx shadcn add @klarhimmel/app-assistant-thread
  ```

Uses

- Button

- **About**: A conversation with an assistant: drawn as the agent chat kit draws it (the person in a bubble on the right, the reply as plain text, no avatars or visible names), optional code, sources and a note under a turn (a staff correction), and…
- **States**: Idle, streaming, error with retry, empty with suggestions. A log region; every turn is labelled by speaker. New project? Set it up once: /get-started/installation.
