@assistant-ui/mcp-docs-server 0.1.24 → 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 +8 -6
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +10 -11
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +31 -19
- package/.docs/organized/code-examples/with-artifacts.md +8 -8
- package/.docs/organized/code-examples/with-assistant-transport.md +6 -6
- package/.docs/organized/code-examples/with-chain-of-thought.md +37 -29
- package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
- package/.docs/organized/code-examples/with-cloud.md +8 -8
- package/.docs/organized/code-examples/with-custom-thread-list.md +10 -10
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +11 -11
- package/.docs/organized/code-examples/with-expo.md +571 -520
- package/.docs/organized/code-examples/with-external-store.md +6 -6
- package/.docs/organized/code-examples/with-ffmpeg.md +8 -8
- package/.docs/organized/code-examples/with-google-adk.md +353 -0
- package/.docs/organized/code-examples/with-heat-graph.md +304 -0
- package/.docs/organized/code-examples/with-interactables.md +778 -0
- package/.docs/organized/code-examples/with-langgraph.md +28 -26
- package/.docs/organized/code-examples/with-parent-id-grouping.md +7 -7
- package/.docs/organized/code-examples/with-react-hook-form.md +9 -9
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-store.md +33 -22
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/organized/code-examples/with-tap-runtime.md +12 -10
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +258 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +74 -9
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
- package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +74 -15
- package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
- package/.docs/raw/docs/(docs)/guides/interactables.mdx +292 -0
- package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +5 -4
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +174 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
- package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
- package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
- package/.docs/raw/docs/(docs)/index.mdx +3 -3
- package/.docs/raw/docs/(docs)/installation.mdx +69 -46
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +226 -44
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
- package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
- package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
- package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +90 -6
- package/.docs/raw/docs/cloud/ai-sdk.mdx +95 -5
- package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
- package/.docs/raw/docs/ink/adapters.mdx +41 -0
- package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
- package/.docs/raw/docs/ink/hooks.mdx +448 -0
- package/.docs/raw/docs/ink/index.mdx +239 -0
- package/.docs/raw/docs/ink/migration.mdx +140 -0
- package/.docs/raw/docs/ink/primitives.mdx +840 -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/react-native/adapters.mdx +63 -87
- package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
- package/.docs/raw/docs/react-native/hooks.mdx +214 -232
- package/.docs/raw/docs/react-native/index.mdx +118 -159
- package/.docs/raw/docs/react-native/migration.mdx +144 -0
- package/.docs/raw/docs/react-native/primitives.mdx +431 -302
- package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
- package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
- package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
- package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
- package/.docs/raw/docs/ui/file.mdx +5 -4
- package/.docs/raw/docs/ui/image.mdx +5 -4
- package/.docs/raw/docs/ui/markdown.mdx +3 -1
- package/.docs/raw/docs/ui/mention.mdx +168 -0
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
- package/.docs/raw/docs/ui/quote.mdx +210 -0
- package/.docs/raw/docs/ui/reasoning.mdx +12 -11
- package/.docs/raw/docs/ui/sources.mdx +88 -17
- package/.docs/raw/docs/ui/streamdown.mdx +16 -7
- package/.docs/raw/docs/ui/thread-list.mdx +11 -13
- package/.docs/raw/docs/ui/thread.mdx +28 -33
- package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
- package/.docs/raw/docs/ui/tool-group.mdx +9 -8
- package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
- package/package.json +5 -5
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
- package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
- /package/.docs/raw/docs/cloud/{overview.mdx → index.mdx} +0 -0
|
@@ -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)
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AssistantModal
|
|
3
|
+
description: A floating chat popover with a fixed-position trigger button that opens a chat panel.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { AssistantModalSample } from "@/components/docs/samples/assistant-modal";
|
|
7
|
+
import { AssistantModalPrimitive as AssistantModalPrimitiveDocs } from "@/generated/primitiveDocs";
|
|
8
|
+
|
|
9
|
+
The AssistantModal primitive is a floating chat popover built on [Radix Popover](https://www.radix-ui.com/primitives/docs/components/popover). A trigger button opens a chat panel, which is a common floating assistant launcher pattern. You control the trigger, content, positioning, and animations.
|
|
10
|
+
|
|
11
|
+
<Tabs items={["Preview", "Code"]}>
|
|
12
|
+
<Tab>
|
|
13
|
+
<AssistantModalSample />
|
|
14
|
+
</Tab>
|
|
15
|
+
<Tab>
|
|
16
|
+
```tsx
|
|
17
|
+
import { AssistantModalPrimitive } from "@assistant-ui/react";
|
|
18
|
+
|
|
19
|
+
function MinimalAssistantModal() {
|
|
20
|
+
return (
|
|
21
|
+
<AssistantModalPrimitive.Root>
|
|
22
|
+
<AssistantModalPrimitive.Anchor>
|
|
23
|
+
<AssistantModalPrimitive.Trigger>
|
|
24
|
+
Open Chat
|
|
25
|
+
</AssistantModalPrimitive.Trigger>
|
|
26
|
+
</AssistantModalPrimitive.Anchor>
|
|
27
|
+
<AssistantModalPrimitive.Content>
|
|
28
|
+
{/* Your Thread goes here */}
|
|
29
|
+
</AssistantModalPrimitive.Content>
|
|
30
|
+
</AssistantModalPrimitive.Root>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
</Tab>
|
|
35
|
+
</Tabs>
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
Minimal example:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { AssistantModalPrimitive } from "@assistant-ui/react";
|
|
43
|
+
|
|
44
|
+
<AssistantModalPrimitive.Root>
|
|
45
|
+
<AssistantModalPrimitive.Anchor>
|
|
46
|
+
<AssistantModalPrimitive.Trigger>Open</AssistantModalPrimitive.Trigger>
|
|
47
|
+
</AssistantModalPrimitive.Anchor>
|
|
48
|
+
<AssistantModalPrimitive.Content>
|
|
49
|
+
<Thread />
|
|
50
|
+
</AssistantModalPrimitive.Content>
|
|
51
|
+
</AssistantModalPrimitive.Root>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`Root` is a Radix Popover provider (no DOM), `Trigger` renders a `<button>`, `Anchor` renders a `<div>`, and `Content` renders a `<div>` inside a portal. Add your own classes, animations, and layout.
|
|
55
|
+
|
|
56
|
+
<Callout type="info">
|
|
57
|
+
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).
|
|
58
|
+
</Callout>
|
|
59
|
+
|
|
60
|
+
## Core Concepts
|
|
61
|
+
|
|
62
|
+
### Popover Architecture
|
|
63
|
+
|
|
64
|
+
AssistantModal is built directly on Radix Popover. `Root` manages open/close state, `Trigger` toggles it, `Anchor` positions the popover, and `Content` is the floating panel. All Radix Popover props are available on the corresponding parts.
|
|
65
|
+
|
|
66
|
+
### Anchor vs Trigger
|
|
67
|
+
|
|
68
|
+
`Content` positions itself relative to `Anchor`, not `Trigger`. The common pattern is wrapping `Trigger` inside `Anchor` so the popover aligns to a larger area (like a fixed-position button container) rather than the button itself:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<AssistantModalPrimitive.Anchor className="fixed right-4 bottom-4 size-11">
|
|
72
|
+
<AssistantModalPrimitive.Trigger>
|
|
73
|
+
Open
|
|
74
|
+
</AssistantModalPrimitive.Trigger>
|
|
75
|
+
</AssistantModalPrimitive.Anchor>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Auto-Open on Run Start
|
|
79
|
+
|
|
80
|
+
The `unstable_openOnRunStart` prop (default `true`) automatically opens the modal when the assistant starts responding. This means if a user triggers a run programmatically while the modal is closed, it pops open to show the response. Set to `false` to disable.
|
|
81
|
+
|
|
82
|
+
### Dismiss Behavior
|
|
83
|
+
|
|
84
|
+
`Content` uses `dissmissOnInteractOutside` *(intentional current API spelling, with the extra `s`)* and defaults it to `false`. Clicking outside the modal does **not** close it. This matches expected chat UX where users interact with the page while keeping the chat open. Set it to `true` for standard popover dismiss behavior.
|
|
85
|
+
|
|
86
|
+
### Open/Close Animations
|
|
87
|
+
|
|
88
|
+
`Content` exposes `data-[state=open]` and `data-[state=closed]` attributes for CSS animations:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<AssistantModalPrimitive.Content
|
|
92
|
+
className="data-[state=open]:animate-in data-[state=open]:fade-in data-[state=closed]:animate-out data-[state=closed]:fade-out"
|
|
93
|
+
>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Parts
|
|
97
|
+
|
|
98
|
+
### Root
|
|
99
|
+
|
|
100
|
+
Radix Popover provider, manages open/close state. No DOM element rendered.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<AssistantModalPrimitive.Root unstable_openOnRunStart={false}>
|
|
104
|
+
...
|
|
105
|
+
</AssistantModalPrimitive.Root>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
<PrimitivesTypeTable type="AssistantModalPrimitiveRootProps" parameters={AssistantModalPrimitiveDocs.Root.props} />
|
|
109
|
+
|
|
110
|
+
### Trigger
|
|
111
|
+
|
|
112
|
+
Button that toggles the modal open and closed. Renders a `<button>` element unless `asChild` is set.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
<AssistantModalPrimitive.Trigger className="rounded-full bg-primary px-4 py-2 text-primary-foreground">
|
|
116
|
+
Open Chat
|
|
117
|
+
</AssistantModalPrimitive.Trigger>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Anchor
|
|
121
|
+
|
|
122
|
+
Positions the trigger and content relative to a shared anchor. Renders a `<div>` element unless `asChild` is set.
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<AssistantModalPrimitive.Anchor className="fixed right-4 bottom-4">
|
|
126
|
+
<AssistantModalPrimitive.Trigger>Chat</AssistantModalPrimitive.Trigger>
|
|
127
|
+
</AssistantModalPrimitive.Anchor>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Content
|
|
131
|
+
|
|
132
|
+
The floating chat panel. Renders a `<div>` element inside a portal.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<AssistantModalPrimitive.Content
|
|
136
|
+
sideOffset={16}
|
|
137
|
+
className="h-[600px] w-[400px] rounded-xl border bg-background shadow-lg"
|
|
138
|
+
>
|
|
139
|
+
<Thread />
|
|
140
|
+
</AssistantModalPrimitive.Content>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
<PrimitivesTypeTable type="AssistantModalPrimitiveContentProps" parameters={AssistantModalPrimitiveDocs.Content.props} />
|
|
144
|
+
|
|
145
|
+
## Patterns
|
|
146
|
+
|
|
147
|
+
### Floating Bottom-Right Widget
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<AssistantModalPrimitive.Root>
|
|
151
|
+
<AssistantModalPrimitive.Anchor className="fixed right-4 bottom-4 size-11">
|
|
152
|
+
<AssistantModalPrimitive.Trigger className="size-full rounded-full bg-primary text-primary-foreground shadow-lg">
|
|
153
|
+
<BotIcon className="size-6" />
|
|
154
|
+
</AssistantModalPrimitive.Trigger>
|
|
155
|
+
</AssistantModalPrimitive.Anchor>
|
|
156
|
+
<AssistantModalPrimitive.Content
|
|
157
|
+
sideOffset={16}
|
|
158
|
+
className="h-[600px] w-[400px] rounded-xl border bg-background shadow-lg"
|
|
159
|
+
>
|
|
160
|
+
<Thread />
|
|
161
|
+
</AssistantModalPrimitive.Content>
|
|
162
|
+
</AssistantModalPrimitive.Root>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Trigger Icon Swap
|
|
166
|
+
|
|
167
|
+
The `Trigger` button receives a `data-state` attribute from Radix (`"open"` or `"closed"`). To pass that state down to child icons, use `asChild` with a wrapper component that destructures and forwards it:
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { forwardRef } from "react";
|
|
171
|
+
|
|
172
|
+
const ModalButton = forwardRef<
|
|
173
|
+
HTMLButtonElement,
|
|
174
|
+
React.ComponentPropsWithoutRef<"button"> & { "data-state"?: string }
|
|
175
|
+
>(({ "data-state": state, ...props }, ref) => (
|
|
176
|
+
<button ref={ref} {...props} className="relative size-11 rounded-full">
|
|
177
|
+
<BotIcon
|
|
178
|
+
data-state={state}
|
|
179
|
+
className="absolute size-6 transition-all data-[state=open]:rotate-90 data-[state=open]:scale-0"
|
|
180
|
+
/>
|
|
181
|
+
<XIcon
|
|
182
|
+
data-state={state}
|
|
183
|
+
className="absolute size-6 transition-all data-[state=closed]:-rotate-90 data-[state=closed]:scale-0"
|
|
184
|
+
/>
|
|
185
|
+
</button>
|
|
186
|
+
));
|
|
187
|
+
|
|
188
|
+
<AssistantModalPrimitive.Trigger asChild>
|
|
189
|
+
<ModalButton />
|
|
190
|
+
</AssistantModalPrimitive.Trigger>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Custom Portal Container
|
|
194
|
+
|
|
195
|
+
Render the content inside a specific container instead of `document.body`:
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
<AssistantModalPrimitive.Content
|
|
199
|
+
portalProps={{ container: myContainerRef.current }}
|
|
200
|
+
>
|
|
201
|
+
<Thread />
|
|
202
|
+
</AssistantModalPrimitive.Content>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Relationship to Components
|
|
206
|
+
|
|
207
|
+
The shadcn [AssistantModal](/docs/ui/assistant-modal) component wraps these primitives with slide/fade animations, icon transitions between open and closed states, and responsive sizing. Start there for a prebuilt floating chat widget.
|
|
208
|
+
|
|
209
|
+
## API Reference
|
|
210
|
+
|
|
211
|
+
For full prop details on every part, see the [AssistantModalPrimitive API Reference](/docs/api-reference/primitives/assistant-modal).
|
|
212
|
+
|
|
213
|
+
Related:
|
|
214
|
+
- [ThreadPrimitive](/docs/primitives/thread)
|
|
215
|
+
- [ComposerPrimitive](/docs/primitives/composer)
|