# Live conversation

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

Thread, composer, tool call and approval playing together on local state. Send any message, then approve or deny. No network.

## Wiring

The four blocks on local state, as installed by the command above. Send a message to see the tool call and the approval.

Assistant.tsx

```
import { useState } from 'react';
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import { Thread, spec as thread } from '@/components/klarhimmel/blocks/app-assistant-thread';
import { Composer, spec as composer } from '@/components/klarhimmel/blocks/app-assistant-composer';
import { ToolCall, spec as tool } from '@/components/klarhimmel/blocks/app-assistant-tool-call';
import { Approval, spec as approval } from '@/components/klarhimmel/blocks/app-assistant-approval';

type Turn = { role: 'user' | 'assistant'; text: string };

export default function Assistant() {
  const [draft, setDraft] = useState('');
  const [turns, setTurns] = useState<Turn[]>([]);
  const send = () => {
    setTurns((t) => [...t, { role: 'user', text: draft }]);
    setDraft('');
  };
  const answer = (text: string) => setTurns((t) => [...t, { role: 'assistant', text }]);
  return (
    <Theme>
      <BlockSurface>
        <main className="mx-auto flex max-w-kh-narrow flex-col gap-4 p-4">
          <Thread props={{ ...thread.defaults, state: turns.length ? 'idle' : 'empty', turns }} onSuggest={setDraft}>
            {turns.length > 0 && <ToolCall props={tool.defaults} />}
            {turns.length > 0 && <Approval props={approval.defaults} onApprove={() => answer('Done.')} onDeny={() => answer('Left as it is.')} />}
          </Thread>
          <Composer props={{ ...composer.defaults, attachments: [], state: draft ? 'filled' : 'ready' }} value={draft} onChange={setDraft} onSend={send} />
        </main>
      </BlockSurface>
    </Theme>
  );
}
```

## 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 @klarhimmel/app-assistant-composer @klarhimmel/app-assistant-tool-call @klarhimmel/app-assistant-approval
  ```

Uses

- Button
- Textarea

- **States**: Empty, asked, approved, denied. A scripted run: any message starts the same sequence, and the next message starts another run below it. New project? Set it up once: /get-started/installation.
