@assistant-ui/mcp-docs-server 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/waterfall.md +4 -4
- package/.docs/organized/code-examples/with-a2a.md +5 -5
- package/.docs/organized/code-examples/with-ag-ui.md +6 -6
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +7 -7
- package/.docs/organized/code-examples/with-artifacts.md +7 -7
- package/.docs/organized/code-examples/with-assistant-transport.md +5 -5
- package/.docs/organized/code-examples/with-chain-of-thought.md +7 -7
- package/.docs/organized/code-examples/with-cloud-standalone.md +8 -8
- package/.docs/organized/code-examples/with-cloud.md +7 -7
- package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +10 -10
- package/.docs/organized/code-examples/with-expo.md +14 -14
- package/.docs/organized/code-examples/with-external-store.md +5 -5
- package/.docs/organized/code-examples/with-ffmpeg.md +7 -7
- package/.docs/organized/code-examples/with-google-adk.md +5 -5
- package/.docs/organized/code-examples/with-heat-graph.md +4 -4
- package/.docs/organized/code-examples/with-interactables.md +778 -0
- package/.docs/organized/code-examples/with-langgraph.md +6 -6
- package/.docs/organized/code-examples/with-parent-id-grouping.md +6 -6
- package/.docs/organized/code-examples/with-react-hook-form.md +8 -8
- package/.docs/organized/code-examples/with-react-ink.md +2 -2
- package/.docs/organized/code-examples/with-react-router.md +10 -10
- package/.docs/organized/code-examples/with-store.md +5 -5
- package/.docs/organized/code-examples/with-tanstack.md +8 -8
- package/.docs/organized/code-examples/with-tap-runtime.md +8 -8
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +31 -0
- package/.docs/raw/docs/(docs)/cli.mdx +60 -0
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +65 -4
- package/.docs/raw/docs/(docs)/guides/interactables.mdx +292 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +3 -3
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +128 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +6 -0
- package/.docs/raw/docs/cloud/ai-sdk.mdx +81 -1
- package/.docs/raw/docs/ink/primitives.mdx +141 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +351 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +215 -0
- package/.docs/raw/docs/primitives/attachment.mdx +216 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +221 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +311 -0
- package/.docs/raw/docs/primitives/composer.mdx +526 -0
- package/.docs/raw/docs/primitives/error.mdx +141 -0
- package/.docs/raw/docs/primitives/index.mdx +98 -0
- package/.docs/raw/docs/primitives/message.mdx +524 -0
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +165 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +242 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +404 -0
- package/.docs/raw/docs/primitives/thread.mdx +482 -0
- package/.docs/raw/docs/ui/mention.mdx +168 -0
- package/package.json +3 -3
|
@@ -697,3 +697,144 @@ A built-in component for rendering tool calls with expandable/collapsible output
|
|
|
697
697
|
| `renderHeader` | `(props: { toolName, status, expanded }) => ReactNode` | Custom header renderer |
|
|
698
698
|
| `renderArgs` | `(props: { args, argsText }) => ReactNode` | Custom args renderer |
|
|
699
699
|
| `renderResult` | `(props: { result, isError }) => ReactNode` | Custom result renderer |
|
|
700
|
+
|
|
701
|
+
## Diff
|
|
702
|
+
|
|
703
|
+
```tsx
|
|
704
|
+
import { DiffPrimitive, DiffView } from "@assistant-ui/react-ink";
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
Components for rendering code diffs in the terminal.
|
|
708
|
+
|
|
709
|
+
### DiffView
|
|
710
|
+
|
|
711
|
+
Pre-composed component that combines all diff primitives for easy diff rendering. Accepts either a unified diff patch string or old/new file content for inline comparison.
|
|
712
|
+
|
|
713
|
+
```tsx
|
|
714
|
+
// From a patch string
|
|
715
|
+
<DiffView
|
|
716
|
+
patch={unifiedDiffString}
|
|
717
|
+
showLineNumbers
|
|
718
|
+
contextLines={3}
|
|
719
|
+
maxLines={50}
|
|
720
|
+
/>
|
|
721
|
+
|
|
722
|
+
// From file contents
|
|
723
|
+
<DiffView
|
|
724
|
+
oldFile={{ content: "old text", name: "file.txt" }}
|
|
725
|
+
newFile={{ content: "new text", name: "file.txt" }}
|
|
726
|
+
showLineNumbers
|
|
727
|
+
/>
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
| Prop | Type | Description |
|
|
731
|
+
|------|------|-------------|
|
|
732
|
+
| `patch` | `string` | Unified diff patch string to parse and display |
|
|
733
|
+
| `oldFile` | `{ content: string; name?: string }` | Old file content for inline comparison |
|
|
734
|
+
| `newFile` | `{ content: string; name?: string }` | New file content for inline comparison |
|
|
735
|
+
| `showLineNumbers` | `boolean` | Whether to show line numbers (default: true) |
|
|
736
|
+
| `contextLines` | `number` | Number of context lines to show around changes |
|
|
737
|
+
| `maxLines` | `number` | Maximum number of lines to display |
|
|
738
|
+
|
|
739
|
+
### Root
|
|
740
|
+
|
|
741
|
+
Container `Box` that provides diff context to child components. Parses the patch or computes the diff from old/new file content.
|
|
742
|
+
|
|
743
|
+
```tsx
|
|
744
|
+
<DiffPrimitive.Root
|
|
745
|
+
patch={patchString}
|
|
746
|
+
oldFile={{ content: oldContent, name: "file.txt" }}
|
|
747
|
+
newFile={{ content: newContent, name: "file.txt" }}
|
|
748
|
+
>
|
|
749
|
+
{children}
|
|
750
|
+
</DiffPrimitive.Root>
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
| Prop | Type | Description |
|
|
754
|
+
|------|------|-------------|
|
|
755
|
+
| `patch` | `string` | Unified diff patch string |
|
|
756
|
+
| `oldFile` | `{ content: string; name?: string }` | Old file for inline diff |
|
|
757
|
+
| `newFile` | `{ content: string; name?: string }` | New file for inline diff |
|
|
758
|
+
|
|
759
|
+
### Header
|
|
760
|
+
|
|
761
|
+
Displays file header information including filename(s) and change statistics.
|
|
762
|
+
|
|
763
|
+
```tsx
|
|
764
|
+
<DiffPrimitive.Header fileIndex={0} />
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
| Prop | Type | Description |
|
|
768
|
+
|------|------|-------------|
|
|
769
|
+
| `fileIndex` | `number` | Index of file to display header for (default: 0) |
|
|
770
|
+
|
|
771
|
+
### Content
|
|
772
|
+
|
|
773
|
+
Renders the diff content with lines. Supports context folding and line truncation.
|
|
774
|
+
|
|
775
|
+
```tsx
|
|
776
|
+
<DiffPrimitive.Content
|
|
777
|
+
fileIndex={0}
|
|
778
|
+
showLineNumbers
|
|
779
|
+
contextLines={3}
|
|
780
|
+
maxLines={100}
|
|
781
|
+
renderLine={({ line, index }) => <CustomLine line={line} />}
|
|
782
|
+
renderFold={({ region, index }) => <CustomFold region={region} />}
|
|
783
|
+
/>
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
| Prop | Type | Description |
|
|
787
|
+
|------|------|-------------|
|
|
788
|
+
| `fileIndex` | `number` | Index of file to display (default: 0) |
|
|
789
|
+
| `showLineNumbers` | `boolean` | Show line numbers (default: true) |
|
|
790
|
+
| `contextLines` | `number` | Number of context lines around changes |
|
|
791
|
+
| `maxLines` | `number` | Maximum lines to display |
|
|
792
|
+
| `renderLine` | `(props: { line; index }) => ReactNode` | Custom line renderer |
|
|
793
|
+
| `renderFold` | `(props: { region; index }) => ReactNode` | Custom fold region renderer |
|
|
794
|
+
|
|
795
|
+
### Line
|
|
796
|
+
|
|
797
|
+
Renders an individual diff line with appropriate coloring and indicators.
|
|
798
|
+
|
|
799
|
+
```tsx
|
|
800
|
+
<DiffPrimitive.Line
|
|
801
|
+
line={parsedLine}
|
|
802
|
+
showLineNumbers
|
|
803
|
+
lineNumberWidth={4}
|
|
804
|
+
/>
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
| Prop | Type | Description |
|
|
808
|
+
|------|------|-------------|
|
|
809
|
+
| `line` | `ParsedLine` | The parsed line object to render |
|
|
810
|
+
| `showLineNumbers` | `boolean` | Show line numbers (default: true) |
|
|
811
|
+
| `lineNumberWidth` | `number` | Width for line number padding (default: 4) |
|
|
812
|
+
|
|
813
|
+
### Stats
|
|
814
|
+
|
|
815
|
+
Displays diff statistics (additions and deletions count).
|
|
816
|
+
|
|
817
|
+
```tsx
|
|
818
|
+
<DiffPrimitive.Stats fileIndex={0} />
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
| Prop | Type | Description |
|
|
822
|
+
|------|------|-------------|
|
|
823
|
+
| `fileIndex` | `number` | Index of file to display stats for (default: 0) |
|
|
824
|
+
|
|
825
|
+
### Composing with Primitives
|
|
826
|
+
|
|
827
|
+
For custom layouts, use the primitives directly:
|
|
828
|
+
|
|
829
|
+
```tsx
|
|
830
|
+
<DiffPrimitive.Root patch={patchString}>
|
|
831
|
+
<Box flexDirection="column">
|
|
832
|
+
<DiffPrimitive.Header />
|
|
833
|
+
<DiffPrimitive.Stats />
|
|
834
|
+
<DiffPrimitive.Content
|
|
835
|
+
showLineNumbers
|
|
836
|
+
contextLines={2}
|
|
837
|
+
/>
|
|
838
|
+
</Box>
|
|
839
|
+
</DiffPrimitive.Root>
|
|
840
|
+
```
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ActionBar
|
|
3
|
+
description: Build message action buttons with auto-hide, copy state, and intelligent disabling.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { ActionBarPrimitiveSample } from "@/components/docs/samples/action-bar-primitive";
|
|
7
|
+
import { ActionBarPrimitive as ActionBarPrimitiveDocs } from "@/generated/primitiveDocs";
|
|
8
|
+
|
|
9
|
+
The ActionBar primitive provides message actions: copy, reload, edit, feedback, speech, and export. It handles intelligent visibility with auto-hide on hover, automatic disabling based on message state, and floating behavior. You compose the buttons; the primitive handles action state and availability.
|
|
10
|
+
|
|
11
|
+
<Tabs items={["Preview", "Code"]}>
|
|
12
|
+
<Tab>
|
|
13
|
+
<ActionBarPrimitiveSample />
|
|
14
|
+
</Tab>
|
|
15
|
+
<Tab>
|
|
16
|
+
```tsx
|
|
17
|
+
import {
|
|
18
|
+
ActionBarPrimitive,
|
|
19
|
+
MessagePrimitive,
|
|
20
|
+
} from "@assistant-ui/react";
|
|
21
|
+
import { CheckIcon, CopyIcon, RefreshCwIcon } from "lucide-react";
|
|
22
|
+
|
|
23
|
+
function AssistantMessage() {
|
|
24
|
+
return (
|
|
25
|
+
<MessagePrimitive.Root className="group flex flex-col items-start gap-1">
|
|
26
|
+
<div className="max-w-[80%] rounded-2xl bg-muted px-4 py-2.5 text-sm">
|
|
27
|
+
<MessagePrimitive.Parts />
|
|
28
|
+
</div>
|
|
29
|
+
<ActionBarPrimitive.Root
|
|
30
|
+
hideWhenRunning
|
|
31
|
+
autohide="not-last"
|
|
32
|
+
autohideFloat="always"
|
|
33
|
+
className="flex gap-0.5 data-[floating]:opacity-0 data-[floating]:group-hover:opacity-100 data-[floating]:transition-opacity"
|
|
34
|
+
>
|
|
35
|
+
<ActionBarPrimitive.Copy className="group/copy flex size-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground">
|
|
36
|
+
<CopyIcon className="size-4 group-data-[copied]/copy:hidden" />
|
|
37
|
+
<CheckIcon className="hidden size-4 group-data-[copied]/copy:block" />
|
|
38
|
+
</ActionBarPrimitive.Copy>
|
|
39
|
+
<ActionBarPrimitive.Reload className="flex size-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground">
|
|
40
|
+
<RefreshCwIcon className="size-4" />
|
|
41
|
+
</ActionBarPrimitive.Reload>
|
|
42
|
+
</ActionBarPrimitive.Root>
|
|
43
|
+
</MessagePrimitive.Root>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
</Tab>
|
|
48
|
+
</Tabs>
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
A minimal action bar with copy and reload:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { ActionBarPrimitive } from "@assistant-ui/react";
|
|
56
|
+
|
|
57
|
+
<ActionBarPrimitive.Root>
|
|
58
|
+
<ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
|
|
59
|
+
<ActionBarPrimitive.Reload>Reload</ActionBarPrimitive.Reload>
|
|
60
|
+
</ActionBarPrimitive.Root>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`Root` renders a `<div>`, action buttons render `<button>` elements. Each button auto-disables when its action isn't available (e.g., Copy is disabled when there's no content, Reload is disabled while the model is running).
|
|
64
|
+
|
|
65
|
+
<Callout type="info">
|
|
66
|
+
ActionBar must be placed inside a `MessagePrimitive.Root` because it reads message state from the nearest message context.
|
|
67
|
+
</Callout>
|
|
68
|
+
|
|
69
|
+
<Callout type="info">
|
|
70
|
+
Runtime setup: primitives require runtime context. Wrap your UI in `AssistantRuntimeProvider` with a runtime (for example `useLocalRuntime(...)`). See [Pick a Runtime](/docs/runtimes/pick-a-runtime).
|
|
71
|
+
</Callout>
|
|
72
|
+
|
|
73
|
+
## Core Concepts
|
|
74
|
+
|
|
75
|
+
### Auto-Hide & Floating
|
|
76
|
+
|
|
77
|
+
The `autohide` prop controls when the action bar is visible:
|
|
78
|
+
|
|
79
|
+
- **`"never"`** (default): always visible
|
|
80
|
+
- **`"not-last"`**: hidden on all messages except the last, shown on hover
|
|
81
|
+
- **`"always"`**: hidden on all messages, shown on hover
|
|
82
|
+
|
|
83
|
+
When `autohideFloat` is set, hidden action bars get the `data-floating` attribute instead of being removed from the DOM. This lets you animate them with CSS:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<ActionBarPrimitive.Root
|
|
87
|
+
autohide="not-last"
|
|
88
|
+
autohideFloat="always"
|
|
89
|
+
className="data-[floating]:opacity-0 data-[floating]:group-hover:opacity-100 data-[floating]:transition-opacity"
|
|
90
|
+
>
|
|
91
|
+
{/* buttons */}
|
|
92
|
+
</ActionBarPrimitive.Root>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The `"single-branch"` option for `autohideFloat` only floats when the message has a single branch (no alternatives).
|
|
96
|
+
|
|
97
|
+
### Automatic Disabling
|
|
98
|
+
|
|
99
|
+
Action buttons automatically disable based on state, with no manual wiring needed:
|
|
100
|
+
|
|
101
|
+
- **Copy**: disabled when there's no copyable text content or an assistant message is still running
|
|
102
|
+
- **Reload**: disabled when the thread is running or the message role isn't assistant
|
|
103
|
+
- **Edit**: disabled when the message is already being edited
|
|
104
|
+
- **Speak**: disabled when there's no speakable text or an assistant message is still running
|
|
105
|
+
|
|
106
|
+
### Copy State
|
|
107
|
+
|
|
108
|
+
After clicking Copy, the button gets a `data-copied` attribute for a configurable duration (default 3 seconds). Use this for visual feedback:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<ActionBarPrimitive.Copy copiedDuration={2000} className="group">
|
|
112
|
+
<CopyIcon className="group-data-[copied]:hidden" />
|
|
113
|
+
<CheckIcon className="hidden group-data-[copied]:block" />
|
|
114
|
+
</ActionBarPrimitive.Copy>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Feedback Buttons
|
|
118
|
+
|
|
119
|
+
Feedback buttons track submission state with `data-submitted`:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<ActionBarPrimitive.FeedbackPositive className="data-[submitted]:text-green-500">
|
|
123
|
+
👍
|
|
124
|
+
</ActionBarPrimitive.FeedbackPositive>
|
|
125
|
+
<ActionBarPrimitive.FeedbackNegative className="data-[submitted]:text-red-500">
|
|
126
|
+
👎
|
|
127
|
+
</ActionBarPrimitive.FeedbackNegative>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Parts
|
|
131
|
+
|
|
132
|
+
### Root
|
|
133
|
+
|
|
134
|
+
Container with auto-hide and floating behavior. Renders a `<div>` element unless `asChild` is set.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
<ActionBarPrimitive.Root
|
|
138
|
+
hideWhenRunning
|
|
139
|
+
autohide="not-last"
|
|
140
|
+
autohideFloat="always"
|
|
141
|
+
className="flex gap-1"
|
|
142
|
+
>
|
|
143
|
+
<ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
|
|
144
|
+
<ActionBarPrimitive.Reload>Reload</ActionBarPrimitive.Reload>
|
|
145
|
+
</ActionBarPrimitive.Root>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
<PrimitivesTypeTable type="ActionBarPrimitiveRootProps" parameters={ActionBarPrimitiveDocs.Root.props.filter(p => p.name !== "asChild")} />
|
|
149
|
+
|
|
150
|
+
### Copy
|
|
151
|
+
|
|
152
|
+
Copies message text to clipboard. Renders a `<button>` element unless `asChild` is set.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<ActionBarPrimitive.Copy copiedDuration={2000} className="group">
|
|
156
|
+
<CopyIcon className="group-data-[copied]:hidden" />
|
|
157
|
+
<CheckIcon className="hidden group-data-[copied]:block" />
|
|
158
|
+
</ActionBarPrimitive.Copy>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
<PrimitivesTypeTable type="ActionBarPrimitiveCopyProps" parameters={ActionBarPrimitiveDocs.Copy.props.filter(p => p.name !== "asChild")} />
|
|
162
|
+
|
|
163
|
+
### Reload
|
|
164
|
+
|
|
165
|
+
Reloads or regenerates the current assistant message. Renders a `<button>` element unless `asChild` is set.
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
<ActionBarPrimitive.Reload className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
169
|
+
Regenerate
|
|
170
|
+
</ActionBarPrimitive.Reload>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Edit
|
|
174
|
+
|
|
175
|
+
Enters edit mode for the current message. Renders a `<button>` element unless `asChild` is set.
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
<ActionBarPrimitive.Edit className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
179
|
+
Edit
|
|
180
|
+
</ActionBarPrimitive.Edit>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Speak
|
|
184
|
+
|
|
185
|
+
Starts speech playback for the current message. Renders a `<button>` element unless `asChild` is set.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
<ActionBarPrimitive.Speak className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
189
|
+
Play
|
|
190
|
+
</ActionBarPrimitive.Speak>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### StopSpeaking
|
|
194
|
+
|
|
195
|
+
Stops speech playback for the current message. Renders a `<button>` element unless `asChild` is set.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
<ActionBarPrimitive.StopSpeaking className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
199
|
+
Stop
|
|
200
|
+
</ActionBarPrimitive.StopSpeaking>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### FeedbackPositive
|
|
204
|
+
|
|
205
|
+
Submits positive feedback for the current message. Renders a `<button>` element unless `asChild` is set.
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<ActionBarPrimitive.FeedbackPositive className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
209
|
+
Helpful
|
|
210
|
+
</ActionBarPrimitive.FeedbackPositive>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### FeedbackNegative
|
|
214
|
+
|
|
215
|
+
Submits negative feedback for the current message. Renders a `<button>` element unless `asChild` is set.
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
<ActionBarPrimitive.FeedbackNegative className="rounded-md px-2 py-1 text-sm hover:bg-muted">
|
|
219
|
+
Not helpful
|
|
220
|
+
</ActionBarPrimitive.FeedbackNegative>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### ExportMarkdown
|
|
224
|
+
|
|
225
|
+
Downloads message as Markdown or calls custom handler. Renders a `<button>` element unless `asChild` is set.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
<ActionBarPrimitive.ExportMarkdown
|
|
229
|
+
onExport={async (content) => {
|
|
230
|
+
await navigator.clipboard.writeText(content);
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
Export
|
|
234
|
+
</ActionBarPrimitive.ExportMarkdown>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
<PrimitivesTypeTable type="ActionBarPrimitiveExportMarkdownProps" parameters={ActionBarPrimitiveDocs.ExportMarkdown.props.filter(p => p.name !== "asChild")} />
|
|
238
|
+
|
|
239
|
+
## Patterns
|
|
240
|
+
|
|
241
|
+
### Assistant Action Bar
|
|
242
|
+
|
|
243
|
+
```tsx
|
|
244
|
+
<ActionBarPrimitive.Root
|
|
245
|
+
hideWhenRunning
|
|
246
|
+
autohide="not-last"
|
|
247
|
+
autohideFloat="single-branch"
|
|
248
|
+
>
|
|
249
|
+
<ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
|
|
250
|
+
<ActionBarPrimitive.Reload>Regenerate</ActionBarPrimitive.Reload>
|
|
251
|
+
<ActionBarPrimitive.ExportMarkdown>Export</ActionBarPrimitive.ExportMarkdown>
|
|
252
|
+
</ActionBarPrimitive.Root>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### User Action Bar
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
<ActionBarPrimitive.Root hideWhenRunning autohide="not-last">
|
|
259
|
+
<ActionBarPrimitive.Edit>Edit</ActionBarPrimitive.Edit>
|
|
260
|
+
</ActionBarPrimitive.Root>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Speech Toggle
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
<AuiIf condition={(s) => !s.message.isSpeaking}>
|
|
267
|
+
<ActionBarPrimitive.Speak>Play</ActionBarPrimitive.Speak>
|
|
268
|
+
</AuiIf>
|
|
269
|
+
<AuiIf condition={(s) => s.message.isSpeaking}>
|
|
270
|
+
<ActionBarPrimitive.StopSpeaking>Stop</ActionBarPrimitive.StopSpeaking>
|
|
271
|
+
</AuiIf>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
<Callout type="info">
|
|
275
|
+
Speech requires a `SpeechSynthesisAdapter` configured in your runtime. See [Speech & Dictation](/docs/guides/speech) for setup.
|
|
276
|
+
</Callout>
|
|
277
|
+
|
|
278
|
+
### Export with Custom Handler
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
<ActionBarPrimitive.ExportMarkdown
|
|
282
|
+
onExport={async (content) => {
|
|
283
|
+
await navigator.clipboard.writeText(content);
|
|
284
|
+
toast("Copied as Markdown!");
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
Copy Markdown
|
|
288
|
+
</ActionBarPrimitive.ExportMarkdown>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Overflow Menu (ActionBarMorePrimitive)
|
|
292
|
+
|
|
293
|
+
`ActionBarMorePrimitive` is a Radix DropdownMenu for overflow actions, using the same pattern as `ThreadListItemMorePrimitive`. Use it to group secondary actions behind a "more" button.
|
|
294
|
+
|
|
295
|
+
`ActionBarMorePrimitive.Item` maps to Radix `DropdownMenu.Item`, so it preserves menu keyboard/focus semantics. Prefer `asChild` when composing an `ActionBarPrimitive` button into a menu item.
|
|
296
|
+
|
|
297
|
+
`ActionBarMorePrimitive.Content` defaults to `sideOffset={4}` so the menu has a small gap from the trigger.
|
|
298
|
+
|
|
299
|
+
| Part | Element | Purpose |
|
|
300
|
+
|------|---------|---------|
|
|
301
|
+
| `Root` | N/A | Radix DropdownMenu provider |
|
|
302
|
+
| `Trigger` | `<button>` | Opens the dropdown |
|
|
303
|
+
| `Content` | `<div>` (portal) | The dropdown panel |
|
|
304
|
+
| `Item` | `<div>` | A menu item |
|
|
305
|
+
| `Separator` | `<div>` | Visual separator between items |
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
import {
|
|
309
|
+
ActionBarPrimitive,
|
|
310
|
+
ActionBarMorePrimitive,
|
|
311
|
+
} from "@assistant-ui/react";
|
|
312
|
+
import { MoreHorizontalIcon } from "lucide-react";
|
|
313
|
+
|
|
314
|
+
<ActionBarPrimitive.Root>
|
|
315
|
+
<ActionBarPrimitive.Copy>Copy</ActionBarPrimitive.Copy>
|
|
316
|
+
<ActionBarPrimitive.Reload>Regenerate</ActionBarPrimitive.Reload>
|
|
317
|
+
<ActionBarMorePrimitive.Root>
|
|
318
|
+
<ActionBarMorePrimitive.Trigger className="flex size-8 items-center justify-center rounded-lg hover:bg-muted">
|
|
319
|
+
<MoreHorizontalIcon className="size-4" />
|
|
320
|
+
</ActionBarMorePrimitive.Trigger>
|
|
321
|
+
<ActionBarMorePrimitive.Content side="bottom" align="end">
|
|
322
|
+
<ActionBarMorePrimitive.Item asChild>
|
|
323
|
+
<ActionBarPrimitive.ExportMarkdown>
|
|
324
|
+
Export Markdown
|
|
325
|
+
</ActionBarPrimitive.ExportMarkdown>
|
|
326
|
+
</ActionBarMorePrimitive.Item>
|
|
327
|
+
<ActionBarMorePrimitive.Separator />
|
|
328
|
+
<ActionBarMorePrimitive.Item asChild>
|
|
329
|
+
<ActionBarPrimitive.FeedbackPositive>
|
|
330
|
+
Helpful
|
|
331
|
+
</ActionBarPrimitive.FeedbackPositive>
|
|
332
|
+
</ActionBarMorePrimitive.Item>
|
|
333
|
+
</ActionBarMorePrimitive.Content>
|
|
334
|
+
</ActionBarMorePrimitive.Root>
|
|
335
|
+
</ActionBarPrimitive.Root>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
See the [ActionBarMorePrimitive API Reference](/docs/api-reference/primitives/action-bar-more) for full prop details.
|
|
339
|
+
|
|
340
|
+
## Relationship to Components
|
|
341
|
+
|
|
342
|
+
The shadcn [Thread](/docs/ui/thread) component uses `ActionBarPrimitive` inside its `AssistantMessage` (with Copy, Reload, and an export dropdown) and `UserMessage` (with Edit). If those defaults work, use the component. Reach for `ActionBarPrimitive` directly when you need different actions, custom layout, or actions outside the standard thread UI.
|
|
343
|
+
|
|
344
|
+
ActionBar is commonly paired with [BranchPicker](/docs/primitives/branch-picker) for navigating between alternative responses on assistant messages.
|
|
345
|
+
|
|
346
|
+
## API Reference
|
|
347
|
+
|
|
348
|
+
For full prop details on every part, see the [ActionBarPrimitive API Reference](/docs/api-reference/primitives/action-bar).
|
|
349
|
+
|
|
350
|
+
Related:
|
|
351
|
+
- [ActionBarMorePrimitive API Reference](/docs/api-reference/primitives/action-bar-more)
|