@assistant-ui/mcp-docs-server 0.1.22 → 0.1.23
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 +801 -0
- package/.docs/organized/code-examples/with-ag-ui.md +38 -26
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +38 -28
- package/.docs/organized/code-examples/with-artifacts.md +467 -0
- package/.docs/organized/code-examples/with-assistant-transport.md +31 -24
- package/.docs/organized/code-examples/with-chain-of-thought.md +41 -32
- package/.docs/organized/code-examples/with-cloud-standalone.md +675 -0
- package/.docs/organized/code-examples/with-cloud.md +34 -27
- package/.docs/organized/code-examples/with-custom-thread-list.md +34 -27
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +41 -30
- package/.docs/organized/code-examples/with-expo.md +2031 -0
- package/.docs/organized/code-examples/with-external-store.md +32 -25
- package/.docs/organized/code-examples/with-ffmpeg.md +31 -27
- package/.docs/organized/code-examples/with-langgraph.md +96 -38
- package/.docs/organized/code-examples/with-parent-id-grouping.md +32 -25
- package/.docs/organized/code-examples/with-react-hook-form.md +63 -58
- package/.docs/organized/code-examples/with-react-router.md +38 -30
- package/.docs/organized/code-examples/with-store.md +16 -24
- package/.docs/organized/code-examples/with-tanstack.md +36 -26
- package/.docs/organized/code-examples/with-tap-runtime.md +10 -24
- package/.docs/raw/docs/(docs)/cli.mdx +13 -6
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +26 -3
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +53 -52
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +0 -2
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +169 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +327 -0
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -1
- package/.docs/raw/docs/(docs)/index.mdx +12 -2
- package/.docs/raw/docs/(docs)/installation.mdx +8 -2
- package/.docs/raw/docs/(docs)/llm.mdx +9 -7
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +2 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +27 -27
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +60 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +78 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +32 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +61 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +1 -1
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +1 -6
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +2 -2
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +1 -6
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +1 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +17 -17
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +205 -0
- package/.docs/raw/docs/cloud/ai-sdk.mdx +292 -0
- package/.docs/raw/docs/cloud/authorization.mdx +178 -79
- package/.docs/raw/docs/cloud/{persistence/langgraph.mdx → langgraph.mdx} +2 -2
- package/.docs/raw/docs/cloud/overview.mdx +29 -39
- package/.docs/raw/docs/react-native/adapters.mdx +118 -0
- package/.docs/raw/docs/react-native/custom-backend.mdx +210 -0
- package/.docs/raw/docs/react-native/hooks.mdx +364 -0
- package/.docs/raw/docs/react-native/index.mdx +332 -0
- package/.docs/raw/docs/react-native/primitives.mdx +653 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +7 -15
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +103 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +25 -2
- package/.docs/raw/docs/runtimes/data-stream.mdx +1 -3
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +113 -9
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +1 -4
- package/.docs/raw/docs/ui/attachment.mdx +4 -2
- package/.docs/raw/docs/ui/message-timing.mdx +92 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +1 -1
- package/.docs/raw/docs/ui/reasoning.mdx +4 -4
- package/.docs/raw/docs/ui/scrollbar.mdx +2 -2
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +55 -50
- package/.docs/raw/docs/ui/thread.mdx +16 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/tools/tests/integration.test.ts +2 -2
- package/src/tools/tests/json-parsing.test.ts +1 -1
- package/src/tools/tests/mcp-protocol.test.ts +1 -3
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -108
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Primitives
|
|
3
|
+
description: Composable React Native components for building chat UIs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Primitives are thin wrappers around React Native components (`View`, `TextInput`, `FlatList`, `Pressable`) that integrate with the assistant-ui runtime. They accept all standard React Native props and add runtime-aware behavior.
|
|
7
|
+
|
|
8
|
+
Many primitives share their core logic with `@assistant-ui/react` via `@assistant-ui/core/react` — only the UI layer (View/Pressable/Text vs DOM elements) differs.
|
|
9
|
+
|
|
10
|
+
## Thread
|
|
11
|
+
|
|
12
|
+
### ThreadRoot
|
|
13
|
+
|
|
14
|
+
Container `View` for the thread area.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { ThreadRoot } from "@assistant-ui/react-native";
|
|
18
|
+
|
|
19
|
+
<ThreadRoot style={{ flex: 1 }}>
|
|
20
|
+
{children}
|
|
21
|
+
</ThreadRoot>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Description |
|
|
25
|
+
|------|------|-------------|
|
|
26
|
+
| `...rest` | `ViewProps` | Standard React Native View props |
|
|
27
|
+
|
|
28
|
+
### ThreadMessages
|
|
29
|
+
|
|
30
|
+
`FlatList`-based message list with automatic runtime integration. Each message is wrapped in a scoped context so that `useAuiState((s) => s.message)` works inside `renderMessage`.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { ThreadMessages } from "@assistant-ui/react-native";
|
|
34
|
+
|
|
35
|
+
<ThreadMessages
|
|
36
|
+
renderMessage={({ message }) => <MessageBubble message={message} />}
|
|
37
|
+
/>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Description |
|
|
41
|
+
|------|------|-------------|
|
|
42
|
+
| `renderMessage` | `(info: { message: ThreadMessage; index: number }) => ReactElement` | Message renderer |
|
|
43
|
+
| `...rest` | `FlatListProps` | Standard FlatList props (except `data`, `renderItem`) |
|
|
44
|
+
|
|
45
|
+
### ThreadEmpty
|
|
46
|
+
|
|
47
|
+
Renders children only when the thread has no messages.
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { ThreadEmpty } from "@assistant-ui/react-native";
|
|
51
|
+
|
|
52
|
+
<ThreadEmpty>
|
|
53
|
+
<Text>Send a message to get started</Text>
|
|
54
|
+
</ThreadEmpty>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### ThreadIf
|
|
58
|
+
|
|
59
|
+
Conditional rendering based on thread state.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { ThreadIf } from "@assistant-ui/react-native";
|
|
63
|
+
|
|
64
|
+
<ThreadIf empty>
|
|
65
|
+
<Text>No messages yet</Text>
|
|
66
|
+
</ThreadIf>
|
|
67
|
+
|
|
68
|
+
<ThreadIf running>
|
|
69
|
+
<ActivityIndicator />
|
|
70
|
+
</ThreadIf>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Prop | Type | Description |
|
|
74
|
+
|------|------|-------------|
|
|
75
|
+
| `empty` | `boolean` | Render when thread is empty |
|
|
76
|
+
| `running` | `boolean` | Render when thread is running |
|
|
77
|
+
|
|
78
|
+
## Composer
|
|
79
|
+
|
|
80
|
+
### ComposerRoot
|
|
81
|
+
|
|
82
|
+
Container `View` for the composer area.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { ComposerRoot } from "@assistant-ui/react-native";
|
|
86
|
+
|
|
87
|
+
<ComposerRoot style={styles.composerContainer}>
|
|
88
|
+
{children}
|
|
89
|
+
</ComposerRoot>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### ComposerInput
|
|
93
|
+
|
|
94
|
+
`TextInput` wired to the composer runtime. Value and `onChangeText` are managed automatically.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { ComposerInput } from "@assistant-ui/react-native";
|
|
98
|
+
|
|
99
|
+
<ComposerInput
|
|
100
|
+
placeholder="Message..."
|
|
101
|
+
multiline
|
|
102
|
+
style={styles.input}
|
|
103
|
+
/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| Prop | Type | Description |
|
|
107
|
+
|------|------|-------------|
|
|
108
|
+
| `...rest` | `TextInputProps` | Standard TextInput props (except `value`, `onChangeText`) |
|
|
109
|
+
|
|
110
|
+
### ComposerSend
|
|
111
|
+
|
|
112
|
+
`Pressable` that sends the current message. Automatically disabled when the composer is empty.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { ComposerSend } from "@assistant-ui/react-native";
|
|
116
|
+
|
|
117
|
+
<ComposerSend style={styles.sendButton}>
|
|
118
|
+
<Text>Send</Text>
|
|
119
|
+
</ComposerSend>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### ComposerCancel
|
|
123
|
+
|
|
124
|
+
`Pressable` that cancels the current run. Automatically disabled when no run is active.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { ComposerCancel } from "@assistant-ui/react-native";
|
|
128
|
+
|
|
129
|
+
<ComposerCancel style={styles.cancelButton}>
|
|
130
|
+
<Text>Stop</Text>
|
|
131
|
+
</ComposerCancel>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### ComposerAttachments
|
|
135
|
+
|
|
136
|
+
Renders composer attachments using the provided component configuration.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { ComposerAttachments } from "@assistant-ui/react-native";
|
|
140
|
+
|
|
141
|
+
<ComposerAttachments
|
|
142
|
+
components={{
|
|
143
|
+
Image: MyImageAttachment,
|
|
144
|
+
Document: MyDocumentAttachment,
|
|
145
|
+
Attachment: MyFallbackAttachment, // fallback for all types
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
| Prop | Type | Description |
|
|
151
|
+
|------|------|-------------|
|
|
152
|
+
| `components` | `{ Image?, Document?, File?, Attachment? }` | Component renderers by attachment type |
|
|
153
|
+
|
|
154
|
+
## Message
|
|
155
|
+
|
|
156
|
+
### MessageRoot
|
|
157
|
+
|
|
158
|
+
Container `View` for a single message.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { MessageRoot } from "@assistant-ui/react-native";
|
|
162
|
+
|
|
163
|
+
<MessageRoot style={styles.messageBubble}>
|
|
164
|
+
{children}
|
|
165
|
+
</MessageRoot>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### MessageContent
|
|
169
|
+
|
|
170
|
+
Renders message content parts. Tool call and data parts automatically render registered tool UIs (via `useAssistantTool` / `useAssistantDataUI`), falling back to render props if provided.
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { MessageContent } from "@assistant-ui/react-native";
|
|
174
|
+
|
|
175
|
+
<MessageContent
|
|
176
|
+
renderText={({ part }) => <Text>{part.text}</Text>}
|
|
177
|
+
renderImage={({ part }) => <Image source={{ uri: part.image }} />}
|
|
178
|
+
/>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Description |
|
|
182
|
+
|------|------|-------------|
|
|
183
|
+
| `renderText` | `(props: { part; index }) => ReactElement` | Text part renderer |
|
|
184
|
+
| `renderToolCall` | `(props: { part; index }) => ReactElement` | Tool call fallback (used when no tool UI is registered) |
|
|
185
|
+
| `renderImage` | `(props: { part; index }) => ReactElement` | Image part renderer |
|
|
186
|
+
| `renderReasoning` | `(props: { part; index }) => ReactElement` | Reasoning part renderer |
|
|
187
|
+
| `renderSource` | `(props: { part; index }) => ReactElement` | Source part renderer |
|
|
188
|
+
| `renderFile` | `(props: { part; index }) => ReactElement` | File part renderer |
|
|
189
|
+
| `renderData` | `(props: { part; index }) => ReactElement` | Data part fallback (used when no data UI is registered) |
|
|
190
|
+
|
|
191
|
+
### MessageIf
|
|
192
|
+
|
|
193
|
+
Conditional rendering based on message properties.
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import { MessageIf } from "@assistant-ui/react-native";
|
|
197
|
+
|
|
198
|
+
<MessageIf user>
|
|
199
|
+
<Text>You said:</Text>
|
|
200
|
+
</MessageIf>
|
|
201
|
+
|
|
202
|
+
<MessageIf assistant last>
|
|
203
|
+
<ActivityIndicator />
|
|
204
|
+
</MessageIf>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
| Prop | Type | Description |
|
|
208
|
+
|------|------|-------------|
|
|
209
|
+
| `user` | `boolean` | Render for user messages |
|
|
210
|
+
| `assistant` | `boolean` | Render for assistant messages |
|
|
211
|
+
| `running` | `boolean` | Render when message is being generated |
|
|
212
|
+
| `last` | `boolean` | Render for the last message |
|
|
213
|
+
|
|
214
|
+
### MessageAttachments
|
|
215
|
+
|
|
216
|
+
Renders user message attachments using the provided component configuration.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
import { MessageAttachments } from "@assistant-ui/react-native";
|
|
220
|
+
|
|
221
|
+
<MessageAttachments
|
|
222
|
+
components={{
|
|
223
|
+
Image: MyImageAttachment,
|
|
224
|
+
Attachment: MyFallbackAttachment,
|
|
225
|
+
}}
|
|
226
|
+
/>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
| Prop | Type | Description |
|
|
230
|
+
|------|------|-------------|
|
|
231
|
+
| `components` | `{ Image?, Document?, File?, Attachment? }` | Component renderers by attachment type |
|
|
232
|
+
|
|
233
|
+
## Attachment
|
|
234
|
+
|
|
235
|
+
Primitives for rendering individual attachments (inside `ComposerAttachments` or `MessageAttachments`).
|
|
236
|
+
|
|
237
|
+
### AttachmentRoot
|
|
238
|
+
|
|
239
|
+
Container `View` for an attachment.
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
import { AttachmentRoot } from "@assistant-ui/react-native";
|
|
243
|
+
|
|
244
|
+
<AttachmentRoot style={styles.attachment}>
|
|
245
|
+
{children}
|
|
246
|
+
</AttachmentRoot>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### AttachmentName
|
|
250
|
+
|
|
251
|
+
`Text` component displaying the attachment filename.
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import { AttachmentName } from "@assistant-ui/react-native";
|
|
255
|
+
|
|
256
|
+
<AttachmentName style={styles.filename} />
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### AttachmentThumb
|
|
260
|
+
|
|
261
|
+
`Text` component displaying the file extension (e.g. `.pdf`).
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
import { AttachmentThumb } from "@assistant-ui/react-native";
|
|
265
|
+
|
|
266
|
+
<AttachmentThumb style={styles.extension} />
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### AttachmentRemove
|
|
270
|
+
|
|
271
|
+
`Pressable` that removes the attachment from the composer.
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
import { AttachmentRemove } from "@assistant-ui/react-native";
|
|
275
|
+
|
|
276
|
+
<AttachmentRemove>
|
|
277
|
+
<Text>Remove</Text>
|
|
278
|
+
</AttachmentRemove>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## ActionBar
|
|
282
|
+
|
|
283
|
+
### ActionBarCopy
|
|
284
|
+
|
|
285
|
+
`Pressable` that copies the message content. Supports function-as-children for copy state feedback.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { ActionBarCopy } from "@assistant-ui/react-native";
|
|
289
|
+
|
|
290
|
+
<ActionBarCopy copiedDuration={3000}>
|
|
291
|
+
{({ isCopied }) => <Text>{isCopied ? "Copied!" : "Copy"}</Text>}
|
|
292
|
+
</ActionBarCopy>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
| Prop | Type | Description |
|
|
296
|
+
|------|------|-------------|
|
|
297
|
+
| `copiedDuration` | `number` | Duration in ms to show "copied" state (default: 3000) |
|
|
298
|
+
| `copyToClipboard` | `(text: string) => void` | Custom clipboard function |
|
|
299
|
+
|
|
300
|
+
### ActionBarEdit
|
|
301
|
+
|
|
302
|
+
`Pressable` that enters edit mode for a message.
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { ActionBarEdit } from "@assistant-ui/react-native";
|
|
306
|
+
|
|
307
|
+
<ActionBarEdit>
|
|
308
|
+
<Text>Edit</Text>
|
|
309
|
+
</ActionBarEdit>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### ActionBarReload
|
|
313
|
+
|
|
314
|
+
`Pressable` that regenerates an assistant message.
|
|
315
|
+
|
|
316
|
+
```tsx
|
|
317
|
+
import { ActionBarReload } from "@assistant-ui/react-native";
|
|
318
|
+
|
|
319
|
+
<ActionBarReload>
|
|
320
|
+
<Text>Retry</Text>
|
|
321
|
+
</ActionBarReload>
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### ActionBarFeedbackPositive / ActionBarFeedbackNegative
|
|
325
|
+
|
|
326
|
+
`Pressable` buttons for submitting message feedback.
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import {
|
|
330
|
+
ActionBarFeedbackPositive,
|
|
331
|
+
ActionBarFeedbackNegative,
|
|
332
|
+
} from "@assistant-ui/react-native";
|
|
333
|
+
|
|
334
|
+
<ActionBarFeedbackPositive>
|
|
335
|
+
{({ isSubmitted }) => <Text>{isSubmitted ? "👍" : "👍🏻"}</Text>}
|
|
336
|
+
</ActionBarFeedbackPositive>
|
|
337
|
+
|
|
338
|
+
<ActionBarFeedbackNegative>
|
|
339
|
+
{({ isSubmitted }) => <Text>{isSubmitted ? "👎" : "👎🏻"}</Text>}
|
|
340
|
+
</ActionBarFeedbackNegative>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## BranchPicker
|
|
344
|
+
|
|
345
|
+
### BranchPickerPrevious / BranchPickerNext
|
|
346
|
+
|
|
347
|
+
`Pressable` buttons to navigate between message branches.
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
import {
|
|
351
|
+
BranchPickerPrevious,
|
|
352
|
+
BranchPickerNext,
|
|
353
|
+
BranchPickerNumber,
|
|
354
|
+
BranchPickerCount,
|
|
355
|
+
} from "@assistant-ui/react-native";
|
|
356
|
+
|
|
357
|
+
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
|
358
|
+
<BranchPickerPrevious>
|
|
359
|
+
<Text>←</Text>
|
|
360
|
+
</BranchPickerPrevious>
|
|
361
|
+
<BranchPickerNumber />
|
|
362
|
+
<Text>/</Text>
|
|
363
|
+
<BranchPickerCount />
|
|
364
|
+
<BranchPickerNext>
|
|
365
|
+
<Text>→</Text>
|
|
366
|
+
</BranchPickerNext>
|
|
367
|
+
</View>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### BranchPickerNumber / BranchPickerCount
|
|
371
|
+
|
|
372
|
+
`Text` components displaying the current branch number and total count.
|
|
373
|
+
|
|
374
|
+
## ThreadList
|
|
375
|
+
|
|
376
|
+
### ThreadListRoot
|
|
377
|
+
|
|
378
|
+
Container `View` for the thread list.
|
|
379
|
+
|
|
380
|
+
```tsx
|
|
381
|
+
import { ThreadListRoot } from "@assistant-ui/react-native";
|
|
382
|
+
|
|
383
|
+
<ThreadListRoot style={styles.threadList}>
|
|
384
|
+
{children}
|
|
385
|
+
</ThreadListRoot>
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### ThreadListItems
|
|
389
|
+
|
|
390
|
+
`FlatList` of thread IDs with runtime integration.
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
import { ThreadListItems } from "@assistant-ui/react-native";
|
|
394
|
+
|
|
395
|
+
<ThreadListItems
|
|
396
|
+
renderItem={({ threadId }) => (
|
|
397
|
+
<ThreadListEntry threadId={threadId} />
|
|
398
|
+
)}
|
|
399
|
+
/>
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
| Prop | Type | Description |
|
|
403
|
+
|------|------|-------------|
|
|
404
|
+
| `renderItem` | `(props: { threadId: string; index: number }) => ReactElement` | Thread item renderer |
|
|
405
|
+
| `...rest` | `FlatListProps` | Standard FlatList props (except `data`, `renderItem`) |
|
|
406
|
+
|
|
407
|
+
### ThreadListNew
|
|
408
|
+
|
|
409
|
+
`Pressable` that creates a new thread.
|
|
410
|
+
|
|
411
|
+
```tsx
|
|
412
|
+
import { ThreadListNew } from "@assistant-ui/react-native";
|
|
413
|
+
|
|
414
|
+
<ThreadListNew style={styles.newThreadButton}>
|
|
415
|
+
<Text>New Chat</Text>
|
|
416
|
+
</ThreadListNew>
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## ThreadListItem
|
|
420
|
+
|
|
421
|
+
Primitives for rendering individual thread list items. Use inside a `ThreadListItemByIndexProvider` or within `ThreadListPrimitiveItems` components.
|
|
422
|
+
|
|
423
|
+
### ThreadListItemRoot
|
|
424
|
+
|
|
425
|
+
Container `View` for a thread list item.
|
|
426
|
+
|
|
427
|
+
```tsx
|
|
428
|
+
import { ThreadListItemRoot } from "@assistant-ui/react-native";
|
|
429
|
+
|
|
430
|
+
<ThreadListItemRoot style={styles.threadItem}>
|
|
431
|
+
{children}
|
|
432
|
+
</ThreadListItemRoot>
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### ThreadListItemTitle
|
|
436
|
+
|
|
437
|
+
Renders the thread title text. Falls back to the provided fallback when title is empty. This component is shared from `@assistant-ui/core/react`.
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import { ThreadListItemTitle } from "@assistant-ui/react-native";
|
|
441
|
+
|
|
442
|
+
<ThreadListItemTitle fallback="New Chat" />
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
| Prop | Type | Description |
|
|
446
|
+
|------|------|-------------|
|
|
447
|
+
| `fallback` | `ReactNode` | Content to show when title is empty |
|
|
448
|
+
|
|
449
|
+
### ThreadListItemTrigger
|
|
450
|
+
|
|
451
|
+
`Pressable` that switches to the thread.
|
|
452
|
+
|
|
453
|
+
```tsx
|
|
454
|
+
import { ThreadListItemTrigger } from "@assistant-ui/react-native";
|
|
455
|
+
|
|
456
|
+
<ThreadListItemTrigger>
|
|
457
|
+
<ThreadListItemTitle fallback="New Chat" />
|
|
458
|
+
</ThreadListItemTrigger>
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### ThreadListItemDelete
|
|
462
|
+
|
|
463
|
+
`Pressable` that deletes the thread.
|
|
464
|
+
|
|
465
|
+
```tsx
|
|
466
|
+
import { ThreadListItemDelete } from "@assistant-ui/react-native";
|
|
467
|
+
|
|
468
|
+
<ThreadListItemDelete>
|
|
469
|
+
<Text>Delete</Text>
|
|
470
|
+
</ThreadListItemDelete>
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### ThreadListItemArchive / ThreadListItemUnarchive
|
|
474
|
+
|
|
475
|
+
`Pressable` buttons that archive or unarchive the thread.
|
|
476
|
+
|
|
477
|
+
```tsx
|
|
478
|
+
import {
|
|
479
|
+
ThreadListItemArchive,
|
|
480
|
+
ThreadListItemUnarchive,
|
|
481
|
+
} from "@assistant-ui/react-native";
|
|
482
|
+
|
|
483
|
+
<ThreadListItemArchive>
|
|
484
|
+
<Text>Archive</Text>
|
|
485
|
+
</ThreadListItemArchive>
|
|
486
|
+
|
|
487
|
+
<ThreadListItemUnarchive>
|
|
488
|
+
<Text>Unarchive</Text>
|
|
489
|
+
</ThreadListItemUnarchive>
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## Suggestion
|
|
493
|
+
|
|
494
|
+
Primitives for rendering suggestions. Use inside a `SuggestionByIndexProvider` (from `@assistant-ui/core/react`).
|
|
495
|
+
|
|
496
|
+
### SuggestionTitle
|
|
497
|
+
|
|
498
|
+
`Text` component displaying the suggestion title.
|
|
499
|
+
|
|
500
|
+
```tsx
|
|
501
|
+
import { SuggestionTitle } from "@assistant-ui/react-native";
|
|
502
|
+
|
|
503
|
+
<SuggestionTitle style={styles.suggestionTitle} />
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### SuggestionDescription
|
|
507
|
+
|
|
508
|
+
`Text` component displaying the suggestion description/label.
|
|
509
|
+
|
|
510
|
+
```tsx
|
|
511
|
+
import { SuggestionDescription } from "@assistant-ui/react-native";
|
|
512
|
+
|
|
513
|
+
<SuggestionDescription style={styles.suggestionDescription} />
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### SuggestionTrigger
|
|
517
|
+
|
|
518
|
+
`Pressable` that triggers the suggestion action (send or insert into composer).
|
|
519
|
+
|
|
520
|
+
```tsx
|
|
521
|
+
import { SuggestionTrigger } from "@assistant-ui/react-native";
|
|
522
|
+
|
|
523
|
+
<SuggestionTrigger send>
|
|
524
|
+
<SuggestionTitle />
|
|
525
|
+
</SuggestionTrigger>
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
| Prop | Type | Description |
|
|
529
|
+
|------|------|-------------|
|
|
530
|
+
| `send` | `boolean` | When true, sends immediately; when false, inserts into composer |
|
|
531
|
+
| `clearComposer` | `boolean` | Whether to clear/replace composer text (default: true) |
|
|
532
|
+
|
|
533
|
+
### ThreadSuggestion
|
|
534
|
+
|
|
535
|
+
Inline `Pressable` that triggers a suggestion with a specified prompt. Use this when you want to hardcode suggestion text.
|
|
536
|
+
|
|
537
|
+
```tsx
|
|
538
|
+
import { ThreadSuggestion } from "@assistant-ui/react-native";
|
|
539
|
+
|
|
540
|
+
<ThreadSuggestion prompt="Tell me a joke" send>
|
|
541
|
+
<Text>Tell me a joke</Text>
|
|
542
|
+
</ThreadSuggestion>
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
| Prop | Type | Description |
|
|
546
|
+
|------|------|-------------|
|
|
547
|
+
| `prompt` | `string` | The suggestion text |
|
|
548
|
+
| `send` | `boolean` | When true, sends immediately |
|
|
549
|
+
| `clearComposer` | `boolean` | Whether to clear/replace composer text (default: true) |
|
|
550
|
+
|
|
551
|
+
### ThreadPrimitiveSuggestions
|
|
552
|
+
|
|
553
|
+
Renders all suggestions from the store. Shared from `@assistant-ui/core/react`.
|
|
554
|
+
|
|
555
|
+
```tsx
|
|
556
|
+
import { ThreadPrimitiveSuggestions } from "@assistant-ui/react-native";
|
|
557
|
+
|
|
558
|
+
<ThreadPrimitiveSuggestions
|
|
559
|
+
components={{ Suggestion: MySuggestionComponent }}
|
|
560
|
+
/>
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
## ChainOfThought
|
|
564
|
+
|
|
565
|
+
Primitives for rendering chain of thought content (grouped reasoning and tool-call parts).
|
|
566
|
+
|
|
567
|
+
### ChainOfThoughtRoot
|
|
568
|
+
|
|
569
|
+
Container `View` for chain of thought content.
|
|
570
|
+
|
|
571
|
+
```tsx
|
|
572
|
+
import { ChainOfThoughtRoot } from "@assistant-ui/react-native";
|
|
573
|
+
|
|
574
|
+
<ChainOfThoughtRoot style={styles.chainOfThought}>
|
|
575
|
+
{children}
|
|
576
|
+
</ChainOfThoughtRoot>
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### ChainOfThoughtAccordionTrigger
|
|
580
|
+
|
|
581
|
+
`Pressable` that toggles the collapsed state of the chain of thought.
|
|
582
|
+
|
|
583
|
+
```tsx
|
|
584
|
+
import { ChainOfThoughtAccordionTrigger } from "@assistant-ui/react-native";
|
|
585
|
+
|
|
586
|
+
<ChainOfThoughtAccordionTrigger>
|
|
587
|
+
<Text>Toggle reasoning</Text>
|
|
588
|
+
</ChainOfThoughtAccordionTrigger>
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### ChainOfThoughtPrimitiveParts
|
|
592
|
+
|
|
593
|
+
Renders the parts within a chain of thought. Shared from `@assistant-ui/core/react`.
|
|
594
|
+
|
|
595
|
+
```tsx
|
|
596
|
+
import { ChainOfThoughtPrimitiveParts } from "@assistant-ui/react-native";
|
|
597
|
+
|
|
598
|
+
<ChainOfThoughtPrimitiveParts
|
|
599
|
+
components={{
|
|
600
|
+
Reasoning: ({ text }) => <Text>{text}</Text>,
|
|
601
|
+
tools: { Fallback: MyToolComponent },
|
|
602
|
+
}}
|
|
603
|
+
/>
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
## Additional Composer Primitives
|
|
607
|
+
|
|
608
|
+
### ComposerAddAttachment
|
|
609
|
+
|
|
610
|
+
`Pressable` for triggering attachment addition. The actual file picker must be implemented by the consumer (e.g. using `expo-document-picker` or `expo-image-picker`).
|
|
611
|
+
|
|
612
|
+
```tsx
|
|
613
|
+
import { ComposerAddAttachment } from "@assistant-ui/react-native";
|
|
614
|
+
|
|
615
|
+
<ComposerAddAttachment onPress={handlePickFile}>
|
|
616
|
+
<Text>📎</Text>
|
|
617
|
+
</ComposerAddAttachment>
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### ComposerIf
|
|
621
|
+
|
|
622
|
+
Conditional rendering based on composer state. Shared from `@assistant-ui/core/react`.
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
import { ComposerIf } from "@assistant-ui/react-native";
|
|
626
|
+
|
|
627
|
+
<ComposerIf editing>
|
|
628
|
+
<Text>Currently editing</Text>
|
|
629
|
+
</ComposerIf>
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
| Prop | Type | Description |
|
|
633
|
+
|------|------|-------------|
|
|
634
|
+
| `editing` | `boolean` | Render when composer is in editing mode |
|
|
635
|
+
| `dictation` | `boolean` | Render when dictation is active |
|
|
636
|
+
|
|
637
|
+
## Shared Primitives from core/react
|
|
638
|
+
|
|
639
|
+
The following primitives are shared with `@assistant-ui/react` via `@assistant-ui/core/react` and work identically on both platforms:
|
|
640
|
+
|
|
641
|
+
- **`ThreadPrimitiveMessages`** / **`ThreadPrimitiveMessageByIndex`** — Component-composition pattern for rendering messages (alternative to the FlatList-based `ThreadMessages`)
|
|
642
|
+
- **`MessagePrimitiveParts`** / **`MessagePrimitivePartByIndex`** — Renders message parts with grouping, ChainOfThought, and Empty support (alternative to the render-props-based `MessageContent`). Uses `<Text>` as default text renderer on RN.
|
|
643
|
+
- **`ThreadPrimitiveSuggestions`** / **`ThreadPrimitiveSuggestionByIndex`** — Renders suggestions from the store
|
|
644
|
+
- **`ThreadListPrimitiveItems`** / **`ThreadListPrimitiveItemByIndex`** — Component-composition pattern for thread list items (alternative to the FlatList-based `ThreadListItems`)
|
|
645
|
+
- **`ChainOfThoughtPrimitiveParts`** — Renders chain of thought parts
|
|
646
|
+
|
|
647
|
+
```tsx
|
|
648
|
+
import {
|
|
649
|
+
ThreadPrimitiveMessages,
|
|
650
|
+
MessagePrimitiveParts,
|
|
651
|
+
ThreadPrimitiveSuggestions,
|
|
652
|
+
} from "@assistant-ui/react-native";
|
|
653
|
+
```
|
|
@@ -119,35 +119,27 @@ Creates a runtime integrated with AI SDK's `useChat` hook.
|
|
|
119
119
|
```tsx
|
|
120
120
|
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
121
121
|
|
|
122
|
-
const runtime = useChatRuntime(
|
|
123
|
-
api: "/api/chat", // optional, defaults to "/api/chat"
|
|
124
|
-
});
|
|
122
|
+
const runtime = useChatRuntime();
|
|
125
123
|
```
|
|
126
124
|
|
|
127
125
|
### Custom API URL
|
|
128
126
|
|
|
129
|
-
|
|
130
|
-
const runtime = useChatRuntime({
|
|
131
|
-
api: "/my-custom-api/chat",
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Forwarding System Messages and Frontend Tools
|
|
136
|
-
|
|
137
|
-
Use `AssistantChatTransport` to automatically forward system messages and frontend tools to your backend:
|
|
127
|
+
To use a different endpoint, pass a custom `AssistantChatTransport`:
|
|
138
128
|
|
|
139
129
|
```tsx
|
|
140
|
-
"use client";
|
|
141
|
-
|
|
142
130
|
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
143
131
|
|
|
144
132
|
const runtime = useChatRuntime({
|
|
145
133
|
transport: new AssistantChatTransport({
|
|
146
|
-
api: "/api/chat",
|
|
134
|
+
api: "/my-custom-api/chat",
|
|
147
135
|
}),
|
|
148
136
|
});
|
|
149
137
|
```
|
|
150
138
|
|
|
139
|
+
### System Messages and Frontend Tools
|
|
140
|
+
|
|
141
|
+
`AssistantChatTransport` (used by default) automatically forwards system messages and frontend tools to your backend. To consume them, update your backend route:
|
|
142
|
+
|
|
151
143
|
Backend route with system/tools forwarding:
|
|
152
144
|
|
|
153
145
|
```tsx
|