@assistant-ui/mcp-docs-server 0.1.24 → 0.1.25
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 -2
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +5 -6
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +27 -15
- package/.docs/organized/code-examples/with-artifacts.md +4 -4
- package/.docs/organized/code-examples/with-assistant-transport.md +2 -2
- package/.docs/organized/code-examples/with-chain-of-thought.md +33 -25
- package/.docs/organized/code-examples/with-cloud-standalone.md +9 -6
- package/.docs/organized/code-examples/with-cloud.md +4 -4
- package/.docs/organized/code-examples/with-custom-thread-list.md +6 -6
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
- package/.docs/organized/code-examples/with-expo.md +565 -514
- package/.docs/organized/code-examples/with-external-store.md +2 -2
- package/.docs/organized/code-examples/with-ffmpeg.md +4 -4
- 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-langgraph.md +24 -22
- package/.docs/organized/code-examples/with-parent-id-grouping.md +3 -3
- package/.docs/organized/code-examples/with-react-hook-form.md +4 -4
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +5 -5
- package/.docs/organized/code-examples/with-store.md +28 -17
- package/.docs/organized/code-examples/with-tanstack.md +7 -7
- package/.docs/organized/code-examples/with-tap-runtime.md +5 -3
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +227 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +14 -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 +9 -11
- 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/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +2 -1
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +173 -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 +99 -45
- 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 +84 -6
- package/.docs/raw/docs/cloud/ai-sdk.mdx +14 -4
- 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 +699 -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/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 +4 -4
- 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,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quote
|
|
3
|
+
description: Let users select and quote text from messages with a floating toolbar, composer preview, and inline quote display.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { QuoteSample } from "@/components/docs/samples/quote";
|
|
7
|
+
|
|
8
|
+
<QuoteSample />
|
|
9
|
+
|
|
10
|
+
## Getting Started
|
|
11
|
+
|
|
12
|
+
<Steps>
|
|
13
|
+
<Step>
|
|
14
|
+
|
|
15
|
+
### Add `quote`
|
|
16
|
+
|
|
17
|
+
<InstallCommand shadcn={["quote"]} />
|
|
18
|
+
|
|
19
|
+
This adds a `/components/assistant-ui/quote.tsx` file with three components: `QuoteBlock`, `SelectionToolbar`, and `ComposerQuotePreview`.
|
|
20
|
+
|
|
21
|
+
</Step>
|
|
22
|
+
<Step>
|
|
23
|
+
|
|
24
|
+
### Display Quotes in User Messages
|
|
25
|
+
|
|
26
|
+
Add `MessagePrimitive.Quote` above `MessagePrimitive.Parts` in your user message:
|
|
27
|
+
|
|
28
|
+
```tsx title="components/assistant-ui/thread.tsx" {1,8-10}
|
|
29
|
+
import { QuoteBlock } from "@/components/assistant-ui/quote";
|
|
30
|
+
|
|
31
|
+
const UserMessage = () => {
|
|
32
|
+
return (
|
|
33
|
+
<MessagePrimitive.Root>
|
|
34
|
+
<MessagePrimitive.Quote>
|
|
35
|
+
{(quote) => <QuoteBlock {...quote} />}
|
|
36
|
+
</MessagePrimitive.Quote>
|
|
37
|
+
<MessagePrimitive.Parts />
|
|
38
|
+
</MessagePrimitive.Root>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
</Step>
|
|
44
|
+
<Step>
|
|
45
|
+
|
|
46
|
+
### Add the Floating Selection Toolbar
|
|
47
|
+
|
|
48
|
+
Render `SelectionToolbar` inside `ThreadPrimitive.Root`. It portals to the document body and appears near the user's text selection.
|
|
49
|
+
|
|
50
|
+
```tsx title="components/assistant-ui/thread.tsx" {1,11}
|
|
51
|
+
import { SelectionToolbar } from "@/components/assistant-ui/quote";
|
|
52
|
+
|
|
53
|
+
const Thread = () => {
|
|
54
|
+
return (
|
|
55
|
+
<ThreadPrimitive.Root>
|
|
56
|
+
<ThreadPrimitive.Viewport>
|
|
57
|
+
<ThreadPrimitive.Messages>
|
|
58
|
+
{({ message }) => { ... }}
|
|
59
|
+
</ThreadPrimitive.Messages>
|
|
60
|
+
...
|
|
61
|
+
</ThreadPrimitive.Viewport>
|
|
62
|
+
|
|
63
|
+
<SelectionToolbar />
|
|
64
|
+
</ThreadPrimitive.Root>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
</Step>
|
|
70
|
+
<Step>
|
|
71
|
+
|
|
72
|
+
### Show Quote Preview in Composer
|
|
73
|
+
|
|
74
|
+
Add `ComposerQuotePreview` inside your composer. It only renders when a quote is set.
|
|
75
|
+
|
|
76
|
+
```tsx title="components/assistant-ui/thread.tsx" {1,6}
|
|
77
|
+
import { ComposerQuotePreview } from "@/components/assistant-ui/quote";
|
|
78
|
+
|
|
79
|
+
const Composer = () => {
|
|
80
|
+
return (
|
|
81
|
+
<ComposerPrimitive.Root>
|
|
82
|
+
<ComposerQuotePreview />
|
|
83
|
+
<ComposerPrimitive.Input placeholder="Send a message..." />
|
|
84
|
+
<ComposerPrimitive.Send />
|
|
85
|
+
</ComposerPrimitive.Root>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
</Step>
|
|
91
|
+
<Step>
|
|
92
|
+
|
|
93
|
+
### Forward Quote Context to the LLM
|
|
94
|
+
|
|
95
|
+
Quote data is stored in message metadata, **not** in message content. Use `injectQuoteContext` in your route handler so the LLM sees the quoted text:
|
|
96
|
+
|
|
97
|
+
```typescript title="app/api/chat/route.ts" {2,9}
|
|
98
|
+
import { convertToModelMessages, streamText } from "ai";
|
|
99
|
+
import { injectQuoteContext } from "@assistant-ui/react-ai-sdk";
|
|
100
|
+
|
|
101
|
+
export async function POST(req: Request) {
|
|
102
|
+
const { messages } = await req.json();
|
|
103
|
+
|
|
104
|
+
const result = streamText({
|
|
105
|
+
model: myModel,
|
|
106
|
+
messages: await convertToModelMessages(injectQuoteContext(messages)),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return result.toUIMessageStreamResponse();
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`injectQuoteContext` prepends the quoted text as a markdown `>` blockquote to the message parts so the LLM receives the context the user is referring to.
|
|
114
|
+
|
|
115
|
+
<Callout>
|
|
116
|
+
For alternative backend approaches (Claude SDK citation source, OpenAI message context), see the [Quoting guide](/docs/guides/quoting#backend-handling).
|
|
117
|
+
</Callout>
|
|
118
|
+
|
|
119
|
+
</Step>
|
|
120
|
+
</Steps>
|
|
121
|
+
|
|
122
|
+
## Customization
|
|
123
|
+
|
|
124
|
+
All three components expose sub-components for full control over styling:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
// Custom QuoteBlock
|
|
128
|
+
<QuoteBlock.Root className="my-custom-class">
|
|
129
|
+
<QuoteBlock.Icon />
|
|
130
|
+
<QuoteBlock.Text>{text}</QuoteBlock.Text>
|
|
131
|
+
</QuoteBlock.Root>
|
|
132
|
+
|
|
133
|
+
// Custom SelectionToolbar
|
|
134
|
+
<SelectionToolbar.Root>
|
|
135
|
+
<SelectionToolbar.Quote>Reply with quote</SelectionToolbar.Quote>
|
|
136
|
+
</SelectionToolbar.Root>
|
|
137
|
+
|
|
138
|
+
// Custom ComposerQuotePreview
|
|
139
|
+
<ComposerQuotePreview.Root>
|
|
140
|
+
<ComposerQuotePreview.Icon />
|
|
141
|
+
<ComposerQuotePreview.Text />
|
|
142
|
+
<ComposerQuotePreview.Dismiss />
|
|
143
|
+
</ComposerQuotePreview.Root>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## API Reference
|
|
147
|
+
|
|
148
|
+
### `QuoteBlock`
|
|
149
|
+
|
|
150
|
+
Renders quoted text in user messages. Pass to `MessagePrimitive.Parts` as `components.Quote`.
|
|
151
|
+
|
|
152
|
+
| Prop | Type | Description |
|
|
153
|
+
|------|------|-------------|
|
|
154
|
+
| `text` | `string` | The quoted text |
|
|
155
|
+
| `messageId` | `string` | ID of the source message |
|
|
156
|
+
|
|
157
|
+
**Sub-components:** `QuoteBlock.Root`, `QuoteBlock.Icon`, `QuoteBlock.Text`
|
|
158
|
+
|
|
159
|
+
### `SelectionToolbar`
|
|
160
|
+
|
|
161
|
+
Floating toolbar that appears when text is selected within a message. Renders as a portal positioned above the selection.
|
|
162
|
+
|
|
163
|
+
| Prop | Type | Description |
|
|
164
|
+
|------|------|-------------|
|
|
165
|
+
| `className` | `string` | Additional class names |
|
|
166
|
+
|
|
167
|
+
**Sub-components:** `SelectionToolbar.Root`, `SelectionToolbar.Quote`
|
|
168
|
+
|
|
169
|
+
### `ComposerQuotePreview`
|
|
170
|
+
|
|
171
|
+
Quote preview inside the composer. Only renders when a quote is set.
|
|
172
|
+
|
|
173
|
+
| Prop | Type | Description |
|
|
174
|
+
|------|------|-------------|
|
|
175
|
+
| `className` | `string` | Additional class names |
|
|
176
|
+
|
|
177
|
+
**Sub-components:** `ComposerQuotePreview.Root`, `ComposerQuotePreview.Icon`, `ComposerQuotePreview.Text`, `ComposerQuotePreview.Dismiss`
|
|
178
|
+
|
|
179
|
+
### `injectQuoteContext`
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { injectQuoteContext } from "@assistant-ui/react-ai-sdk";
|
|
183
|
+
|
|
184
|
+
injectQuoteContext(messages: UIMessage[]): UIMessage[]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Extracts `metadata.custom.quote` from each message and prepends the quoted text as a `> blockquote` text part. Use before `convertToModelMessages` in your route handler. For alternative backend approaches, see the [Quoting guide](/docs/guides/quoting#backend-handling).
|
|
188
|
+
|
|
189
|
+
### `useMessageQuote`
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { useMessageQuote } from "@assistant-ui/react";
|
|
193
|
+
|
|
194
|
+
const quote: QuoteInfo | undefined = useMessageQuote();
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Returns the quote attached to the current message, or `undefined`. Useful for building custom quote displays without `QuoteBlock`. For a usage example, see the [Quoting guide](/docs/guides/quoting#reading-quote-data).
|
|
198
|
+
|
|
199
|
+
### `ComposerRuntime.setQuote`
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
setQuote(quote: QuoteInfo | undefined): void
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Set or clear the quote on the composer programmatically. The quote is automatically cleared when the message is sent. For a usage example, see the [Quoting guide](/docs/guides/quoting#programmatic-api).
|
|
206
|
+
|
|
207
|
+
## Related
|
|
208
|
+
|
|
209
|
+
- [Quoting guide](/docs/guides/quoting): Backend handling, programmatic API, data shape, and design notes
|
|
210
|
+
- [Thread](/docs/ui/thread): Main chat container
|
|
@@ -27,18 +27,18 @@ Pass the `Reasoning` and `ReasoningGroup` components to the `MessagePrimitive.Pa
|
|
|
27
27
|
|
|
28
28
|
```tsx title="/app/components/assistant-ui/thread.tsx" {2,10-11}
|
|
29
29
|
import { MessagePrimitive } from "@assistant-ui/react";
|
|
30
|
-
import { Reasoning
|
|
30
|
+
import { Reasoning } from "@/components/assistant-ui/reasoning";
|
|
31
31
|
|
|
32
32
|
const AssistantMessage: FC = () => {
|
|
33
33
|
return (
|
|
34
34
|
<MessagePrimitive.Root className="...">
|
|
35
35
|
<div className="...">
|
|
36
|
-
<MessagePrimitive.Parts
|
|
37
|
-
|
|
38
|
-
Reasoning
|
|
39
|
-
|
|
36
|
+
<MessagePrimitive.Parts>
|
|
37
|
+
{({ part }) => {
|
|
38
|
+
if (part.type === "reasoning") return <Reasoning {...part} />;
|
|
39
|
+
return null;
|
|
40
40
|
}}
|
|
41
|
-
|
|
41
|
+
</MessagePrimitive.Parts>
|
|
42
42
|
</div>
|
|
43
43
|
<AssistantActionBar />
|
|
44
44
|
<BranchPicker className="..." />
|
|
@@ -67,14 +67,15 @@ Use the `variant` prop on `Reasoning.Root` to change the visual style:
|
|
|
67
67
|
|
|
68
68
|
```tsx
|
|
69
69
|
<Reasoning.Root variant="outline">...</Reasoning.Root>
|
|
70
|
+
<Reasoning.Root variant="ghost">...</Reasoning.Root>
|
|
70
71
|
<Reasoning.Root variant="muted">...</Reasoning.Root>
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
| Variant | Description
|
|
74
|
-
| --------- |
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
74
|
+
| Variant | Description |
|
|
75
|
+
| --------- | -------------------------------------------- |
|
|
76
|
+
| `outline` | Rounded border (default) |
|
|
77
|
+
| `ghost` | No additional styling |
|
|
78
|
+
| `muted` | Muted background |
|
|
78
79
|
|
|
79
80
|
## ReasoningGroup
|
|
80
81
|
|
|
@@ -29,11 +29,12 @@ import { Sources } from "@/components/assistant-ui/sources";
|
|
|
29
29
|
const AssistantMessage: FC = () => {
|
|
30
30
|
return (
|
|
31
31
|
<MessagePrimitive.Root className="...">
|
|
32
|
-
<MessagePrimitive.Parts
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
<MessagePrimitive.Parts>
|
|
33
|
+
{({ part }) => {
|
|
34
|
+
if (part.type === "source") return <Sources {...part} />;
|
|
35
|
+
return null;
|
|
35
36
|
}}
|
|
36
|
-
|
|
37
|
+
</MessagePrimitive.Parts>
|
|
37
38
|
</MessagePrimitive.Root>
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -44,12 +45,17 @@ const AssistantMessage: FC = () => {
|
|
|
44
45
|
|
|
45
46
|
## Variants
|
|
46
47
|
|
|
47
|
-
Use the `variant` prop to change the visual style.
|
|
48
|
+
Use the `variant` prop to change the visual style. The default is `outline`.
|
|
48
49
|
|
|
49
50
|
```tsx
|
|
50
|
-
<Source variant="outline" />
|
|
51
|
-
<Source variant="ghost" />
|
|
52
|
-
<Source variant="muted" />
|
|
51
|
+
<Source variant="outline" /> // Border (default)
|
|
52
|
+
<Source variant="ghost" /> // No background
|
|
53
|
+
<Source variant="muted" /> // Solid muted background
|
|
54
|
+
<Source variant="secondary" /> // Secondary background
|
|
55
|
+
<Source variant="info" /> // Blue
|
|
56
|
+
<Source variant="warning" /> // Amber
|
|
57
|
+
<Source variant="success" /> // Emerald
|
|
58
|
+
<Source variant="destructive" /> // Red
|
|
53
59
|
```
|
|
54
60
|
|
|
55
61
|
## Sizes
|
|
@@ -64,25 +70,90 @@ Use the `size` prop to change the size.
|
|
|
64
70
|
|
|
65
71
|
## API Reference
|
|
66
72
|
|
|
67
|
-
###
|
|
73
|
+
### `Sources`
|
|
68
74
|
|
|
69
|
-
The
|
|
75
|
+
The default export used as a `SourceMessagePartComponent`. Renders a single source part when `sourceType === "url"`. Also exposes compound sub-components for custom layouts.
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Default | Description |
|
|
78
|
+
|------|------|---------|-------------|
|
|
79
|
+
| `url` | `string` | — | The URL of the source (provided by the runtime) |
|
|
80
|
+
| `title` | `string \| undefined` | — | Display title; falls back to the domain if omitted |
|
|
81
|
+
| `sourceType` | `string` | — | Must be `"url"` to render; other types are ignored |
|
|
82
|
+
|
|
83
|
+
#### Compound sub-components
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { Sources } from "@/components/assistant-ui/sources";
|
|
87
|
+
|
|
88
|
+
<Sources.Root href="https://example.com">
|
|
89
|
+
<Sources.Icon url="https://example.com" />
|
|
90
|
+
<Sources.Title>Example</Sources.Title>
|
|
91
|
+
</Sources.Root>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
| Sub-component | Equivalent named export | Description |
|
|
95
|
+
|---------------|------------------------|-------------|
|
|
96
|
+
| `Sources.Root` | `Source` | Root anchor element |
|
|
97
|
+
| `Sources.Icon` | `SourceIcon` | Favicon with domain initial fallback |
|
|
98
|
+
| `Sources.Title` | `SourceTitle` | Truncated title text |
|
|
99
|
+
|
|
100
|
+
### `Source`
|
|
101
|
+
|
|
102
|
+
Root container rendered as an `<a>` tag. Accepts all `<a>` props plus `variant` and `size`.
|
|
103
|
+
|
|
104
|
+
| Prop | Type | Default | Description |
|
|
105
|
+
|------|------|---------|-------------|
|
|
106
|
+
| `href` | `string` | — | URL the link points to |
|
|
107
|
+
| `variant` | `"outline" \| "ghost" \| "muted" \| "secondary" \| "info" \| "warning" \| "success" \| "destructive"` | `"outline"` | Visual style |
|
|
108
|
+
| `size` | `"sm" \| "default" \| "lg"` | `"default"` | Size of the badge |
|
|
109
|
+
| `target` | `string` | `"_blank"` | Link target |
|
|
110
|
+
| `rel` | `string` | `"noopener noreferrer"` | Link rel attribute |
|
|
111
|
+
| `asChild` | `boolean` | `false` | Render as a child element using Radix Slot |
|
|
112
|
+
| `className` | `string` | — | Additional CSS classes |
|
|
113
|
+
|
|
114
|
+
### `SourceIcon`
|
|
115
|
+
|
|
116
|
+
Displays the favicon for the given URL. Falls back to the domain initial inside a muted box when the favicon fails to load.
|
|
117
|
+
|
|
118
|
+
| Prop | Type | Default | Description |
|
|
119
|
+
|------|------|---------|-------------|
|
|
120
|
+
| `url` | `string` | — | URL used to derive the favicon and fallback initial |
|
|
121
|
+
| `className` | `string` | — | Additional CSS classes applied to the `<img>` or fallback `<span>` |
|
|
122
|
+
|
|
123
|
+
### `SourceTitle`
|
|
124
|
+
|
|
125
|
+
Truncated title text rendered as a `<span>`.
|
|
126
|
+
|
|
127
|
+
| Prop | Type | Default | Description |
|
|
128
|
+
|------|------|---------|-------------|
|
|
129
|
+
| `children` | `ReactNode` | — | Title content to display |
|
|
130
|
+
| `className` | `string` | — | Additional CSS classes (default max-width is `37.5rem`) |
|
|
131
|
+
|
|
132
|
+
### `sourceVariants`
|
|
133
|
+
|
|
134
|
+
The underlying CVA variant function used to generate badge class names. Use this when building custom source-like components that need to match the built-in styling.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { sourceVariants } from "@/components/assistant-ui/sources";
|
|
138
|
+
|
|
139
|
+
<span className={sourceVariants({ variant: "info", size: "sm" })}>
|
|
140
|
+
Custom badge
|
|
141
|
+
</span>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Composable API
|
|
145
|
+
|
|
146
|
+
Use the named exports to build fully custom source layouts:
|
|
70
147
|
|
|
71
148
|
```tsx
|
|
72
149
|
import { Source, SourceIcon, SourceTitle } from "@/components/assistant-ui/sources";
|
|
73
150
|
|
|
74
|
-
<Source href="https://example.com" className="gap-2">
|
|
151
|
+
<Source href="https://example.com" variant="muted" className="gap-2">
|
|
75
152
|
<SourceIcon url="https://example.com" className="size-4" />
|
|
76
153
|
<SourceTitle className="max-w-none font-medium">Example</SourceTitle>
|
|
77
154
|
</Source>
|
|
78
155
|
```
|
|
79
156
|
|
|
80
|
-
| Component | Description |
|
|
81
|
-
|-----------|-------------|
|
|
82
|
-
| `Source` | Root container, renders as `<a>` |
|
|
83
|
-
| `SourceIcon` | Favicon with domain initial fallback |
|
|
84
|
-
| `SourceTitle` | Truncated title text |
|
|
85
|
-
|
|
86
157
|
## Related Components
|
|
87
158
|
|
|
88
159
|
- [PartGrouping](/docs/ui/part-grouping) - Group sources by parentId
|
|
@@ -31,7 +31,9 @@ For additional features, install the optional plugins:
|
|
|
31
31
|
import { StreamdownTextPrimitive } from "@assistant-ui/react-streamdown";
|
|
32
32
|
|
|
33
33
|
// Inside a MessagePrimitive.Parts component
|
|
34
|
-
<MessagePrimitive.Parts
|
|
34
|
+
<MessagePrimitive.Parts>
|
|
35
|
+
{({ part }) => part.type === "text" ? <StreamdownText {...part} /> : null}
|
|
36
|
+
</MessagePrimitive.Parts>
|
|
35
37
|
|
|
36
38
|
// Where StreamdownText is:
|
|
37
39
|
const StreamdownText = () => <StreamdownTextPrimitive />;
|
|
@@ -190,12 +192,17 @@ Configure how incomplete markdown syntax is handled during streaming:
|
|
|
190
192
|
```tsx
|
|
191
193
|
<StreamdownTextPrimitive
|
|
192
194
|
remend={{
|
|
193
|
-
links: true,
|
|
194
|
-
images: true,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
links: true, // Complete incomplete links
|
|
196
|
+
images: true, // Handle incomplete images
|
|
197
|
+
linkMode: "protocol", // How to handle incomplete links: 'protocol' or 'text-only'
|
|
198
|
+
bold: true, // Complete **text → **text**
|
|
199
|
+
italic: true, // Complete *text → *text*
|
|
200
|
+
boldItalic: true, // Complete ***text → ***text***
|
|
201
|
+
inlineCode: true, // Complete `code → `code`
|
|
202
|
+
strikethrough: true, // Complete ~~text → ~~text~~
|
|
203
|
+
katex: true, // Complete $$equation → $$equation$$
|
|
204
|
+
setextHeadings: true, // Handle incomplete setext headings
|
|
205
|
+
handlers: [], // Custom handlers for incomplete markdown completion
|
|
199
206
|
}}
|
|
200
207
|
/>
|
|
201
208
|
```
|
|
@@ -229,6 +236,8 @@ Restrict allowed URLs for links and images. This overrides streamdown's default
|
|
|
229
236
|
allowedProtocols: ["https", "mailto"],
|
|
230
237
|
// Disable base64 data images
|
|
231
238
|
allowDataImages: false,
|
|
239
|
+
// Default origin for relative URLs
|
|
240
|
+
defaultOrigin: "https://example.com",
|
|
232
241
|
// CSS class for blocked elements
|
|
233
242
|
blockedLinkClass: "blocked-link",
|
|
234
243
|
blockedImageClass: "blocked-image",
|
|
@@ -89,19 +89,17 @@ import { ThreadListPrimitive, ThreadListItemPrimitive } from "@assistant-ui/reac
|
|
|
89
89
|
|
|
90
90
|
<ThreadListPrimitive.Root>
|
|
91
91
|
<ThreadListPrimitive.New />
|
|
92
|
-
<ThreadListPrimitive.Items
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<ThreadListItemPrimitive.
|
|
96
|
-
<ThreadListItemPrimitive.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}}
|
|
104
|
-
/>
|
|
92
|
+
<ThreadListPrimitive.Items>
|
|
93
|
+
{() => (
|
|
94
|
+
<ThreadListItemPrimitive.Root>
|
|
95
|
+
<ThreadListItemPrimitive.Trigger>
|
|
96
|
+
<ThreadListItemPrimitive.Title />
|
|
97
|
+
</ThreadListItemPrimitive.Trigger>
|
|
98
|
+
<ThreadListItemPrimitive.Archive />
|
|
99
|
+
<ThreadListItemPrimitive.Delete />
|
|
100
|
+
</ThreadListItemPrimitive.Root>
|
|
101
|
+
)}
|
|
102
|
+
</ThreadListPrimitive.Items>
|
|
105
103
|
</ThreadListPrimitive.Root>
|
|
106
104
|
```
|
|
107
105
|
|
|
@@ -16,27 +16,27 @@ attachments, and conditional UI states. Fully customizable and composable.
|
|
|
16
16
|
The `Thread` component is built with the following primitives:
|
|
17
17
|
|
|
18
18
|
```tsx
|
|
19
|
-
import { ThreadPrimitive,
|
|
19
|
+
import { ThreadPrimitive, AuiIf } from "@assistant-ui/react";
|
|
20
20
|
|
|
21
21
|
<ThreadPrimitive.Root>
|
|
22
22
|
<ThreadPrimitive.Viewport>
|
|
23
|
-
<AuiIf condition={(s) => s.thread.isEmpty}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
<AuiIf condition={(s) => s.thread.isEmpty}>
|
|
24
|
+
<ThreadWelcome />
|
|
25
|
+
{/* ThreadWelcome includes ThreadPrimitive.Suggestions */}
|
|
26
|
+
</AuiIf>
|
|
27
|
+
|
|
28
|
+
<ThreadPrimitive.Messages>
|
|
29
|
+
{({ message }) => {
|
|
30
|
+
if (message.role === "user") return <UserMessage />;
|
|
31
|
+
return <AssistantMessage />;
|
|
29
32
|
}}
|
|
30
|
-
|
|
31
|
-
<ThreadPrimitive.ScrollToBottom />
|
|
32
|
-
</ThreadPrimitive.Viewport>
|
|
33
|
-
<ThreadPrimitive.Suggestions />
|
|
34
|
-
<AuiIf condition={...} />
|
|
33
|
+
</ThreadPrimitive.Messages>
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
<ThreadPrimitive.ViewportFooter>
|
|
36
|
+
<ThreadPrimitive.ScrollToBottom />
|
|
37
|
+
<Composer />
|
|
38
|
+
</ThreadPrimitive.ViewportFooter>
|
|
39
|
+
</ThreadPrimitive.Viewport>
|
|
40
40
|
</ThreadPrimitive.Root>
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -118,11 +118,9 @@ const aui = useAui({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
// Display suggestions in your thread component
|
|
121
|
-
<ThreadPrimitive.Suggestions
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}}
|
|
125
|
-
/>
|
|
121
|
+
<ThreadPrimitive.Suggestions>
|
|
122
|
+
{() => <SuggestionItem />}
|
|
123
|
+
</ThreadPrimitive.Suggestions>
|
|
126
124
|
|
|
127
125
|
// Custom suggestion item
|
|
128
126
|
const SuggestionItem = () => (
|
|
@@ -196,13 +194,12 @@ This primitive renders a `<div>` element unless `asChild` is set.
|
|
|
196
194
|
Renders all messages in the thread. This primitive renders a separate component for each message.
|
|
197
195
|
|
|
198
196
|
```tsx
|
|
199
|
-
<ThreadPrimitive.Messages
|
|
200
|
-
|
|
201
|
-
UserMessage
|
|
202
|
-
|
|
203
|
-
AssistantMessage: AssistantMessage,
|
|
197
|
+
<ThreadPrimitive.Messages>
|
|
198
|
+
{({ message }) => {
|
|
199
|
+
if (message.role === "user") return <UserMessage />;
|
|
200
|
+
return <AssistantMessage />;
|
|
204
201
|
}}
|
|
205
|
-
|
|
202
|
+
</ThreadPrimitive.Messages>
|
|
206
203
|
```
|
|
207
204
|
|
|
208
205
|
<ParametersTable
|
|
@@ -325,11 +322,9 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
325
322
|
Renders all configured suggestions. Configure suggestions using the `Suggestions()` API in your runtime provider.
|
|
326
323
|
|
|
327
324
|
```tsx
|
|
328
|
-
<ThreadPrimitive.Suggestions
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}}
|
|
332
|
-
/>
|
|
325
|
+
<ThreadPrimitive.Suggestions>
|
|
326
|
+
{() => <CustomSuggestionComponent />}
|
|
327
|
+
</ThreadPrimitive.Suggestions>
|
|
333
328
|
```
|
|
334
329
|
|
|
335
330
|
<ParametersTable
|
|
@@ -388,4 +383,4 @@ The condition function receives an `AssistantState` object with access to `threa
|
|
|
388
383
|
|
|
389
384
|
- [ThreadList](/docs/ui/thread-list) - List of threads, with or without sidebar
|
|
390
385
|
- [Quoting guide](/docs/guides/quoting) - Quote selected text from messages
|
|
391
|
-
- [SelectionToolbarPrimitive](/docs/reference/primitives/selection-toolbar) - Floating toolbar API reference
|
|
386
|
+
- [SelectionToolbarPrimitive](/docs/api-reference/primitives/selection-toolbar) - Floating toolbar API reference
|
|
@@ -36,13 +36,12 @@ import { ToolFallback } from "@/components/assistant-ui/tool-fallback";
|
|
|
36
36
|
const AssistantMessage = () => {
|
|
37
37
|
return (
|
|
38
38
|
<MessagePrimitive.Root>
|
|
39
|
-
<MessagePrimitive.Parts
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
39
|
+
<MessagePrimitive.Parts>
|
|
40
|
+
{({ part }) => {
|
|
41
|
+
if (part.type === "tool-call") return <ToolFallback {...part} />;
|
|
42
|
+
return null;
|
|
44
43
|
}}
|
|
45
|
-
|
|
44
|
+
</MessagePrimitive.Parts>
|
|
46
45
|
</MessagePrimitive.Root>
|
|
47
46
|
);
|
|
48
47
|
};
|
|
@@ -36,11 +36,12 @@ import { ToolGroup } from "@/components/assistant-ui/tool-group";
|
|
|
36
36
|
const AssistantMessage = () => {
|
|
37
37
|
return (
|
|
38
38
|
<MessagePrimitive.Root>
|
|
39
|
-
<MessagePrimitive.Parts
|
|
40
|
-
|
|
41
|
-
ToolGroup
|
|
39
|
+
<MessagePrimitive.Parts>
|
|
40
|
+
{({ part }) => {
|
|
41
|
+
if (part.type === "tool-call") return <ToolGroup {...part} />;
|
|
42
|
+
return null;
|
|
42
43
|
}}
|
|
43
|
-
|
|
44
|
+
</MessagePrimitive.Parts>
|
|
44
45
|
</MessagePrimitive.Root>
|
|
45
46
|
);
|
|
46
47
|
};
|
|
@@ -60,8 +61,8 @@ Use the `variant` prop on `ToolGroup.Root` to change the visual style:
|
|
|
60
61
|
|
|
61
62
|
| Variant | Description |
|
|
62
63
|
| --------- | ---------------------------------- |
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
64
|
+
| `outline` | Rounded border (default) |
|
|
65
|
+
| `ghost` | No additional styling |
|
|
65
66
|
| `muted` | Muted background with border |
|
|
66
67
|
|
|
67
68
|
## Examples
|
|
@@ -137,8 +138,8 @@ import {
|
|
|
137
138
|
parameters={[
|
|
138
139
|
{
|
|
139
140
|
name: "variant",
|
|
140
|
-
type: '"
|
|
141
|
-
default: '"
|
|
141
|
+
type: '"outline" | "ghost" | "muted"',
|
|
142
|
+
default: '"outline"',
|
|
142
143
|
description: "Visual variant of the tool group container.",
|
|
143
144
|
},
|
|
144
145
|
{
|