@assistant-ui/mcp-docs-server 0.1.28 → 0.1.30
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 +18 -10
- package/.docs/organized/code-examples/with-a2a.md +12 -24
- package/.docs/organized/code-examples/with-ag-ui.md +14 -11
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +12 -12
- package/.docs/organized/code-examples/with-artifacts.md +14 -12
- package/.docs/organized/code-examples/with-assistant-transport.md +13 -14
- package/.docs/organized/code-examples/with-chain-of-thought.md +11 -11
- package/.docs/organized/code-examples/with-cloud-standalone.md +17 -14
- package/.docs/organized/code-examples/with-cloud.md +12 -13
- package/.docs/organized/code-examples/with-custom-thread-list.md +12 -12
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +19 -14
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +15 -15
- package/.docs/organized/code-examples/with-expo.md +27 -23
- package/.docs/organized/code-examples/with-external-store.md +11 -11
- package/.docs/organized/code-examples/with-ffmpeg.md +19 -14
- package/.docs/organized/code-examples/with-generative-ui.md +11 -11
- package/.docs/organized/code-examples/with-google-adk.md +10 -10
- package/.docs/organized/code-examples/with-heat-graph.md +8 -8
- package/.docs/organized/code-examples/with-interactables.md +12 -27
- package/.docs/organized/code-examples/with-langchain.md +437 -0
- package/.docs/organized/code-examples/with-langgraph.md +20 -20
- package/.docs/organized/code-examples/with-livekit.md +59 -18
- package/.docs/organized/code-examples/with-opencode.md +2392 -0
- package/.docs/organized/code-examples/with-parent-id-grouping.md +12 -12
- package/.docs/organized/code-examples/with-react-hook-form.md +223 -151
- package/.docs/organized/code-examples/with-react-ink.md +3 -3
- package/.docs/organized/code-examples/with-react-router.md +15 -15
- package/.docs/organized/code-examples/with-store.md +11 -8
- package/.docs/organized/code-examples/with-tanstack.md +14 -14
- package/.docs/organized/code-examples/with-tap-runtime.md +13 -9
- package/.docs/raw/docs/(docs)/guides/mentions.mdx +248 -109
- package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +112 -92
- package/.docs/raw/docs/(docs)/guides/voice.mdx +10 -3
- package/.docs/raw/docs/(docs)/rtl.mdx +79 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +4 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +1 -1
- package/.docs/raw/docs/primitives/composer.mdx +94 -62
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +57 -0
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +49 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +39 -1
- package/.docs/raw/docs/runtimes/custom/local.mdx +65 -18
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +62 -0
- package/.docs/raw/docs/runtimes/langchain/comparison.mdx +60 -0
- package/.docs/raw/docs/runtimes/langchain/index.mdx +210 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +288 -60
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -4
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +199 -0
- package/.docs/raw/docs/ui/directive-text.mdx +113 -0
- package/.docs/raw/docs/ui/reasoning.mdx +13 -9
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +4 -4
- package/src/utils/logger.ts +1 -1
- package/.docs/raw/docs/ui/mention.mdx +0 -168
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Directive Text
|
|
3
|
+
description: Render mention directives as inline chips in user messages.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { DirectiveTextSample } from "@/components/docs/samples/directive-text";
|
|
7
|
+
|
|
8
|
+
<DirectiveTextSample />
|
|
9
|
+
|
|
10
|
+
`DirectiveText` parses the directive syntax written by [`ComposerTriggerPopover`](/docs/ui/composer-trigger-popover) (default: `:type[label]{name=id}`) and renders each segment as an inline chip. Use it as the `Text` component in user messages so the raw directive syntax never shows up.
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
<Steps>
|
|
15
|
+
<Step>
|
|
16
|
+
|
|
17
|
+
### Add `directive-text`
|
|
18
|
+
|
|
19
|
+
<InstallCommand shadcn={["directive-text"]} />
|
|
20
|
+
|
|
21
|
+
This adds `/components/assistant-ui/directive-text.tsx` with `DirectiveText` and the `createDirectiveText(formatter, options?)` factory.
|
|
22
|
+
|
|
23
|
+
</Step>
|
|
24
|
+
<Step>
|
|
25
|
+
|
|
26
|
+
### Use in user messages
|
|
27
|
+
|
|
28
|
+
Pass `DirectiveText` as the `Text` component in `MessagePrimitive.Parts`:
|
|
29
|
+
|
|
30
|
+
```tsx title="components/assistant-ui/thread.tsx"
|
|
31
|
+
import { DirectiveText } from "@/components/assistant-ui/directive-text";
|
|
32
|
+
|
|
33
|
+
const UserMessage = () => (
|
|
34
|
+
<MessagePrimitive.Root>
|
|
35
|
+
<MessagePrimitive.Parts components={{ Text: DirectiveText }} />
|
|
36
|
+
</MessagePrimitive.Root>
|
|
37
|
+
);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Keep your markdown renderer (e.g. `MarkdownText`) for assistant messages — assistants rarely emit directive syntax.
|
|
41
|
+
|
|
42
|
+
</Step>
|
|
43
|
+
</Steps>
|
|
44
|
+
|
|
45
|
+
## Icons per Directive Type
|
|
46
|
+
|
|
47
|
+
`DirectiveText` ships icon-free by default — every parsed segment renders as a plain label chip regardless of its `type`. To add icons, use the `createDirectiveText` factory and pass an `iconMap` that routes each `type` string to an icon component, plus an optional `fallbackIcon` for unmapped types:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { createDirectiveText } from "@/components/assistant-ui/directive-text";
|
|
51
|
+
import { unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
|
|
52
|
+
import { FileTextIcon, SparklesIcon, UserIcon, WrenchIcon } from "lucide-react";
|
|
53
|
+
|
|
54
|
+
const DirectiveTextWithIcons = createDirectiveText(
|
|
55
|
+
unstable_defaultDirectiveFormatter,
|
|
56
|
+
{
|
|
57
|
+
iconMap: {
|
|
58
|
+
tool: WrenchIcon,
|
|
59
|
+
user: UserIcon,
|
|
60
|
+
file: FileTextIcon,
|
|
61
|
+
},
|
|
62
|
+
fallbackIcon: SparklesIcon,
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
<MessagePrimitive.Parts components={{ Text: DirectiveTextWithIcons }} />;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
A matching `iconMap` / `fallbackIcon` option is accepted by [`ComposerTriggerPopover`](/docs/ui/composer-trigger-popover), where it routes `item.metadata.icon` strings instead of `type` — keeping icon configuration consistent across the composer and the rendered message.
|
|
70
|
+
|
|
71
|
+
## Custom Formatter
|
|
72
|
+
|
|
73
|
+
The default format is `:type[label]{name=id}`. For a different format, build a custom `Unstable_DirectiveFormatter` and wrap it with `createDirectiveText`:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import type { Unstable_DirectiveFormatter } from "@assistant-ui/core";
|
|
77
|
+
import { createDirectiveText } from "@/components/assistant-ui/directive-text";
|
|
78
|
+
|
|
79
|
+
const slashFormatter: Unstable_DirectiveFormatter = {
|
|
80
|
+
serialize: (item) => `/${item.id}`,
|
|
81
|
+
parse: (text) => {
|
|
82
|
+
/* return alternating text / mention segments */
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const SlashDirectiveText = createDirectiveText(slashFormatter);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Pass the **same formatter** to the composer trigger's `directive={{ formatter }}` (or `action={{ formatter }}`) so insertion and rendering stay consistent.
|
|
90
|
+
|
|
91
|
+
## Customizing the Chip
|
|
92
|
+
|
|
93
|
+
Because `directive-text.tsx` is copied into your project, you can also edit it directly — swap the chip styling, read `data-directive-id` to link to a detail page, or replace the chip wrapper entirely.
|
|
94
|
+
|
|
95
|
+
## API Reference
|
|
96
|
+
|
|
97
|
+
### `DirectiveText`
|
|
98
|
+
|
|
99
|
+
A `TextMessagePartComponent` that parses `:type[label]{name=id}` directives and renders them as inline chips. Uses the default formatter from `@assistant-ui/core` and renders chips without icons. For per-type icons, build a component with `createDirectiveText(formatter, { iconMap })`.
|
|
100
|
+
|
|
101
|
+
### `createDirectiveText(formatter, options?)`
|
|
102
|
+
|
|
103
|
+
Factory that returns a `TextMessagePartComponent` bound to a custom `Unstable_DirectiveFormatter`.
|
|
104
|
+
|
|
105
|
+
| Option | Type | Description |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
| `iconMap` | `Record<string, ComponentType<{ className?: string }>>` | Maps a directive segment's `type` to an icon rendered inside the chip |
|
|
108
|
+
| `fallbackIcon` | `ComponentType<{ className?: string }>` | Icon used when no `iconMap` entry matches. When neither option resolves, the chip renders without an icon. |
|
|
109
|
+
|
|
110
|
+
## Related
|
|
111
|
+
|
|
112
|
+
- [Composer Trigger Popover](/docs/ui/composer-trigger-popover) — the picker that inserts directives
|
|
113
|
+
- [Mentions guide](/docs/guides/mentions) — directive format, backend parsing
|
|
@@ -23,22 +23,26 @@ This adds a `/components/assistant-ui/reasoning.tsx` file to your project.
|
|
|
23
23
|
|
|
24
24
|
### Use in your application
|
|
25
25
|
|
|
26
|
-
Pass the `Reasoning` and `ReasoningGroup` components to
|
|
26
|
+
Pass the `Reasoning` and `ReasoningGroup` components to `MessagePrimitive.Parts` via the `components` prop. Using them together is the recommended default — `ReasoningGroup` wraps consecutive reasoning parts in a collapsible container for a smooth out-of-the-box UI.
|
|
27
27
|
|
|
28
|
-
```tsx title="/app/components/assistant-ui/thread.tsx"
|
|
28
|
+
```tsx title="/app/components/assistant-ui/thread.tsx"
|
|
29
29
|
import { MessagePrimitive } from "@assistant-ui/react";
|
|
30
|
-
import {
|
|
30
|
+
import { MarkdownText } from "@/components/assistant-ui/markdown-text";
|
|
31
|
+
import { ToolFallback } from "@/components/assistant-ui/tool-fallback";
|
|
32
|
+
import { Reasoning, ReasoningGroup } from "@/components/assistant-ui/reasoning"; // [!code ++]
|
|
31
33
|
|
|
32
34
|
const AssistantMessage: FC = () => {
|
|
33
35
|
return (
|
|
34
36
|
<MessagePrimitive.Root className="...">
|
|
35
37
|
<div className="...">
|
|
36
|
-
<MessagePrimitive.Parts
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
<MessagePrimitive.Parts
|
|
39
|
+
components={{
|
|
40
|
+
Text: MarkdownText,
|
|
41
|
+
Reasoning, // [!code ++]
|
|
42
|
+
ReasoningGroup, // [!code ++]
|
|
43
|
+
tools: { Fallback: ToolFallback },
|
|
40
44
|
}}
|
|
41
|
-
|
|
45
|
+
/>
|
|
42
46
|
</div>
|
|
43
47
|
<AssistantActionBar />
|
|
44
48
|
<BranchPicker className="..." />
|
|
@@ -57,7 +61,7 @@ The component consists of two parts:
|
|
|
57
61
|
1. `Reasoning`: Renders individual reasoning message part content (with markdown support)
|
|
58
62
|
2. `ReasoningGroup`: Wraps consecutive reasoning parts in a collapsible container
|
|
59
63
|
|
|
60
|
-
Consecutive reasoning parts are automatically grouped together by the `ReasoningGroup`
|
|
64
|
+
Consecutive reasoning parts are automatically grouped together by `ReasoningGroup`. We recommend using both together as the default — you can drop `ReasoningGroup` or build your own layout with the composable API below if you need more flexibility.
|
|
61
65
|
|
|
62
66
|
> When using the composable API, `Reasoning.Text` is a plain container. Add `<MarkdownText />` for markdown rendering.
|
|
63
67
|
|
package/dist/utils/logger.js
CHANGED
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/mcp-docs-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "MCP server for assistant-ui documentation and examples",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"zod": "^4.3.6"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^25.
|
|
40
|
+
"@types/node": "^25.6.0",
|
|
41
41
|
"tsx": "^4.21.0",
|
|
42
|
-
"vitest": "^4.1.
|
|
43
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
42
|
+
"vitest": "^4.1.5",
|
|
43
|
+
"@assistant-ui/x-buildutils": "0.0.6"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|
package/src/utils/logger.ts
CHANGED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Mention
|
|
3
|
-
description: Let users @-mention tools in the composer with a keyboard-navigable popover picker and inline chips.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## Getting Started
|
|
7
|
-
|
|
8
|
-
<Steps>
|
|
9
|
-
<Step>
|
|
10
|
-
|
|
11
|
-
### Add `composer-mention`
|
|
12
|
-
|
|
13
|
-
<InstallCommand shadcn={["composer-mention"]} />
|
|
14
|
-
|
|
15
|
-
This adds a `/components/assistant-ui/composer-mention.tsx` file with `ComposerMentionPopover`, `ComposerMentionRoot`, and `DirectiveText`.
|
|
16
|
-
|
|
17
|
-
</Step>
|
|
18
|
-
<Step>
|
|
19
|
-
|
|
20
|
-
### Wrap the Composer
|
|
21
|
-
|
|
22
|
-
Wrap your composer with `ComposerMentionPopover.Root` and add `<ComposerMentionPopover />` inside:
|
|
23
|
-
|
|
24
|
-
```tsx title="components/assistant-ui/thread.tsx" {1,7,10}
|
|
25
|
-
import { ComposerMentionPopover } from "@/components/assistant-ui/composer-mention";
|
|
26
|
-
|
|
27
|
-
const Composer = () => {
|
|
28
|
-
return (
|
|
29
|
-
<ComposerMentionPopover.Root>
|
|
30
|
-
<ComposerPrimitive.Root>
|
|
31
|
-
<ComposerPrimitive.Input placeholder="Type @ to mention a tool..." />
|
|
32
|
-
<ComposerPrimitive.Send />
|
|
33
|
-
<ComposerMentionPopover />
|
|
34
|
-
</ComposerPrimitive.Root>
|
|
35
|
-
</ComposerMentionPopover.Root>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
The popover automatically shows registered tools when the user types `@`.
|
|
41
|
-
|
|
42
|
-
</Step>
|
|
43
|
-
<Step>
|
|
44
|
-
|
|
45
|
-
### Render Mentions in User Messages
|
|
46
|
-
|
|
47
|
-
Use `DirectiveText` as the `Text` component for **user messages** so mention directives render as inline chips instead of raw `:tool[label]` syntax:
|
|
48
|
-
|
|
49
|
-
```tsx title="components/assistant-ui/thread.tsx" {1,8}
|
|
50
|
-
import { DirectiveText } from "@/components/assistant-ui/composer-mention";
|
|
51
|
-
|
|
52
|
-
const UserMessage = () => {
|
|
53
|
-
return (
|
|
54
|
-
<MessagePrimitive.Root>
|
|
55
|
-
<MessagePrimitive.Parts
|
|
56
|
-
components={{
|
|
57
|
-
Text: DirectiveText,
|
|
58
|
-
}}
|
|
59
|
-
/>
|
|
60
|
-
</MessagePrimitive.Root>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
<Callout>
|
|
66
|
-
`DirectiveText` renders plain text with mention chips. For assistant messages
|
|
67
|
-
that contain markdown, keep using your markdown renderer (e.g. `MarkdownText`).
|
|
68
|
-
</Callout>
|
|
69
|
-
|
|
70
|
-
</Step>
|
|
71
|
-
</Steps>
|
|
72
|
-
|
|
73
|
-
## With Lexical Rich Editor
|
|
74
|
-
|
|
75
|
-
For inline mention chips in the composer (not just the popover), use `LexicalComposerInput` from `@assistant-ui/react-lexical`:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
npm install @assistant-ui/react-lexical lexical @lexical/react
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Replace `ComposerPrimitive.Input` with `LexicalComposerInput`:
|
|
82
|
-
|
|
83
|
-
```tsx title="components/assistant-ui/thread.tsx" {1,8}
|
|
84
|
-
import { LexicalComposerInput } from "@assistant-ui/react-lexical";
|
|
85
|
-
|
|
86
|
-
const Composer = () => {
|
|
87
|
-
return (
|
|
88
|
-
<ComposerMentionPopover.Root>
|
|
89
|
-
<ComposerPrimitive.Root>
|
|
90
|
-
<LexicalComposerInput placeholder="Type @ to mention a tool..." />
|
|
91
|
-
<ComposerPrimitive.Send />
|
|
92
|
-
<ComposerMentionPopover />
|
|
93
|
-
</ComposerPrimitive.Root>
|
|
94
|
-
</ComposerMentionPopover.Root>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
`LexicalComposerInput` auto-wires to `MentionContext` — no extra props needed. Selected mentions appear as inline chips that are treated as atomic units (select, delete, undo as a whole).
|
|
100
|
-
|
|
101
|
-
## Custom Formatter
|
|
102
|
-
|
|
103
|
-
The default directive format is `:type[label]{name=id}`. To use a custom format, pass a `formatter` to both the mention root and the message renderer:
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
import { ComposerMentionPopover } from "@/components/assistant-ui/composer-mention";
|
|
107
|
-
import { createDirectiveText } from "@/components/assistant-ui/composer-mention";
|
|
108
|
-
|
|
109
|
-
const myFormatter = {
|
|
110
|
-
serialize: (item) => `@${item.id}`,
|
|
111
|
-
parse: (text) => [{ kind: "text", text }], // implement your parsing
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// In composer (textarea path):
|
|
115
|
-
<ComposerMentionPopover.Root formatter={myFormatter}>
|
|
116
|
-
...
|
|
117
|
-
</ComposerMentionPopover.Root>
|
|
118
|
-
|
|
119
|
-
// In composer (Lexical path — also pass formatter):
|
|
120
|
-
<ComposerMentionPopover.Root formatter={myFormatter}>
|
|
121
|
-
<ComposerPrimitive.Root>
|
|
122
|
-
<LexicalComposerInput formatter={myFormatter} />
|
|
123
|
-
...
|
|
124
|
-
</ComposerPrimitive.Root>
|
|
125
|
-
</ComposerMentionPopover.Root>
|
|
126
|
-
|
|
127
|
-
// In user messages:
|
|
128
|
-
const MyDirectiveText = createDirectiveText(myFormatter);
|
|
129
|
-
<MessagePrimitive.Parts components={{ Text: MyDirectiveText }} />
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Keyboard Navigation
|
|
133
|
-
|
|
134
|
-
The mention popover supports full keyboard navigation out of the box:
|
|
135
|
-
|
|
136
|
-
| Key | Action |
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| <Kbd>ArrowDown</Kbd> | Highlight next item |
|
|
139
|
-
| <Kbd>ArrowUp</Kbd> | Highlight previous item |
|
|
140
|
-
| <Kbd>Enter</Kbd> | Select highlighted item / drill into category |
|
|
141
|
-
| <Kbd>Escape</Kbd> | Close popover |
|
|
142
|
-
| <Kbd>Backspace</Kbd> | Go back to categories (when query is empty) |
|
|
143
|
-
|
|
144
|
-
## Components
|
|
145
|
-
|
|
146
|
-
### `ComposerMentionPopover.Root`
|
|
147
|
-
|
|
148
|
-
Wraps the composer with mention context and a tool mention adapter. Provides the `@`-trigger detection, keyboard navigation, and popover state.
|
|
149
|
-
|
|
150
|
-
| Prop | Type | Default | Description |
|
|
151
|
-
| --- | --- | --- | --- |
|
|
152
|
-
| `adapter` | `Unstable_MentionAdapter` | Tool adapter | Custom mention adapter |
|
|
153
|
-
| `trigger` | `string` | `"@"` | Character(s) that open the popover |
|
|
154
|
-
| `formatter` | `Unstable_DirectiveFormatter` | Default | Custom directive serializer/parser |
|
|
155
|
-
| `formatLabel` | `(name: string) => string` | Title case | Format tool names for display |
|
|
156
|
-
| `categoryLabel` | `string` | `"Tools"` | Label for the tools category |
|
|
157
|
-
|
|
158
|
-
### `ComposerMentionPopover`
|
|
159
|
-
|
|
160
|
-
Pre-built popover containing categories and items lists. Only renders when the `@` trigger is active.
|
|
161
|
-
|
|
162
|
-
### `DirectiveText`
|
|
163
|
-
|
|
164
|
-
A `TextMessagePartComponent` that parses `:type[label]{name=id}` directives and renders them as styled inline chips.
|
|
165
|
-
|
|
166
|
-
### `createDirectiveText(formatter)`
|
|
167
|
-
|
|
168
|
-
Factory function that creates a `TextMessagePartComponent` using a custom `Unstable_DirectiveFormatter`.
|