@assistant-ui/mcp-docs-server 0.1.31 → 0.1.33

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.
Files changed (281) hide show
  1. package/.docs/organized/code-examples/waterfall.md +23 -25
  2. package/.docs/organized/code-examples/with-a2a.md +28 -28
  3. package/.docs/organized/code-examples/with-ag-ui.md +35 -30
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +16 -14
  5. package/.docs/organized/code-examples/with-artifacts.md +44 -38
  6. package/.docs/organized/code-examples/with-assistant-transport.md +68 -56
  7. package/.docs/organized/code-examples/with-browser-extension.md +357 -0
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +425 -90
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +30 -29
  10. package/.docs/organized/code-examples/with-cloud.md +16 -14
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +19 -17
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +29 -26
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +20 -18
  14. package/.docs/organized/code-examples/with-expo.md +37 -31
  15. package/.docs/organized/code-examples/with-external-store.md +13 -11
  16. package/.docs/organized/code-examples/with-ffmpeg.md +327 -290
  17. package/.docs/organized/code-examples/with-generative-ui.md +1195 -194
  18. package/.docs/organized/code-examples/with-google-adk.md +13 -11
  19. package/.docs/organized/code-examples/with-heat-graph.md +16 -14
  20. package/.docs/organized/code-examples/with-image-generation.md +456 -0
  21. package/.docs/organized/code-examples/with-interactables.md +322 -244
  22. package/.docs/organized/code-examples/with-langchain.md +18 -16
  23. package/.docs/organized/code-examples/with-langgraph.md +95 -88
  24. package/.docs/organized/code-examples/with-livekit.md +30 -27
  25. package/.docs/organized/code-examples/with-mcp.md +754 -0
  26. package/.docs/organized/code-examples/with-opencode.md +70 -70
  27. package/.docs/organized/code-examples/with-react-hook-form.md +24 -22
  28. package/.docs/organized/code-examples/with-react-ink.md +4 -4
  29. package/.docs/organized/code-examples/with-react-router.md +20 -18
  30. package/.docs/organized/code-examples/with-resumable-stream.md +661 -0
  31. package/.docs/organized/code-examples/with-store.md +22 -20
  32. package/.docs/organized/code-examples/with-tanstack.md +18 -19
  33. package/.docs/organized/code-examples/with-tap-runtime.md +31 -28
  34. package/.docs/raw/docs/(docs)/architecture.mdx +43 -2
  35. package/.docs/raw/docs/(docs)/cli.mdx +2 -2
  36. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +34 -26
  37. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +32 -26
  38. package/.docs/raw/docs/(docs)/index.mdx +2 -2
  39. package/.docs/raw/docs/(docs)/installation.mdx +2 -2
  40. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +26 -24
  41. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
  42. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +20 -12
  43. package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
  44. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +41 -16
  45. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +12 -23
  46. package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +20 -0
  47. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +37 -8
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +11 -9
  49. package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +64 -0
  50. package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +22 -0
  51. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +52 -0
  52. package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +46 -0
  53. package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
  54. package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
  55. package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
  56. package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
  57. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +18 -13
  58. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +31 -52
  59. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
  60. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +15 -28
  61. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +64 -18
  62. package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +434 -0
  63. package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +24 -0
  64. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +11 -12
  65. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +109 -0
  66. package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +58 -0
  67. package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +22 -0
  68. package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +20 -0
  69. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +109 -132
  70. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +78 -221
  71. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +127 -242
  72. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +39 -20
  73. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +66 -87
  74. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +50 -58
  75. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +80 -48
  76. package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +67 -0
  77. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +323 -461
  78. package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +36 -43
  79. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +29 -24
  80. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
  81. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +202 -588
  82. package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +65 -0
  83. package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +35 -22
  84. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +57 -140
  85. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +70 -161
  86. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +84 -108
  87. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +77 -96
  88. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -349
  89. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +9 -21
  90. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +10 -21
  91. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +15 -70
  92. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +18 -13
  93. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +25 -28
  94. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +11 -63
  95. package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +20 -0
  96. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +11 -48
  97. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +10 -47
  98. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
  99. package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +85 -0
  100. package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
  101. package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +127 -0
  102. package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
  103. package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +91 -0
  104. package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +48 -0
  105. package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +62 -0
  106. package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +22 -0
  107. package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +19 -0
  108. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +143 -0
  109. package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +22 -0
  110. package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +54 -0
  111. package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +36 -0
  112. package/.docs/raw/docs/cloud/ai-sdk.mdx +1 -3
  113. package/.docs/raw/docs/cloud/index.mdx +2 -2
  114. package/.docs/raw/docs/guides/attachments.mdx +4 -4
  115. package/.docs/raw/docs/guides/branching.mdx +1 -1
  116. package/.docs/raw/docs/guides/chain-of-thought.mdx +12 -14
  117. package/.docs/raw/docs/guides/context-api.mdx +6 -5
  118. package/.docs/raw/docs/guides/dictation.mdx +2 -2
  119. package/.docs/raw/docs/guides/editing.mdx +1 -1
  120. package/.docs/raw/docs/guides/image-generation.mdx +74 -0
  121. package/.docs/raw/docs/guides/index.mdx +5 -14
  122. package/.docs/raw/docs/guides/latex.mdx +2 -2
  123. package/.docs/raw/docs/guides/mentions.mdx +6 -6
  124. package/.docs/raw/docs/guides/message-timing.mdx +38 -5
  125. package/.docs/raw/docs/guides/quoting.mdx +1 -1
  126. package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +212 -0
  127. package/.docs/raw/docs/guides/resumable-stream-stores.mdx +152 -0
  128. package/.docs/raw/docs/guides/resumable-streams.mdx +210 -0
  129. package/.docs/raw/docs/guides/slash-commands.mdx +2 -2
  130. package/.docs/raw/docs/guides/speech.mdx +2 -2
  131. package/.docs/raw/docs/guides/suggestions.mdx +89 -5
  132. package/.docs/raw/docs/guides/voice.mdx +2 -2
  133. package/.docs/raw/docs/ink/adapters.mdx +37 -1
  134. package/.docs/raw/docs/ink/custom-backend.mdx +59 -8
  135. package/.docs/raw/docs/ink/hooks.mdx +98 -85
  136. package/.docs/raw/docs/ink/index.mdx +10 -11
  137. package/.docs/raw/docs/ink/migration.mdx +1 -1
  138. package/.docs/raw/docs/ink/primitives.mdx +350 -9
  139. package/.docs/raw/docs/integrations/auth/better-auth.mdx +1 -1
  140. package/.docs/raw/docs/integrations/auth/clerk.mdx +1 -1
  141. package/.docs/raw/docs/integrations/auth/next-auth.mdx +1 -1
  142. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +3 -3
  143. package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
  144. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +2 -2
  145. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
  146. package/.docs/raw/docs/integrations/gateways/index.mdx +9 -4
  147. package/.docs/raw/docs/integrations/index.mdx +17 -5
  148. package/.docs/raw/docs/integrations/observability/langfuse.mdx +8 -1
  149. package/.docs/raw/docs/integrations/observability/langsmith.mdx +8 -4
  150. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
  151. package/.docs/raw/docs/migrations/toolkit-tools.mdx +226 -0
  152. package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
  153. package/.docs/raw/docs/primitives/composer.mdx +53 -0
  154. package/.docs/raw/docs/primitives/index.mdx +2 -2
  155. package/.docs/raw/docs/primitives/message.mdx +9 -10
  156. package/.docs/raw/docs/primitives/suggestion.mdx +9 -0
  157. package/.docs/raw/docs/react-native/hooks.mdx +57 -82
  158. package/.docs/raw/docs/react-native/index.mdx +4 -4
  159. package/.docs/raw/docs/react-native/migration.mdx +1 -1
  160. package/.docs/raw/docs/react-native/primitives.mdx +2 -2
  161. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +7 -4
  162. package/.docs/raw/docs/runtimes/a2a/overview.mdx +2 -2
  163. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +2 -2
  164. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +32 -1
  165. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +2 -2
  166. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +7 -2
  167. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
  168. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +129 -1
  169. package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
  170. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +27 -2
  171. package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -1
  172. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +18 -7
  173. package/.docs/raw/docs/runtimes/custom/overview.mdx +2 -2
  174. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
  175. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +2 -2
  176. package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
  177. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
  178. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +2 -2
  179. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
  180. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
  181. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
  182. package/.docs/raw/docs/runtimes/opencode/overview.mdx +2 -2
  183. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
  184. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -5
  185. package/.docs/raw/docs/tools/backend.mdx +136 -0
  186. package/.docs/raw/docs/tools/defining-tools.mdx +413 -0
  187. package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
  188. package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
  189. package/.docs/raw/docs/tools/index.mdx +76 -0
  190. package/.docs/raw/docs/{guides → tools}/interactables.mdx +3 -3
  191. package/.docs/raw/docs/tools/mcp-apps.mdx +231 -0
  192. package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +77 -50
  193. package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +19 -21
  194. package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
  195. package/.docs/raw/docs/tools/user-managed-mcp.mdx +337 -0
  196. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +11 -1
  197. package/.docs/raw/docs/ui/directive-text.mdx +3 -3
  198. package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
  199. package/.docs/raw/docs/ui/model-selector.mdx +8 -8
  200. package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
  201. package/.docs/raw/docs/ui/reasoning.mdx +4 -5
  202. package/.docs/raw/docs/ui/sources.mdx +17 -0
  203. package/.docs/raw/docs/ui/streamdown.mdx +34 -2
  204. package/.docs/raw/docs/ui/thread-list.mdx +2 -2
  205. package/.docs/raw/docs/ui/thread.mdx +2 -2
  206. package/.docs/raw/docs/ui/tool-group.mdx +5 -6
  207. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
  208. package/README.md +14 -72
  209. package/dist/constants.d.ts +12 -9
  210. package/dist/constants.d.ts.map +1 -1
  211. package/dist/constants.js +13 -9
  212. package/dist/constants.js.map +1 -1
  213. package/dist/index.d.ts +7 -3
  214. package/dist/index.d.ts.map +1 -1
  215. package/dist/index.js +25 -24
  216. package/dist/index.js.map +1 -1
  217. package/dist/prepare-docs/code-examples.d.ts +4 -1
  218. package/dist/prepare-docs/code-examples.d.ts.map +1 -1
  219. package/dist/prepare-docs/code-examples.js +109 -121
  220. package/dist/prepare-docs/code-examples.js.map +1 -1
  221. package/dist/prepare-docs/copy-raw.d.ts +4 -1
  222. package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
  223. package/dist/prepare-docs/copy-raw.js +45 -42
  224. package/dist/prepare-docs/copy-raw.js.map +1 -1
  225. package/dist/prepare-docs/prepare.d.ts +1 -2
  226. package/dist/prepare-docs/prepare.js +17 -17
  227. package/dist/prepare-docs/prepare.js.map +1 -1
  228. package/dist/stdio.d.ts +1 -3
  229. package/dist/stdio.js +6 -3
  230. package/dist/stdio.js.map +1 -1
  231. package/dist/tools/docs.d.ts +20 -15
  232. package/dist/tools/docs.d.ts.map +1 -1
  233. package/dist/tools/docs.js +140 -161
  234. package/dist/tools/docs.js.map +1 -1
  235. package/dist/tools/examples.d.ts +20 -15
  236. package/dist/tools/examples.d.ts.map +1 -1
  237. package/dist/tools/examples.js +74 -86
  238. package/dist/tools/examples.js.map +1 -1
  239. package/dist/tools/tests/test-setup.d.ts +5 -2
  240. package/dist/tools/tests/test-setup.d.ts.map +1 -1
  241. package/dist/tools/tests/test-setup.js +21 -28
  242. package/dist/tools/tests/test-setup.js.map +1 -1
  243. package/dist/utils/logger.d.ts +8 -5
  244. package/dist/utils/logger.d.ts.map +1 -1
  245. package/dist/utils/logger.js +17 -17
  246. package/dist/utils/logger.js.map +1 -1
  247. package/dist/utils/mcp-format.d.ts +8 -5
  248. package/dist/utils/mcp-format.d.ts.map +1 -1
  249. package/dist/utils/mcp-format.js +9 -9
  250. package/dist/utils/mcp-format.js.map +1 -1
  251. package/dist/utils/mdx.d.ts +8 -6
  252. package/dist/utils/mdx.d.ts.map +1 -1
  253. package/dist/utils/mdx.js +22 -22
  254. package/dist/utils/mdx.js.map +1 -1
  255. package/dist/utils/paths.d.ts +9 -6
  256. package/dist/utils/paths.d.ts.map +1 -1
  257. package/dist/utils/paths.js +66 -76
  258. package/dist/utils/paths.js.map +1 -1
  259. package/dist/utils/security.d.ts +4 -1
  260. package/dist/utils/security.d.ts.map +1 -1
  261. package/dist/utils/security.js +19 -40
  262. package/dist/utils/security.js.map +1 -1
  263. package/package.json +5 -5
  264. package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
  265. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
  266. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
  267. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +0 -41
  268. package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -40
  269. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -260
  270. package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -103
  271. package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -254
  272. package/.docs/raw/docs/guides/tool-ui.mdx +0 -858
  273. package/.docs/raw/docs/guides/tools.mdx +0 -675
  274. package/dist/prepare-docs/prepare.d.ts.map +0 -1
  275. package/dist/stdio.d.ts.map +0 -1
  276. /package/.docs/raw/docs/{(reference)/migrations → migrations}/deprecation-policy.mdx +0 -0
  277. /package/.docs/raw/docs/{(reference) → migrations}/react-compatibility.mdx +0 -0
  278. /package/.docs/raw/docs/{(reference)/migrations → migrations}/react-langgraph-v0-7.mdx +0 -0
  279. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-11.mdx +0 -0
  280. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-12.mdx +0 -0
  281. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-14.mdx +0 -0
@@ -1,858 +0,0 @@
1
- ---
2
- title: Generative UI
3
- description: Render tool calls as interactive UI instead of plain text.
4
- platforms: ["react"]
5
- ---
6
-
7
- import { ToolUISample } from "@/components/docs/samples/tool-ui";
8
-
9
- Create custom UI components for AI tool calls, providing visual feedback and interactive experiences when tools are executed.
10
-
11
- <ToolUISample />
12
-
13
- ## Overview
14
-
15
- Tool UIs in assistant-ui allow you to create custom interfaces that appear when AI tools are called. These generative UI components enhance the user experience by:
16
-
17
- - **Visualizing tool execution** with loading states and progress indicators
18
- - **Displaying results** in rich, formatted layouts
19
- - **Enabling user interaction** through forms and controls
20
- - **Providing error feedback** with helpful recovery options
21
-
22
- This guide demonstrates building tool UIs with the **Vercel AI SDK**.
23
-
24
- ## Creating Tool UIs
25
-
26
- There are two main approaches to creating tool UIs in assistant-ui:
27
-
28
- ### 1. Client-Defined Tools (`makeAssistantTool`)
29
-
30
- If you're creating tools on the client side, use `makeAssistantTool` to register them with the assistant context. Then create a UI component with `makeAssistantToolUI`. This component-based API coexists with the [Tools()](/docs/guides/tools) toolkit API; pick whichever fits your codebase better.
31
-
32
- ```tsx
33
- import { makeAssistantTool, tool } from "@assistant-ui/react";
34
- import { z } from "zod";
35
-
36
- // Define the tool
37
- const weatherTool = tool({
38
- description: "Get current weather for a location",
39
- parameters: z.object({
40
- location: z.string(),
41
- unit: z.enum(["celsius", "fahrenheit"]),
42
- }),
43
- execute: async ({ location, unit }) => {
44
- const weather = await fetchWeatherAPI(location, unit);
45
- return weather;
46
- },
47
- });
48
-
49
- // Register the tool
50
- const WeatherTool = makeAssistantTool({
51
- ...weatherTool,
52
- toolName: "getWeather",
53
- });
54
-
55
- // Create the UI
56
- const WeatherToolUI = makeAssistantToolUI<
57
- { location: string; unit: "celsius" | "fahrenheit" },
58
- { temperature: number; description: string }
59
- >({
60
- toolName: "getWeather",
61
- render: ({ args, result, status }) => {
62
- if (status.type === "running") {
63
- return <div>Checking weather in {args.location}...</div>;
64
- }
65
-
66
- return (
67
- <div className="weather-card">
68
- <h3>{args.location}</h3>
69
- <p>
70
- {result.temperature}°{args.unit === "celsius" ? "C" : "F"}
71
- </p>
72
- <p>{result.description}</p>
73
- </div>
74
- );
75
- },
76
- });
77
- ```
78
-
79
- <Callout type="tip">
80
- Tools defined with `makeAssistantTool` can be passed to your backend using the
81
- `frontendTools` utility
82
- </Callout>
83
-
84
- Learn more about creating tools in the [Tools Guide](/docs/guides/tools).
85
-
86
- ### 2. UI-Only for Existing Tools (`makeAssistantToolUI`)
87
-
88
- If your tool is defined elsewhere (e.g., in your backend API, MCP server, or LangGraph), use `makeAssistantToolUI` to create just the UI component:
89
-
90
- ```tsx
91
- import { makeAssistantToolUI } from "@assistant-ui/react";
92
-
93
- const WeatherToolUI = makeAssistantToolUI<
94
- { location: string; unit: "celsius" | "fahrenheit" },
95
- { temperature: number; description: string }
96
- >({
97
- toolName: "getWeather", // Must match the backend tool name
98
- render: ({ args, result, status }) => {
99
- // UI rendering logic only
100
- },
101
- });
102
- ```
103
-
104
- ## Quick Start Example
105
-
106
- This example shows how to implement the UI-only approach using `makeAssistantToolUI`:
107
-
108
- <Steps>
109
- <Step>
110
-
111
- ### Create a Tool UI Component
112
-
113
- ```tsx
114
- import { makeAssistantToolUI } from "@assistant-ui/react";
115
- import { z } from "zod";
116
-
117
- type WeatherArgs = {
118
- location: string;
119
- unit: "celsius" | "fahrenheit";
120
- };
121
-
122
- type WeatherResult = {
123
- temperature: number;
124
- description: string;
125
- humidity: number;
126
- windSpeed: number;
127
- };
128
-
129
- const WeatherToolUI = makeAssistantToolUI<WeatherArgs, WeatherResult>({
130
- toolName: "getWeather",
131
- render: ({ args, status, result }) => {
132
- if (status.type === "running") {
133
- return (
134
- <div className="flex items-center gap-2">
135
- <Spinner />
136
- <span>Checking weather in {args.location}...</span>
137
- </div>
138
- );
139
- }
140
-
141
- if (status.type === "incomplete" && status.reason === "error") {
142
- return (
143
- <div className="text-red-500">
144
- Failed to get weather for {args.location}
145
- </div>
146
- );
147
- }
148
-
149
- return (
150
- <div className="weather-card rounded-lg bg-blue-50 p-4">
151
- <h3 className="text-lg font-bold">{args.location}</h3>
152
- <div className="mt-2 grid grid-cols-2 gap-4">
153
- <div>
154
- <p className="text-2xl">
155
- {result.temperature}°{args.unit === "celsius" ? "C" : "F"}
156
- </p>
157
- <p className="text-gray-600">{result.description}</p>
158
- </div>
159
- <div className="text-sm">
160
- <p>Humidity: {result.humidity}%</p>
161
- <p>Wind: {result.windSpeed} km/h</p>
162
- </div>
163
- </div>
164
- </div>
165
- );
166
- },
167
- });
168
- ```
169
-
170
- </Step>
171
- <Step>
172
-
173
- ### Register the Tool UI
174
-
175
- Place the component inside your `AssistantRuntimeProvider`:
176
-
177
- ```tsx
178
- function App() {
179
- return (
180
- <AssistantRuntimeProvider runtime={runtime}>
181
- <Thread />
182
- <WeatherToolUI />
183
- </AssistantRuntimeProvider>
184
- );
185
- }
186
- ```
187
-
188
- </Step>
189
- <Step>
190
-
191
- ### Define the Backend Tool (Vercel AI SDK)
192
-
193
- When using the Vercel AI SDK, define the corresponding tool in your API route:
194
-
195
- ```tsx title="/app/api/chat/route.ts"
196
- import { streamText, tool, zodSchema } from "ai";
197
- import { z } from "zod";
198
-
199
- export async function POST(req: Request) {
200
- const { messages } = await req.json();
201
-
202
- const result = streamText({
203
- model: openai("gpt-4o"),
204
- messages: await convertToModelMessages(messages),
205
- tools: {
206
- getWeather: tool({
207
- description: "Get current weather for a location",
208
- inputSchema: zodSchema(
209
- z.object({
210
- location: z.string(),
211
- unit: z.enum(["celsius", "fahrenheit"]),
212
- }),
213
- ),
214
- execute: async ({ location, unit }) => {
215
- const weather = await fetchWeatherAPI(location);
216
- return {
217
- temperature: weather.temp,
218
- description: weather.condition,
219
- humidity: weather.humidity,
220
- windSpeed: weather.wind,
221
- };
222
- },
223
- }),
224
- },
225
- });
226
-
227
- return result.toUIMessageStreamResponse();
228
- }
229
- ```
230
-
231
- </Step>
232
- </Steps>
233
-
234
- ## Tool UI Patterns
235
-
236
- ### Component Pattern
237
-
238
- Create standalone tool UI components:
239
-
240
- ```tsx
241
- export const WebSearchToolUI = makeAssistantToolUI<
242
- { query: string },
243
- { results: SearchResult[] }
244
- >({
245
- toolName: "webSearch",
246
- render: ({ args, status, result }) => {
247
- return (
248
- <div className="search-container">
249
- <div className="mb-3 flex items-center gap-2">
250
- <SearchIcon />
251
- <span>Search results for: "{args.query}"</span>
252
- </div>
253
-
254
- {status.type === "running" && <LoadingSpinner />}
255
-
256
- {result && (
257
- <div className="space-y-2">
258
- {result.results.map((item, index) => (
259
- <div key={index} className="rounded border p-3">
260
- <a href={item.url} className="font-medium text-blue-600">
261
- {item.title}
262
- </a>
263
- <p className="text-sm text-gray-600">{item.snippet}</p>
264
- </div>
265
- ))}
266
- </div>
267
- )}
268
- </div>
269
- );
270
- },
271
- });
272
- ```
273
-
274
- ### Hook Pattern
275
-
276
- Use hooks for dynamic tool UI registration:
277
-
278
- <Callout type="tip">
279
- Use the `useAssistantToolUI` hook directly in your component for dynamic tool UI registration. This allows access to local component state and props when rendering the tool UI.
280
- </Callout>
281
-
282
- ```tsx
283
- import { useAssistantToolUI } from "@assistant-ui/react";
284
-
285
- function DynamicToolUI() {
286
- const [theme, setTheme] = useState("light");
287
-
288
- useAssistantToolUI({
289
- toolName: "analyzeData",
290
- render: ({ args, result, status }) => {
291
- // Hook allows access to component state
292
- return (
293
- <DataVisualization
294
- data={result}
295
- theme={theme}
296
- loading={status.type === "running"}
297
- />
298
- );
299
- },
300
- });
301
-
302
- return null;
303
- }
304
- ```
305
-
306
- ### Inline Pattern
307
-
308
- For tools that need access to parent component props:
309
-
310
- <Callout type="tip">
311
- **Why `useInlineRender`?** By default, a tool UI's `render` function is
312
- static. Use `useInlineRender` when your UI needs access to dynamic component
313
- props (for example, to pass in an `id` or other contextual data).
314
- </Callout>
315
-
316
- ```tsx
317
- import { useAssistantToolUI, useInlineRender } from "@assistant-ui/react";
318
-
319
- function ProductPage({ productId, productName }) {
320
- useAssistantToolUI({
321
- toolName: "checkInventory",
322
- render: useInlineRender(({ args, result }) => {
323
- // Access parent component props
324
- return (
325
- <div className="inventory-status">
326
- <h4>{productName} Inventory</h4>
327
- <p>
328
- Stock for {productId}: {result.quantity} units
329
- </p>
330
- <p>Location: {result.warehouse}</p>
331
- </div>
332
- );
333
- }),
334
- });
335
-
336
- return <div>Product details...</div>;
337
- }
338
- ```
339
-
340
- ## Interactive Tool UIs
341
-
342
- ### User Input Collection
343
-
344
- Create tools that collect user input during execution:
345
-
346
- <Callout type="tip">
347
- **Pro tip:** Call `addResult(...)` exactly once to complete the tool call.
348
- After it's invoked, the assistant will resume the conversation with your
349
- provided data.
350
- </Callout>
351
-
352
- ```tsx
353
- const DatePickerToolUI = makeAssistantToolUI<
354
- { prompt: string },
355
- { date: string }
356
- >({
357
- toolName: "selectDate",
358
- render: ({ args, result, addResult }) => {
359
- if (result) {
360
- return (
361
- <div className="rounded bg-green-50 p-3">
362
- ✅ Selected date: {new Date(result.date).toLocaleDateString()}
363
- </div>
364
- );
365
- }
366
-
367
- return (
368
- <div className="rounded border p-4">
369
- <p className="mb-3">{args.prompt}</p>
370
- <DatePicker
371
- onChange={(date) => {
372
- addResult({ date: date.toISOString() });
373
- }}
374
- />
375
- </div>
376
- );
377
- },
378
- });
379
- ```
380
-
381
- ### Multi-Step Interactions
382
-
383
- Build complex workflows with human-in-the-loop patterns for multi-step user interactions:
384
-
385
- ```tsx
386
- const DeleteProjectTool = makeAssistantTool({
387
- toolName: "deleteProject",
388
- parameters: z.object({
389
- projectId: z.string(),
390
- }),
391
- execute: async ({ projectId }, { human }) => {
392
- const response = await human({ action, details });
393
- if (!response.approved) throw new Error("Project deletion cancelled");
394
-
395
- await deleteProject(projectId);
396
- return { success: true };
397
- },
398
- });
399
-
400
- const ApprovalTool = makeAssistantTool({
401
- ...tool({
402
- description: "Request user approval for an action",
403
- parameters: z.object({
404
- action: z.string(),
405
- details: z.any(),
406
- }),
407
- execute: async ({ action, details }, { human }) => {
408
- // Request approval from user
409
- const response = await human({ action, details });
410
-
411
- return {
412
- approved: response.approved,
413
- reason: response.reason,
414
- };
415
- },
416
- }),
417
- toolName: "requestApproval",
418
- render: ({ args, result, interrupt, resume }) => {
419
- const [reason, setReason] = useState("");
420
-
421
- // Show result after approval/rejection
422
- if (result) {
423
- return (
424
- <div className={result.approved ? "text-green-600" : "text-red-600"}>
425
- {result.approved ? "✅ Approved" : `❌ Rejected: ${result.reason}`}
426
- </div>
427
- );
428
- }
429
-
430
- // Show approval UI when waiting for user input
431
- if (interrupt) {
432
- return (
433
- <div className="rounded border-2 border-yellow-400 p-4">
434
- <h4 className="font-bold">Approval Required</h4>
435
- <p className="my-2">{interrupt.payload.action}</p>
436
- <pre className="rounded bg-gray-100 p-2 text-sm">
437
- {JSON.stringify(interrupt.payload.details, null, 2)}
438
- </pre>
439
-
440
- <div className="mt-4 flex gap-2">
441
- <button
442
- onClick={() => resume({ approved: true })}
443
- className="rounded bg-green-500 px-4 py-2 text-white"
444
- >
445
- Approve
446
- </button>
447
- <button
448
- onClick={() => resume({ approved: false, reason })}
449
- className="rounded bg-red-500 px-4 py-2 text-white"
450
- >
451
- Reject
452
- </button>
453
- <input
454
- type="text"
455
- placeholder="Rejection reason..."
456
- value={reason}
457
- onChange={(e) => setReason(e.target.value)}
458
- className="flex-1 rounded border px-2"
459
- />
460
- </div>
461
- </div>
462
- );
463
- }
464
-
465
- return <div>Processing...</div>;
466
- },
467
- });
468
- ```
469
-
470
- <Callout type="tip">
471
- Use tool human input (`human()` / `resume()`) for workflows that need to
472
- pause tool execution and wait for user input. Use `addResult()` for "human
473
- tools" where the AI requests a tool call but the entire execution happens
474
- through user interaction.
475
- </Callout>
476
-
477
- ## Advanced Features
478
-
479
- ### Tool Status Handling
480
-
481
- The `status` prop provides detailed execution state:
482
-
483
- ```tsx
484
- render: ({ status, args }) => {
485
- switch (status.type) {
486
- case "running":
487
- return <LoadingState />;
488
-
489
- case "requires-action":
490
- return <UserInputRequired reason={status.reason} />;
491
-
492
- case "incomplete":
493
- if (status.reason === "cancelled") {
494
- return <div>Operation cancelled</div>;
495
- }
496
- if (status.reason === "error") {
497
- return <ErrorDisplay error={status.error} />;
498
- }
499
- return <div>Failed: {status.reason}</div>;
500
-
501
- case "complete":
502
- return <SuccessDisplay />;
503
- }
504
- };
505
- ```
506
-
507
- ### Deferred Rendering
508
-
509
- <Callout type="info">
510
- This section applies when the model **drives** the component through a tool call (args arrive incrementally and you want to wait for the final shape). If your backend or orchestrator pushes the component instead, prefer [Data-Part Generative UI](#data-part-generative-ui) with `makeAssistantDataUI`. Data parts arrive as terminal events, so the renderer only fires once with the final data, no deferred rendering needed.
511
- </Callout>
512
-
513
- Sometimes you want to capture a tool call's streaming arguments but only render the final UI once the call completes. This is useful when partial args would render misleading or jarring intermediate states (a chart that flashes through half-populated data), when the component is expensive to mount (heavy visualizations, embedded iframes, third-party widgets), or when the model controls *whether* the component appears at all.
514
-
515
- #### Inline at the end of streaming
516
-
517
- Return `null` from the tool UI's `render` until `status.type === "complete"`. The streaming args still arrive in `args` as the model emits them, you just ignore them until the call is done:
518
-
519
- ```tsx
520
- const ChartToolUI = makeAssistantToolUI<
521
- { title: string; series: number[] },
522
- void
523
- >({
524
- toolName: "renderChart",
525
- render: ({ args, status }) => {
526
- if (status.type !== "complete") return null;
527
- return <Chart title={args.title} data={args.series} />;
528
- },
529
- });
530
- ```
531
-
532
- The chart mounts once, with the final args, after streaming finishes. No re-renders during the stream.
533
-
534
- The same `render` shape works inside the [`Tools()`](/docs/guides/tools) toolkit's `render` field, with `useAssistantToolUI`, and with `MessagePrimitive.Parts`'s inline `tools.by_name` overrides. The deferred-rendering pattern applies regardless of how you registered the tool UI.
535
-
536
- #### Below the message body
537
-
538
- If the component should sit *outside* the message parts (for example, a card attached under the avatar block rather than inline with text), gate at the message level with [`AuiIf`](/docs/api-reference/primitives/assistant-if) and read `s.message.status`:
539
-
540
- ```tsx
541
- import { MessagePrimitive, AuiIf, useAuiState } from "@assistant-ui/react";
542
-
543
- function PostMessageCard() {
544
- const parts = useAuiState((s) => s.message.parts);
545
- const chartCall = parts.find(
546
- (p) => p.type === "tool-call" && p.toolName === "renderChart",
547
- );
548
- if (!chartCall) return null;
549
- return <Chart {...chartCall.args} />;
550
- }
551
-
552
- <MessagePrimitive.Root>
553
- <MessagePrimitive.Parts />
554
-
555
- <AuiIf
556
- condition={(s) =>
557
- s.message.role === "assistant" &&
558
- s.message.status?.type === "complete"
559
- }
560
- >
561
- <PostMessageCard />
562
- </AuiIf>
563
- </MessagePrimitive.Root>;
564
- ```
565
-
566
- The `AuiIf` predicate fires whenever the assistant state changes; children mount only when both checks pass. `PostMessageCard` then reads the captured tool-call part from `s.message.parts` and renders from its args.
567
-
568
- For the opposite pattern (showing partial data as it streams in), see [Field-Level Streaming State](#field-level-streaming-state) and [Partial Results & Streaming](#partial-results--streaming) below.
569
-
570
- ### Field-Level Streaming State
571
-
572
- Use `useToolArgsStatus` to react to per-field streaming state. The hook returns a `propStatus` map where each top-level key in the args object resolves from `"streaming"` to `"complete"` as the partial JSON arrives. Call it inside a tool-call message part context:
573
-
574
- ```tsx
575
- import { useToolArgsStatus } from "@assistant-ui/react";
576
-
577
- const FormToolUI = makeAssistantToolUI<{ email: string; phone: string }, unknown>({
578
- toolName: "submitForm",
579
- render: ({ args }) => {
580
- const { propStatus } = useToolArgsStatus<{ email: string; phone: string }>();
581
-
582
- return (
583
- <form className="space-y-4">
584
- <div>
585
- <input
586
- type="email"
587
- value={args.email ?? ""}
588
- className={propStatus.email === "streaming" ? "loading" : ""}
589
- disabled
590
- />
591
- </div>
592
-
593
- <div>
594
- <input
595
- type="tel"
596
- value={args.phone ?? ""}
597
- className={propStatus.phone === "streaming" ? "loading" : ""}
598
- disabled
599
- />
600
- </div>
601
- </form>
602
- );
603
- },
604
- });
605
- ```
606
-
607
- ### Partial Results & Streaming
608
-
609
- Display results as they stream in:
610
-
611
- ```tsx
612
- const AnalysisToolUI = makeAssistantToolUI<
613
- { data: string },
614
- { progress: number; insights: string[] }
615
- >({
616
- toolName: "analyzeData",
617
- render: ({ result, status }) => {
618
- const progress = result?.progress || 0;
619
- const insights = result?.insights || [];
620
-
621
- return (
622
- <div className="analysis-container">
623
- {status.type === "running" && (
624
- <div className="mb-4">
625
- <div className="mb-1 flex justify-between">
626
- <span>Analyzing...</span>
627
- <span>{progress}%</span>
628
- </div>
629
- <div className="w-full rounded bg-gray-200">
630
- <div
631
- className="h-2 rounded bg-blue-500"
632
- style={{ width: `${progress}%` }}
633
- />
634
- </div>
635
- </div>
636
- )}
637
-
638
- <div className="space-y-2">
639
- {insights.map((insight, i) => (
640
- <div key={i} className="rounded bg-gray-50 p-2">
641
- {insight}
642
- </div>
643
- ))}
644
- </div>
645
- </div>
646
- );
647
- },
648
- });
649
- ```
650
-
651
- ### Custom Tool Fallback
652
-
653
- For tools that have no dedicated UI, add the `ToolFallback` shadcn component to your project. See the [ToolFallback install guide](/docs/ui/tool-fallback) for setup instructions and the [ToolGroup guide](/docs/ui/tool-group) for grouping consecutive tool calls into a collapsible container.
654
-
655
- ## Execution Context
656
-
657
- Generative UI components have access to execution context through props:
658
-
659
- ```tsx
660
- type ToolCallMessagePartProps<TArgs, TResult> = {
661
- // Tool arguments
662
- args: TArgs;
663
- argsText: string; // JSON stringified args
664
-
665
- // Execution status
666
- status: ToolCallMessagePartStatus;
667
- isError?: boolean;
668
-
669
- // Tool result (may be partial during streaming)
670
- result?: TResult;
671
-
672
- // Tool metadata
673
- toolName: string;
674
- toolCallId: string;
675
-
676
- // Interactive callbacks
677
- addResult: (result: TResult | ToolResponse<TResult>) => void;
678
- resume: (payload: unknown) => void;
679
-
680
- // Interrupt state
681
- interrupt?: { type: "human"; payload: unknown }; // Payload from context.human()
682
-
683
- // Optional artifact data
684
- artifact?: unknown;
685
- };
686
- ```
687
-
688
- ### Human Input Handling
689
-
690
- When a tool calls `human()` during execution, the payload becomes available in the render function as `interrupt.payload`:
691
-
692
- ```tsx
693
- const ConfirmationToolUI = makeAssistantToolUI<
694
- { action: string },
695
- { confirmed: boolean }
696
- >({
697
- toolName: "confirmAction",
698
- render: ({ args, result, interrupt, resume }) => {
699
- // Tool is waiting for user input
700
- if (interrupt) {
701
- return (
702
- <div className="confirmation-dialog">
703
- <p>Confirm: {interrupt.payload.message}</p>
704
- <button onClick={() => resume(true)}>Yes</button>
705
- <button onClick={() => resume(false)}>No</button>
706
- </div>
707
- );
708
- }
709
-
710
- // Tool completed
711
- if (result) {
712
- return <div>Action {result.confirmed ? "confirmed" : "cancelled"}</div>;
713
- }
714
-
715
- return <div>Processing...</div>;
716
- },
717
- });
718
- ```
719
-
720
- Learn more about tool human input in the [Tools Guide](/docs/guides/tools#human-in-the-loop).
721
-
722
- ## Best Practices
723
-
724
- ### 1. Handle All Status States
725
-
726
- Always handle loading, error, and success states:
727
-
728
- ```tsx
729
- render: ({ status, result, args }) => {
730
- if (status.type === "running") return <Skeleton />;
731
- if (status.type === "incomplete") return <ErrorState />;
732
- if (!result) return null;
733
- return <ResultDisplay result={result} />;
734
- };
735
- ```
736
-
737
- ### 2. Provide Visual Feedback
738
-
739
- Use animations and transitions for better UX:
740
-
741
- ```tsx
742
- <div
743
- className={cn(
744
- "transition-all duration-300",
745
- status.type === "running" && "opacity-50",
746
- status.type === "complete" && "opacity-100",
747
- )}
748
- >
749
- {/* Tool UI content */}
750
- </div>
751
- ```
752
-
753
- ### 3. Make UIs Accessible
754
-
755
- Ensure keyboard navigation and screen reader support:
756
-
757
- ```tsx
758
- <button
759
- onClick={() => addResult(value)}
760
- aria-label="Confirm selection"
761
- className="focus:outline-none focus:ring-2"
762
- >
763
- Confirm
764
- </button>
765
- ```
766
-
767
- ### 4. Optimize Performance
768
-
769
- Use `useInlineRender` to prevent unnecessary re-renders:
770
-
771
- ```tsx
772
- useAssistantToolUI({
773
- toolName: "heavyComputation",
774
- render: useInlineRender(({ result }) => {
775
- // Expensive rendering logic
776
- return <ComplexVisualization data={result} />;
777
- }),
778
- });
779
- ```
780
-
781
- <Callout>
782
- Generative UI components are only displayed in the chat interface. The actual
783
- tool execution happens on the backend. This separation allows you to create
784
- rich, interactive experiences while keeping sensitive logic secure on the
785
- server.
786
- </Callout>
787
-
788
- ## Per-Property Streaming Status
789
-
790
- When rendering a tool UI, you can track which arguments have finished streaming using `useToolArgsStatus`. This must be used inside a tool-call message part context.
791
-
792
- ```tsx
793
- import { useToolArgsStatus } from "@assistant-ui/react";
794
-
795
- const WeatherUI = makeAssistantToolUI({
796
- toolName: "weather",
797
- render: ({ args }) => {
798
- const { status, propStatus } = useToolArgsStatus<{
799
- location: string;
800
- unit: string;
801
- }>();
802
-
803
- return (
804
- <div>
805
- <span className={propStatus.location === "streaming" ? "animate-pulse" : ""}>
806
- {args.location ?? "..."}
807
- </span>
808
- {status === "complete" && <WeatherChart data={args} />}
809
- </div>
810
- );
811
- },
812
- });
813
- ```
814
-
815
- `propStatus` maps each key to `"streaming"` | `"complete"` once the key appears in the partial JSON. Keys not yet present in the stream are absent from `propStatus`.
816
-
817
- ## Data-Part Generative UI
818
-
819
- Alongside tool-call rendering, assistant-ui supports a second generative UI mechanism based on `DataMessagePart`. Instead of attaching UI to a tool invocation, the backend (or the LangGraph graph) emits named data events that are appended as `{ type: "data", name, data }` parts on the parent assistant message.
820
-
821
- **When to choose which:**
822
-
823
- - **Tool UI**: the **model** decides what to render by calling a tool whose args become the component's data. Register the renderer via the [`Tools()`](/docs/guides/tools) toolkit's `render` field (recommended), or standalone with `makeAssistantToolUI` / `useAssistantToolUI` when the tool itself is defined elsewhere (backend, MCP, LangGraph). Args stream incrementally, so you observe partial state via `status` / `useToolArgsStatus` and may need [Deferred Rendering](#deferred-rendering) for components that should only mount with final data.
824
- - **Data UI** (`makeAssistantDataUI`): the **backend or orchestrator** decides what to render and pushes a named data event onto the assistant message. Data parts arrive as terminal events with no streaming partials, so the renderer naturally fires once with the final data.
825
-
826
- If you want a component to appear only after the message is complete and you control the backend, Data UI is usually the more direct fit; reach for Tool UI's deferred pattern when the model itself must drive the choice.
827
-
828
- Use `makeAssistantDataUI` to register a renderer for a named data part:
829
-
830
- ```tsx
831
- import { makeAssistantDataUI } from "@assistant-ui/react";
832
-
833
- type ChartProps = { series: number[]; title: string };
834
-
835
- export const ChartUI = makeAssistantDataUI<ChartProps>({
836
- name: "chart",
837
- render: ({ data }) => (
838
- <div>
839
- <h3>{data.title}</h3>
840
- <Chart series={data.series} />
841
- </div>
842
- ),
843
- });
844
- ```
845
-
846
- Mount `<ChartUI />` once inside the `AssistantRuntimeProvider` tree; it renders nothing itself and only registers the renderer.
847
-
848
- For LangGraph-specific patterns (emitting UI from a Python/TypeScript graph node via `push_ui_message` / `typedUi`, dynamic loading with `LoadExternalComponent`, and the `useLangGraphUIMessages` escape hatch), see [LangGraph Generative UI](/docs/runtimes/langgraph/generative-ui).
849
-
850
- A fallback renderer for unmatched data parts is available internally but `setFallbackDataUI` is not yet a public API.
851
-
852
- ## Related Guides
853
-
854
- - [Tools Guide](/docs/guides/tools) - Learn how to create and use tools with AI models
855
- - [Multi-Agent](/docs/guides/multi-agent) - Render sub-agent conversations inside tool call UIs
856
- - [Tool Fallback](/docs/ui/tool-fallback) - Default UI for tools without custom components
857
- - [API Reference](/docs/api-reference/primitives/message-part) - Detailed type definitions and component APIs
858
- - [Message Primitive](/docs/api-reference/primitives/message) - Complete Message component documentation