Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Chat): harden chat components — scroll button, drawer animation, status, bubbles, stories (#1245)

Cindy Zhang16098b5a3161
diff --git a/apps/storybook/stories/Chat.stories.tsx b/apps/storybook/stories/Chat.stories.tsx
index 226bb2ca61..8182514d95 100644
--- a/apps/storybook/stories/Chat.stories.tsx
+++ b/apps/storybook/stories/Chat.stories.tsx
@@ -25,8 +25,8 @@ const meta: Meta<typeof XDSChatMessageList> = {
};
export default meta;
-export const Minimal: StoryObj = {
- name: 'Minimal',
+export const Default: StoryObj = {
+ name: 'Default',
render: () => (
<div style={{height: 500, display: 'flex', flexDirection: 'column'}}>
<XDSChatMessageList>
@@ -64,8 +64,8 @@ Both work great.`}</XDSMarkdown>
),
};
-export const Standard: StoryObj = {
- name: 'Standard',
+export const Detailed: StoryObj = {
+ name: 'Detailed',
render: () => (
<div style={{height: 500, display: 'flex', flexDirection: 'column'}}>
<XDSChatMessageList>
@@ -112,9 +112,7 @@ export const Maximal: StoryObj = {
sender="assistant"
name="Navi"
avatar={<XDSAvatar name="Navi" size="small" />}>
- <XDSChatMessageBubble>
- <XDSMarkdown density="compact">{`Good afternoon! I've been looking at the **NDS gap analysis** and have the priority list ready.`}</XDSMarkdown>
- </XDSChatMessageBubble>
+ <XDSMarkdown density="compact">{`Good afternoon! I've been looking at the **NDS gap analysis** and have the priority list ready.`}</XDSMarkdown>
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-03-15T14:30:00" format="time" />
@@ -137,13 +135,11 @@ export const Maximal: StoryObj = {
sender="assistant"
name="Navi"
avatar={<XDSAvatar name="Navi" size="small" />}>
- <XDSChatMessageBubble>
- <XDSMarkdown density="compact">{`Chat components — **1,847 usages** across 42 apps.
+ <XDSMarkdown density="compact">{`Chat components — **1,847 usages** across 42 apps.
1. \`ChatBubble\` — 1,847 usages
2. \`ChatTypingIndicator\` — 463 usages
3. \`TextShimmer\` — 706 usages`}</XDSMarkdown>
- </XDSChatMessageBubble>
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-03-15T14:31:30" format="time" />
@@ -255,15 +251,13 @@ export const DensityComparison: StoryObj = {
<XDSChatMessage
sender="assistant"
avatar={<XDSAvatar name="Navi" size={avatarSize[density]} />}>
- <XDSChatMessageBubble>
- <XDSMarkdown density="compact">{`Density controls **spacing** at every level:
+ <XDSMarkdown density="compact">{`Density controls **spacing** at every level:
- **Gap** between messages
- **Padding** inside bubbles
- **Gap** between child elements
This is the **${density}** density. ${density === 'compact' ? 'Great for sidebars and panels where space is limited.' : density === 'spacious' ? 'Ideal for long-form reading where breathing room helps comprehension.' : 'The default — works well for most full-page chat interfaces.'}`}</XDSMarkdown>
- </XDSChatMessageBubble>
</XDSChatMessage>
<XDSChatMessage sender="user">
<XDSChatMessageBubble>Makes sense, thanks!</XDSChatMessageBubble>
@@ -294,7 +288,7 @@ export const SystemMessages: StoryObj = {
<XDSChatMessage
sender="assistant"
avatar={<XDSAvatar name="Navi" size="small" />}>
- <XDSChatMessageBubble>Good morning!</XDSChatMessageBubble>
+ <XDSMarkdown density="compact">Good morning!</XDSMarkdown>
</XDSChatMessage>
<XDSChatSystemMessage>Conversation started</XDSChatSystemMessage>
<XDSChatMessage sender="user">
@@ -347,7 +341,7 @@ export const AutoScroll: StoryObj = {
</XDSChatMessage>
) : (
<XDSChatMessage key={msg.id} sender="assistant">
- <XDSChatMessageBubble>{msg.text}</XDSChatMessageBubble>
+ <XDSMarkdown density="compact">{msg.text}</XDSMarkdown>
</XDSChatMessage>
),
)}
@@ -572,10 +566,10 @@ For server state, use a library like **TanStack Query** or **SWR**.`}</XDSMarkdo
sender="assistant"
name="Navi"
avatar={<XDSAvatar name="Navi" size="small" />}>
- <XDSChatMessageBubble>
+ <XDSMarkdown density="compact">
Avoid global state managers unless you have a genuine need for
cross-cutting state. Most apps are over-engineered in this area.
- </XDSChatMessageBubble>
+ </XDSMarkdown>
<XDSChatMessageMetadata
timestamp={
<XDSTimestamp value="2026-03-15T14:36:00" format="time" />
diff --git a/apps/storybook/stories/ChatComposer.stories.tsx b/apps/storybook/stories/ChatComposer.stories.tsx
index 334331a874..0fad86157e 100644
--- a/apps/storybook/stories/ChatComposer.stories.tsx
+++ b/apps/storybook/stories/ChatComposer.stories.tsx
@@ -120,6 +120,7 @@ export const WithFooterActions: Story = {
variant="ghost"
size="md"
icon={MicIcon}
+ isIconOnly
iconOnly
isIconOnly
/>
@@ -145,6 +146,7 @@ export const WithAttachments: Story = {
variant="ghost"
size="sm"
icon={PaperclipIcon}
+ isIconOnly
iconOnly
isIconOnly
/>
@@ -182,6 +184,7 @@ export const FullFeatured: Story = {
variant="ghost"
size="sm"
icon={AtSignIcon}
+ isIconOnly
iconOnly
isIconOnly
/>
@@ -190,6 +193,7 @@ export const FullFeatured: Story = {
variant="ghost"
size="sm"
icon={PaperclipIcon}
+ isIconOnly
iconOnly
isIconOnly
/>
@@ -210,6 +214,7 @@ export const FullFeatured: Story = {
variant="ghost"
size="md"
icon={MicIcon}
+ isIconOnly
iconOnly
isIconOnly
/>
@@ -262,22 +267,15 @@ export const WithError: Story = {
),
};
-/** With attachments and status on top */
-export const WithAttachmentsAndStatusTop: Story = {
+/** With status on top */
+export const WithStatusTop: Story = {
render: () => (
<XDSChatComposer
onSubmit={value => console.log('Submit:', value)}
statusPosition="top"
- attachments={
- <XDSChatComposerAttachments count={3}>
- <XDSToken label="report.pdf" onRemove={() => {}} />
- <XDSToken label="data.csv" onRemove={() => {}} />
- <XDSToken label="notes.docx" onRemove={() => {}} />
- </XDSChatComposerAttachments>
- }
status={{
type: 'warning',
- message: 'Large files may take longer to process.',
+ message: 'Context window is 90% full.',
}}
/>
),
diff --git a/apps/storybook/stories/ChatComposition.stories.tsx b/apps/storybook/stories/ChatComposition.stories.tsx
new file mode 100644
index 0000000000..dea8c9f8dd
--- /dev/null
+++ b/apps/storybook/stories/ChatComposition.stories.tsx
@@ -0,0 +1,527 @@
+import type {Meta, StoryObj} from '@storybook/react';
+import {
+ XDSChatMessageList,
+ XDSChatMessage,
+ XDSChatMessageBubble,
+ XDSChatSystemMessage,
+ XDSChatComposer,
+ XDSChatComposerAttachments,
+ XDSChatComposerInput,
+ XDSChatMessageTokenizedText,
+ XDSChatToolCalls,
+ type XDSChatComposerInputHandle,
+ type XDSChatComposerTrigger,
+ type XDSChatToolCallItem,
+} from '@xds/core/Chat';
+import {XDSMarkdown} from '@xds/core/Markdown';
+import {XDSToken} from '@xds/core/Token';
+import {XDSButton} from '@xds/core/Button';
+import {XDSCodeBlock} from '@xds/core/CodeBlock';
+import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {useXDSTooltip} from '@xds/core/Tooltip';
+import {createStaticSource} from '@xds/core/Typeahead';
+import {useState, useCallback, useRef} from 'react';
+
+const meta: Meta = {
+ title: 'Chat/Compositions',
+ tags: ['autodocs'],
+ parameters: {layout: 'fullscreen'},
+};
+export default meta;
+
+// Icons
+const PaperclipIcon = (
+ <svg
+ width="1em"
+ height="1em"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round">
+ <path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" />
+ </svg>
+);
+const AtSignIcon = (
+ <svg
+ width="1em"
+ height="1em"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round">
+ <circle cx="12" cy="12" r="4" />
+ <path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8" />
+ </svg>
+);
+const MicIcon = (
+ <svg
+ width="1em"
+ height="1em"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round">
+ <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
+ <path d="M19 10v2a7 7 0 0 1-14 0v-2" />
+ <line x1="12" x2="12" y1="19" y2="22" />
+ </svg>
+);
+
+// Data
+const CONTACTS = [
+ {id: 'cindy', label: 'Cindy Zhang'},
+ {id: 'alex', label: 'Alex Rivera'},
+ {id: 'sam', label: 'Sam Chen'},
+ {id: 'navi', label: 'Navi'},
+];
+const COMMANDS = [
+ {id: 'summarize', label: 'summarize'},
+ {id: 'search', label: 'search'},
+ {id: 'explain', label: 'explain'},
+];
+
+type Message =
+ | {id: number; role: 'user'; text: string; files?: string[]}
+ | {
+ id: number;
+ role: 'assistant';
+ text: string;
+ toolCalls?: XDSChatToolCallItem[];
+ isStreaming?: boolean;
+ }
+ | {id: number; role: 'system'; text: string};
+
+const SEED_MESSAGES: Message[] = [
+ {id: 1, role: 'system', text: 'Today'},
+ {
+ id: 2,
+ role: 'user',
+ text: 'Can you review the Button component and fix the focus ring?',
+ },
+ {
+ id: 3,
+ role: 'assistant',
+ text: "I'll read the Button component and check the focus styles.",
+ toolCalls: [
+ {
+ key: '1',
+ name: 'read',
+ target: 'XDSButton.tsx',
+ status: 'complete',
+ duration: '45ms',
+ node: 'xds',
+ },
+ {
+ key: '2',
+ name: 'edit',
+ target: 'XDSButton.tsx',
+ status: 'complete',
+ duration: '120ms',
+ node: 'xds',
+ additions: 8,
+ deletions: 2,
+ resultDetail: (
+ <XDSCodeBlock
+ code={`:focus-visible {\n outline: 2px solid var(--color-ring-focus);\n outline-offset: 2px;\n}`}
+ language="css"
+ />
+ ),
+ },
+ {
+ key: '3',
+ name: 'bash',
+ target: 'yarn test',
+ status: 'complete',
+ duration: '6.1s',
+ node: 'xds',
+ resultDetail: (
+ <XDSCodeBlock
+ code={`$ yarn test\n✓ 24 tests passed (3 suites)`}
+ language="bash"
+ />
+ ),
+ },
+ ],
+ },
+ {
+ id: 4,
+ role: 'assistant',
+ text: "Added a `:focus-visible` style with a 2px solid outline and 2px offset. All 24 Button tests pass.\n\n```css\n:focus-visible {\n outline: 2px solid var(--color-ring-focus);\n outline-offset: 2px;\n}\n```\n\nHere's the test breakdown:\n\n| Suite | Tests | Duration | Status |\n|-------|-------|----------|--------|\n| XDSButton.test.tsx | 18 | 1.2s | ✓ Pass |\n| XDSButton.a11y.test.tsx | 4 | 0.8s | ✓ Pass |\n| XDSButton.snapshot.test.tsx | 2 | 0.3s | ✓ Pass |\n\nThe focus ring meets **WCAG 2.4.7** requirements and uses the theme's focus color token.",
+ },
+ {id: 5, role: 'user', text: 'Nice, can you also check the Card component?'},
+];
+
+/** Full AI chat — message list + composer with streaming, tool calls, triggers, attachments, and interactive modals */
+export const FullAIChat: StoryObj = {
+ name: 'Full AI Chat',
+ render: () => {
+ const [messages, setMessages] = useState<Message[]>(SEED_MESSAGES);
+ const [files, setFiles] = useState<string[]>([]);
+ const [isStreaming, setIsStreaming] = useState(false);
+ const streamRef = useRef<ReturnType<typeof setInterval>>(undefined);
+ const inputRef = useRef<XDSChatComposerInputHandle>(null);
+ const contextTooltip = useXDSTooltip({placement: 'above'});
+
+ // Token configs for rendering mentions in message bubbles
+ const mentionTokens = CONTACTS.map(c => ({
+ pattern: `@${c.id}`,
+ label: `@${c.label}`,
+ variant: 'blue' as const,
+ }));
+
+ const triggers: XDSChatComposerTrigger[] = [
+ {
+ character: '@',
+ searchSource: createStaticSource(CONTACTS),
+ onSelect: item => ({
+ value: `@${item.id}`,
+ label: `@${item.label}`,
+ variant: 'blue' as const,
+ }),
+ },
+ {
+ character: '/',
+ searchSource: createStaticSource(COMMANDS),
+ onSelect: item => `/${item.label} `,
+ },
+ ];
+
+ // Simulates: stream intro text → run tool calls → stream result text
+ const streamResponse = useCallback(
+ (
+ introText: string,
+ resultText: string,
+ toolCalls?: XDSChatToolCallItem[],
+ ) => {
+ const msgId = Date.now();
+ setIsStreaming(true);
+
+ // Start with empty message
+ setMessages(prev => [
+ ...prev,
+ {
+ id: msgId,
+ role: 'assistant',
+ text: '',
+ isStreaming: true,
+ },
+ ]);
+
+ // Phase 1: stream intro text
+ let i = 0;
+ streamRef.current = setInterval(() => {
+ i += 2 + Math.floor(Math.random() * 4);
+ if (i >= introText.length) {
+ clearInterval(streamRef.current);
+ setMessages(prev =>
+ prev.map(m => (m.id === msgId ? {...m, text: introText} : m)),
+ );
+
+ // Phase 2: tool calls appear as running
+ if (toolCalls) {
+ setTimeout(() => {
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId && m.role === 'assistant'
+ ? {
+ ...m,
+ toolCalls: toolCalls.map(tc => ({
+ ...tc,
+ status: 'running' as const,
+ duration: undefined,
+ })),
+ }
+ : m,
+ ),
+ );
+
+ // Phase 2b: tool calls complete
+ setTimeout(() => {
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId && m.role === 'assistant'
+ ? {...m, toolCalls}
+ : m,
+ ),
+ );
+
+ // Phase 3: stream result text
+ setTimeout(() => {
+ let j = 0;
+ const fullText = introText + '\n\n' + resultText;
+ streamRef.current = setInterval(() => {
+ j += 3 + Math.floor(Math.random() * 5);
+ const end = introText.length + 2 + j;
+ if (end >= fullText.length) {
+ clearInterval(streamRef.current);
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId
+ ? {...m, text: fullText, isStreaming: false}
+ : m,
+ ),
+ );
+ setIsStreaming(false);
+ return;
+ }
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId
+ ? {...m, text: fullText.slice(0, end)}
+ : m,
+ ),
+ );
+ }, 30);
+ }, 300);
+ }, 1800);
+ }, 400);
+ } else {
+ // No tool calls — just finish
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId ? {...m, isStreaming: false} : m,
+ ),
+ );
+ setIsStreaming(false);
+ }
+ return;
+ }
+ setMessages(prev =>
+ prev.map(m =>
+ m.id === msgId ? {...m, text: introText.slice(0, i)} : m,
+ ),
+ );
+ }, 30);
+ },
+ [],
+ );
+
+ const handleSubmit = useCallback(
+ (value: string) => {
+ setMessages(prev => [
+ ...prev,
+ {
+ id: Date.now(),
+ role: 'user',
+ text: value,
+ files: files.length ? [...files] : undefined,
+ },
+ ]);
+ setFiles([]);
+ setTimeout(() => {
+ streamResponse(
+ "I'll check the Card component for the same issue.",
+ 'The border radius was hardcoded. I replaced it with the theme token:\n\n```css\n/* before */\nborder-radius: 12px;\n\n/* after */\nborder-radius: var(--radius-element);\n```\n\nCards now adapt across themes. All tests pass.',
+ [
+ {
+ key: 'r1',
+ name: 'read',
+ target: 'XDSCard.tsx',
+ status: 'complete',
+ duration: '35ms',
+ node: 'xds',
+ },
+ {
+ key: 'e1',
+ name: 'edit',
+ target: 'XDSCard.tsx',
+ status: 'complete',
+ duration: '90ms',
+ node: 'xds',
+ additions: 1,
+ deletions: 1,
+ },
+ {
+ key: 't1',
+ name: 'bash',
+ target: 'yarn test --filter Card',
+ status: 'complete',
+ duration: '3.2s',
+ node: 'xds',
+ },
+ ],
+ );
+ }, 800);
+ },
+ [files, streamResponse],
+ );
+
+ const handleStop = useCallback(() => {
+ clearInterval(streamRef.current);
+ setIsStreaming(false);
+ setMessages(prev =>
+ prev.map(m =>
+ m.role === 'assistant' && m.isStreaming
+ ? {...m, isStreaming: false}
+ : m,
+ ),
+ );
+ }, []);
+
+ return (
+ <>
+ <div
+ style={{
+ maxWidth: 800,
+ margin: '0 auto',
+ paddingBottom: 120,
+ }}>
+ <XDSChatMessageList>
+ {messages.map(msg => {
+ if (msg.role === 'system') {
+ return (
+ <XDSChatSystemMessage key={msg.id} variant="divider">
+ {msg.text}
+ </XDSChatSystemMessage>
+ );
+ }
+ if (msg.role === 'user') {
+ return (
+ <XDSChatMessage key={msg.id} sender="user">
+ {msg.files && (
+ <XDSChatComposerAttachments>
+ {msg.files.map(f => (
+ <XDSToken key={f} label={f} />
+ ))}
+ </XDSChatComposerAttachments>
+ )}
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText tokens={mentionTokens}>
+ {msg.text}
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ );
+ }
+ return (
+ <XDSChatMessage key={msg.id} sender="assistant">
+ {msg.text && (
+ <XDSMarkdown density="compact">{msg.text}</XDSMarkdown>
+ )}
+ {msg.toolCalls && msg.toolCalls.length > 0 && (
+ <XDSChatToolCalls calls={msg.toolCalls ?? []} />
+ )}
+ </XDSChatMessage>
+ );
+ })}
+ </XDSChatMessageList>
+ </div>
+
+ {/* Frosted glass layer — sits behind the composer */}
+ <div
+ style={{
+ position: 'fixed',
+ bottom: 0,
+ left: 0,
+ right: 0,
+ height: 120,
+ pointerEvents: 'none',
+ backdropFilter: 'blur(12px)',
+ WebkitBackdropFilter: 'blur(12px)',
+ maskImage: 'linear-gradient(to bottom, transparent, black 48px)',
+ WebkitMaskImage:
+ 'linear-gradient(to bottom, transparent, black 48px)',
+ }}
+ />
+ {/* Composer dock */}
+ <div
+ style={{
+ position: 'fixed',
+ bottom: 0,
+ left: 0,
+ right: 0,
+ padding: '0 16px 12px',
+ }}>
+ <div style={{maxWidth: 800, margin: '0 auto'}}>
+ <XDSChatComposer
+ onSubmit={handleSubmit}
+ onStop={handleStop}
+ isStreaming={isStreaming}
+ attachments={
+ files.length > 0 ? (
+ <XDSChatComposerAttachments>
+ {files.map(f => (
+ <XDSToken
+ key={f}
+ label={f}
+ onRemove={() =>
+ setFiles(prev => prev.filter(x => x !== f))
+ }
+ />
+ ))}
+ </XDSChatComposerAttachments>
+ ) : undefined
+ }
+ headerActions={
+ <>
+ <XDSButton
+ label="Mention"
+ variant="ghost"
+ size="sm"
+ icon={AtSignIcon}
+ isIconOnly
+ onClick={() => {
+ inputRef.current?.focus();
+ inputRef.current?.insertText('@');
+ }}
+ />
+ <XDSButton
+ label="Attach"
+ variant="ghost"
+ size="sm"
+ icon={PaperclipIcon}
+ isIconOnly
+ onClick={() =>
+ setFiles(prev => [...prev, `file-${prev.length + 1}.tsx`])
+ }
+ />
+ </>
+ }
+ headerContext={
+ <>
+ <div
+ ref={contextTooltip.ref}
+ aria-describedby={contextTooltip.describedBy}
+ style={{paddingInlineEnd: 8}}>
+ <XDSProgressBar
+ label="Context"
+ value={12}
+ variant="neutral"
+ isLabelHidden
+ />
+ </div>
+ {contextTooltip.renderTooltip('3k / 100k tokens used')}
+ </>
+ }
+ input={
+ <XDSChatComposerInput
+ ref={inputRef}
+ triggers={triggers}
+ placeholder="Ask about the codebase..."
+ />
+ }
+ footerActions={
+ <XDSButton label="Claude Opus" variant="ghost" size="md" />
+ }
+ sendActions={
+ <XDSButton
+ label="Microphone"
+ variant="ghost"
+ size="md"
+ icon={MicIcon}
+ isIconOnly
+ />
+ }
+ />
+ </div>
+ </div>
+ </>
+ );
+ },
+};
diff --git a/apps/storybook/stories/ChatReasoning.stories.tsx b/apps/storybook/stories/ChatReasoning.stories.tsx
index 534ed56fea..0e01c137a1 100644
--- a/apps/storybook/stories/ChatReasoning.stories.tsx
+++ b/apps/storybook/stories/ChatReasoning.stories.tsx
@@ -3,14 +3,14 @@ import {
XDSChatMessageList,
XDSChatMessage,
XDSChatMessageBubble,
- XDSChatReasoning,
} from '@xds/core/Chat';
+import {XDSChatReasoning} from '@xds/lab';
import {XDSAvatar} from '@xds/core/Avatar';
import {XDSMarkdown} from '@xds/core/Markdown';
import {useState, useEffect} from 'react';
const meta: Meta = {
- title: 'Chat/XDSChatReasoning',
+ title: 'Lab/XDSChatReasoning',
component: XDSChatReasoning,
tags: ['autodocs'],
parameters: {
@@ -31,8 +31,8 @@ export const Collapsed: StoryObj = {
render: () => (
<XDSChatReasoning duration="12s">
Let me work through the constraints systematically. The farmer has 3
- fields and rotates wheat, corn, soy. No same crop in adjacent fields
- and no same crop in the same field two years in a row...
+ fields and rotates wheat, corn, soy. No same crop in adjacent fields and
+ no same crop in the same field two years in a row...
</XDSChatReasoning>
),
};
diff --git a/apps/storybook/stories/ChatTokenizedText.stories.tsx b/apps/storybook/stories/ChatTokenizedText.stories.tsx
new file mode 100644
index 0000000000..c5d33faf20
--- /dev/null
+++ b/apps/storybook/stories/ChatTokenizedText.stories.tsx
@@ -0,0 +1,96 @@
+import type {Meta, StoryObj} from '@storybook/react';
+import {XDSChatMessageTokenizedText} from '@xds/core/Chat';
+import {XDSChatMessage, XDSChatMessageBubble} from '@xds/core/Chat';
+
+const meta: Meta<typeof XDSChatMessageTokenizedText> = {
+ title: 'Chat/XDSChatMessageTokenizedText',
+ component: XDSChatMessageTokenizedText,
+ tags: ['autodocs'],
+ parameters: {layout: 'centered'},
+ decorators: [
+ Story => (
+ <div style={{width: 500, padding: 40}}>
+ <Story />
+ </div>
+ ),
+ ],
+};
+export default meta;
+
+type Story = StoryObj<typeof XDSChatMessageTokenizedText>;
+
+const mentionTokens = [
+ {pattern: '@cindy', label: '@Cindy Zhang', variant: 'blue' as const},
+ {pattern: '@navi', label: '@Navi', variant: 'blue' as const},
+ {pattern: '@alex', label: '@Alex Rivera', variant: 'blue' as const},
+];
+
+/** Single mention token */
+export const SingleToken: Story = {
+ render: () => (
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText tokens={mentionTokens}>
+ Hey @cindy can you review this?
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ ),
+};
+
+/** Multiple mentions in one message */
+export const MultipleTokens: Story = {
+ render: () => (
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText tokens={mentionTokens}>
+ @cindy and @alex can @navi help with the review?
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ ),
+};
+
+/** No tokens — renders as plain text */
+export const PlainText: Story = {
+ render: () => (
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText>
+ Just a regular message with no mentions.
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ ),
+};
+
+/** Tokens with different variants */
+export const MixedVariants: Story = {
+ render: () => (
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText
+ tokens={[
+ {pattern: '@cindy', label: '@Cindy', variant: 'blue'},
+ {pattern: '#bug', label: '#bug', variant: 'red'},
+ {pattern: '#feat', label: '#feature', variant: 'green'},
+ ]}>
+ @cindy filed #bug and #feat for the sprint
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ ),
+};
+
+/** Token at start and end of message */
+export const TokensAtEdges: Story = {
+ render: () => (
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble>
+ <XDSChatMessageTokenizedText tokens={mentionTokens}>
+ @cindy this is for @navi
+ </XDSChatMessageTokenizedText>
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+ ),
+};
diff --git a/apps/storybook/stories/ChatToolCalls.stories.tsx b/apps/storybook/stories/ChatToolCalls.stories.tsx
index bbd5cf469a..9f7a8b3a95 100644
--- a/apps/storybook/stories/ChatToolCalls.stories.tsx
+++ b/apps/storybook/stories/ChatToolCalls.stories.tsx
@@ -1,10 +1,7 @@
import type {Meta, StoryObj} from '@storybook/react';
import {XDSChatToolCalls, type XDSChatToolCallItem} from '@xds/core/Chat';
import {useState, useCallback} from 'react';
-import {useXDSImperativeDialog} from '@xds/core/Dialog';
import {XDSCodeBlock} from '@xds/core/CodeBlock';
-import {XDSBanner} from '@xds/core/Banner';
-import {XDSVStack} from '@xds/core/Stack';
const meta: Meta<typeof XDSChatToolCalls> = {
title: 'Chat/XDSChatToolCalls',
@@ -34,7 +31,12 @@ export const SingleCall: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'git status', status: 'complete', duration: '1.2s'},
+ {
+ name: 'bash',
+ target: 'git status',
+ status: 'complete',
+ duration: '1.2s',
+ },
]}
/>
),
@@ -45,9 +47,26 @@ export const MultipleCalls: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'git diff --stat', status: 'complete', duration: '340ms'},
- {name: 'read', label: 'src/Button.tsx', status: 'complete', duration: '45ms'},
- {name: 'edit', label: 'src/Button.tsx', status: 'complete', duration: '120ms', stats: {additions: 12, deletions: 3}},
+ {
+ name: 'bash',
+ target: 'git diff --stat',
+ status: 'complete',
+ duration: '340ms',
+ },
+ {
+ name: 'read',
+ target: 'src/Button.tsx',
+ status: 'complete',
+ duration: '45ms',
+ },
+ {
+ name: 'edit',
+ target: 'src/Button.tsx',
+ status: 'complete',
+ duration: '120ms',
+ additions: 12,
+ deletions: 3,
+ },
]}
/>
),
@@ -58,10 +77,33 @@ export const WithNodes: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'yarn test', status: 'complete', duration: '4.2s', node: 'cli:devvm'},
- {name: 'bash', label: 'yarn build', status: 'complete', duration: '12s', node: 'cli:devvm'},
- {name: 'read', label: 'README.md', status: 'complete', duration: '30ms', node: 'workspace'},
- {name: 'web_search', label: 'CSS anchor positioning', status: 'complete', duration: '1.8s'},
+ {
+ name: 'bash',
+ target: 'yarn test',
+ status: 'complete',
+ duration: '4.2s',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'bash',
+ target: 'yarn build',
+ status: 'complete',
+ duration: '12s',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'read',
+ target: 'README.md',
+ status: 'complete',
+ duration: '30ms',
+ node: 'workspace',
+ },
+ {
+ name: 'web_search',
+ target: 'CSS anchor positioning',
+ status: 'complete',
+ duration: '1.8s',
+ },
]}
/>
),
@@ -72,9 +114,31 @@ export const WithStats: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'edit', label: 'XDSButton.tsx', status: 'complete', duration: '85ms', node: 'cli:devvm', stats: {additions: 24, deletions: 8}},
- {name: 'edit', label: 'XDSButton.test.tsx', status: 'complete', duration: '60ms', node: 'cli:devvm', stats: {additions: 45}},
- {name: 'bash', label: 'grep -r "radius"', status: 'complete', duration: '200ms', node: 'cli:devvm', stats: {matches: 14, files: 6}},
+ {
+ name: 'edit',
+ target: 'XDSButton.tsx',
+ status: 'complete',
+ duration: '85ms',
+ node: 'cli:devvm',
+ additions: 24,
+ deletions: 8,
+ },
+ {
+ name: 'edit',
+ target: 'XDSButton.test.tsx',
+ status: 'complete',
+ duration: '60ms',
+ node: 'cli:devvm',
+ additions: 45,
+ },
+ {
+ name: 'bash',
+ target: 'grep -r "radius"',
+ status: 'complete',
+ duration: '200ms',
+ node: 'cli:devvm',
+ stats: '6 files · 14 matches',
+ },
]}
/>
),
@@ -85,9 +149,28 @@ export const WithErrors: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'yarn build', status: 'complete', duration: '8s', node: 'cli:devvm'},
- {name: 'bash', label: 'yarn test', status: 'error', duration: '2.1s', node: 'cli:devvm', errorMessage: 'Process exited with code 1: FAIL src/Button.test.tsx'},
- {name: 'read', label: 'test-output.log', status: 'complete', duration: '15ms', node: 'cli:devvm'},
+ {
+ name: 'bash',
+ target: 'yarn build',
+ status: 'complete',
+ duration: '8s',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'read',
+ target: 'test-output.log',
+ status: 'complete',
+ duration: '15ms',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'bash',
+ target: 'yarn test',
+ status: 'error',
+ duration: '2.1s',
+ node: 'cli:devvm',
+ errorMessage: 'Process exited with code 1: FAIL src/Button.test.tsx',
+ },
]}
/>
),
@@ -98,8 +181,19 @@ export const Running: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'yarn test --watch', status: 'running', node: 'cli:devvm'},
- {name: 'read', label: 'vitest.config.ts', status: 'complete', duration: '20ms', node: 'cli:devvm'},
+ {
+ name: 'bash',
+ target: 'yarn test --watch',
+ status: 'running',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'read',
+ target: 'vitest.config.ts',
+ status: 'complete',
+ duration: '20ms',
+ node: 'cli:devvm',
+ },
]}
/>
),
@@ -109,11 +203,47 @@ export const Running: Story = {
export const Streaming: Story = {
render: () => {
const allCalls: XDSChatToolCallItem[] = [
- {key: '1', name: 'web_search', label: 'CSS anchor positioning support', status: 'complete', duration: '1.8s'},
- {key: '2', name: 'read', label: 'packages/core/src/Layer/useXDSLayer.tsx', status: 'complete', duration: '45ms', node: 'cli:devvm'},
- {key: '3', name: 'bash', label: 'npx tsc --noEmit', status: 'complete', duration: '4.2s', node: 'cli:devvm'},
- {key: '4', name: 'edit', label: 'XDSChatComposer.tsx', status: 'complete', duration: '120ms', node: 'cli:devvm', stats: {additions: 8, deletions: 2}},
- {key: '5', name: 'bash', label: 'yarn test', status: 'complete', duration: '6.1s', node: 'cli:devvm'},
+ {
+ key: '1',
+ name: 'web_search',
+ target: 'CSS anchor positioning support',
+ status: 'complete',
+ duration: '1.8s',
+ },
+ {
+ key: '2',
+ name: 'read',
+ target: 'packages/core/src/Layer/useXDSLayer.tsx',
+ status: 'complete',
+ duration: '45ms',
+ node: 'cli:devvm',
+ },
+ {
+ key: '3',
+ name: 'bash',
+ target: 'npx tsc --noEmit',
+ status: 'complete',
+ duration: '4.2s',
+ node: 'cli:devvm',
+ },
+ {
+ key: '4',
+ name: 'edit',
+ target: 'XDSChatComposer.tsx',
+ status: 'complete',
+ duration: '120ms',
+ node: 'cli:devvm',
+ additions: 8,
+ deletions: 2,
+ },
+ {
+ key: '5',
+ name: 'bash',
+ target: 'yarn test',
+ status: 'complete',
+ duration: '6.1s',
+ node: 'cli:devvm',
+ },
];
const [calls, setCalls] = useState<XDSChatToolCallItem[]>([]);
@@ -131,19 +261,23 @@ export const Streaming: Story = {
}
// Add as running
const call = allCalls[i]!;
- setCalls(prev => [...prev, {...call, status: 'running', duration: undefined}]);
+ setCalls(prev => [
+ ...prev,
+ {...call, status: 'running', duration: undefined},
+ ]);
// Complete after a delay
const idx = i;
- setTimeout(() => {
- setCalls(prev =>
- prev.map((c, j) =>
- j === idx ? {...allCalls[idx]!} : c,
- ),
- );
- // Add next after completion
- setTimeout(addNext, 200);
- }, 800 + Math.random() * 1200);
+ setTimeout(
+ () => {
+ setCalls(prev =>
+ prev.map((c, j) => (j === idx ? {...allCalls[idx]!} : c)),
+ );
+ // Add next after completion
+ setTimeout(addNext, 200);
+ },
+ 800 + Math.random() * 1200,
+ );
i++;
};
@@ -176,14 +310,56 @@ export const ManyCalls: Story = {
render: () => (
<XDSChatToolCalls
calls={[
- {name: 'bash', label: 'git fetch origin', status: 'complete', duration: '1.2s'},
- {name: 'bash', label: 'git log --oneline -5', status: 'complete', duration: '80ms'},
- {name: 'read', label: 'CHANGELOG.md', status: 'complete', duration: '30ms'},
- {name: 'read', label: 'package.json', status: 'complete', duration: '15ms'},
- {name: 'edit', label: 'package.json', status: 'complete', duration: '50ms', stats: {additions: 1, deletions: 1}},
- {name: 'bash', label: 'yarn install', status: 'complete', duration: '8.5s'},
- {name: 'bash', label: 'yarn build', status: 'complete', duration: '12s'},
- {name: 'bash', label: 'yarn test', status: 'complete', duration: '6.2s'},
+ {
+ name: 'bash',
+ target: 'git fetch origin',
+ status: 'complete',
+ duration: '1.2s',
+ },
+ {
+ name: 'bash',
+ target: 'git log --oneline -5',
+ status: 'complete',
+ duration: '80ms',
+ },
+ {
+ name: 'read',
+ target: 'CHANGELOG.md',
+ status: 'complete',
+ duration: '30ms',
+ },
+ {
+ name: 'read',
+ target: 'package.json',
+ status: 'complete',
+ duration: '15ms',
+ },
+ {
+ name: 'edit',
+ target: 'package.json',
+ status: 'complete',
+ duration: '50ms',
+ additions: 1,
+ deletions: 1,
+ },
+ {
+ name: 'bash',
+ target: 'yarn install',
+ status: 'complete',
+ duration: '8.5s',
+ },
+ {
+ name: 'bash',
+ target: 'yarn build',
+ status: 'complete',
+ duration: '12s',
+ },
+ {
+ name: 'bash',
+ target: 'yarn test',
+ status: 'complete',
+ duration: '6.2s',
+ },
]}
/>
),
@@ -192,8 +368,6 @@ export const ManyCalls: Story = {
/** Interactive calls — edit opens a diff modal, bash opens output */
export const Interactive: Story = {
render: () => {
- const dialog = useXDSImperativeDialog({width: 720});
-
const editDiff = `--- a/packages/core/src/Button/XDSButton.tsx
+++ b/packages/core/src/Button/XDSButton.tsx
@@ -55,7 +55,7 @@ const styles = stylex.create({
@@ -227,45 +401,53 @@ Tests: 67 passed, 67 total
Time: 6.1s`;
return (
- <>
- <XDSChatToolCalls
- calls={[
- {
- name: 'edit',
- label: 'XDSButton.tsx',
- status: 'complete',
- duration: '85ms',
- node: 'cli:devvm',
- stats: {additions: 12, deletions: 3},
- onClick: () => dialog.show(<XDSCodeBlock code={editDiff} language="typescript" maxHeight="50vh" />),
- },
- {
- name: 'bash',
- label: 'yarn test',
- status: 'complete',
- duration: '6.1s',
- node: 'cli:devvm',
- onClick: () => dialog.show(<XDSCodeBlock code={testOutput} language="bash" maxHeight="50vh" />),
- },
- {
- name: 'web_search',
- label: 'CSS anchor positioning',
- status: 'complete',
- duration: '1.8s',
- },
- ]}
- />
- {dialog.element}
- </>
+ <XDSChatToolCalls
+ calls={[
+ {
+ name: 'edit',
+ target: 'XDSButton.tsx',
+ status: 'complete',
+ duration: '85ms',
+ node: 'cli:devvm',
+ additions: 12,
+ deletions: 3,
+ resultDetail: (
+ <XDSCodeBlock
+ code={editDiff}
+ language="typescript"
+ maxHeight="50vh"
+ />
+ ),
+ },
+ {
+ name: 'bash',
+ target: 'yarn test',
+ status: 'complete',
+ duration: '6.1s',
+ node: 'cli:devvm',
+ resultDetail: (
+ <XDSCodeBlock
+ code={testOutput}
+ language="bash"
+ maxHeight="50vh"
+ />
+ ),
+ },
+ {
+ name: 'web_search',
+ target: 'CSS anchor positioning',
+ status: 'complete',
+ duration: '1.8s',
+ },
+ ]}
+ />
);
},
};
/** Error with modal — clicking a failed call shows error detail with banner */
-export const ErrorWithModal: Story = {
+export const ErrorWithDetail: Story = {
render: () => {
- const dialog = useXDSImperativeDialog({width: 720});
-
const errorOutput = `$ yarn test
PASS packages/core/src/Chat/XDSChatReasoning.test.tsx (7 tests)
FAIL packages/core/src/Chat/XDSChatToolCalls.test.tsx
@@ -274,55 +456,73 @@ export const ErrorWithModal: Story = {
ReferenceError: hasError is not defined
- at XDSChatToolCalls (packages/core/src/Chat/XDSChatToolCalls.tsx:545:5)
- at renderWithHooks (react-dom.development.js:14985:18)
-
- ● XDSChatToolCalls > auto-collapses groups of more than 3
-
- ReferenceError: hasError is not defined
-
Test Suites: 1 failed, 6 passed, 7 total
Tests: 4 failed, 63 passed, 67 total
Time: 6.84s`;
return (
- <>
- <XDSChatToolCalls
- calls={[
- {
- name: 'bash',
- label: 'yarn build',
- status: 'complete',
- duration: '8s',
- node: 'cli:devvm',
- },
- {
- name: 'bash',
- label: 'yarn test',
- status: 'error',
- duration: '6.8s',
- node: 'cli:devvm',
- errorMessage: '4 tests failed',
- onClick: () => dialog.show(
- <XDSVStack gap={2}>
- <XDSCodeBlock code={errorOutput} language="bash" maxHeight="50vh" />
- <XDSBanner status="error" title="Test failure">
- 4 tests failed in XDSChatToolCalls.test.tsx
- </XDSBanner>
- </XDSVStack>,
- ),
- },
- {
- name: 'read',
- label: 'XDSChatToolCalls.tsx',
- status: 'complete',
- duration: '15ms',
- node: 'cli:devvm',
- },
- ]}
- />
- {dialog.element}
- </>
+ <XDSChatToolCalls
+ calls={[
+ {
+ name: 'bash',
+ target: 'yarn build',
+ status: 'complete',
+ duration: '8s',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'read',
+ target: 'XDSChatToolCalls.tsx',
+ status: 'complete',
+ duration: '15ms',
+ node: 'cli:devvm',
+ },
+ {
+ name: 'bash',
+ target: 'yarn test',
+ status: 'error',
+ duration: '6.8s',
+ node: 'cli:devvm',
+ errorMessage: '4 tests failed',
+ resultDetail: (
+ <XDSCodeBlock
+ code={errorOutput}
+ language="bash"
+ maxHeight="50vh"
+ />
+ ),
+ },
+ ]}
+ />
);
},
};
+
+/** All statuses — shows every status icon treatment side by side */
+export const AllStatuses: Story = {
+ render: () => (
+ <XDSChatToolCalls
+ calls={[
+ {key: 'pending', name: 'bash', target: 'yarn build', status: 'pending'},
+ {key: 'running', name: 'bash', target: 'yarn test', status: 'running'},
+ {
+ key: 'complete',
+ name: 'edit',
+ target: 'XDSButton.tsx',
+ status: 'complete',
+ duration: '120ms',
+ additions: 8,
+ deletions: 2,
+ },
+ {
+ key: 'error',
+ name: 'bash',
+ target: 'yarn lint',
+ status: 'error',
+ duration: '0.8s',
+ errorMessage: '3 lint errors found',
+ },
+ ]}
+ />
+ ),
+};
diff --git a/packages/core/src/Chat/Chat.doc.mjs b/packages/core/src/Chat/Chat.doc.mjs
index c558a81abd..68e2079061 100644
--- a/packages/core/src/Chat/Chat.doc.mjs
+++ b/packages/core/src/Chat/Chat.doc.mjs
@@ -4,7 +4,7 @@ export const docs = {
name: 'Chat',
description:
'Chat components for AI chat interfaces. Layout (MessageList, Message, Bubble, SystemMessage) + Composer (Composer, ComposerInput with trigger menus, ComposerAttachments).',
- keywords: ['chat', 'message', 'bubble', 'conversation', 'ai', 'assistant', 'thread', 'system-message', 'composer', 'mention', 'trigger', 'typeahead', 'token'],
+ keywords: ['chat', 'message', 'bubble', 'conversation', 'ai', 'assistant', 'thread', 'system-message', 'composer', 'mention', 'trigger', 'typeahead', 'token', 'imperative', 'tokenized-text'],
features: [
'Composition model — MessageList > Message > Bubble',
'Sender-aware styling (user, assistant, system) via context',
@@ -18,6 +18,8 @@ export const docs = {
'role="log" with aria-live="polite" for accessibility',
'Composer layout shell with named semantic slots',
'ContentEditable input with @ mention and / command trigger menus',
+ 'Imperative handle on ComposerInput for programmatic token/text insertion',
+ 'Tokenized text rendering in message bubbles via XDSChatMessageTokenizedText',
'XDSSearchSource integration — reuses Typeahead search sources',
'Concentric radius — inner elements follow outer shell curvature',
'Themeable via --composer-radius and --composer-padding CSS vars',
@@ -127,7 +129,7 @@ export const docs = {
{name: 'footerActions', type: 'ReactNode', description: 'Slot: left-aligned footer actions (model selector, etc).'},
{name: 'sendActions', type: 'ReactNode', description: 'Slot: actions to the left of the send button.'},
{name: 'sendButton', type: 'ReactNode', description: 'Slot: custom send button. Replaces the default send/stop button.'},
- {name: 'status', type: "{ type: 'error' | 'warning'; message?: string }", description: 'Status message below (or above) the composer.'},
+ {name: 'status', type: "{ type: 'error' | 'warning'; message?: string }", description: 'Status message rendered below (or above) the composer.'},
{name: 'statusPosition', type: "'top' | 'bottom'", description: 'Where to render the status.', default: "'bottom'"},
],
@@ -139,9 +141,9 @@ export const docs = {
},
{
name: 'XDSChatComposerInput',
- description: 'ContentEditable-based rich input with trigger menus (@ mentions, / commands), inline tokens, serialization, message history, and paste/drop file handling. Uses XDSSearchSource for search.',
+ description: 'ContentEditable-based rich input with trigger menus (@ mentions, / commands), inline tokens, serialization, message history, and paste/drop file handling. Uses XDSSearchSource for search. Exposes an imperative handle for programmatic control.',
props: [
- {name: 'ref', type: 'React.Ref<HTMLDivElement>', description: 'Ref to the root element.'},
+ {name: 'ref', type: 'React.Ref<XDSChatComposerInputHandle>', description: 'Imperative handle ref exposing insertToken, insertText, focus, and getValue.'},
{name: 'value', type: 'string', description: 'Controlled value.'},
{name: 'onChange', type: '(value: string) => void', description: 'Change handler.'},
{name: 'placeholder', type: 'string', description: 'Placeholder text.', default: "'Type a message\u2026'"},
@@ -170,6 +172,17 @@ export const docs = {
{label: 'With tokens', code: `<XDSChatComposerAttachments>\n <XDSToken label="report.pdf" onDismiss={() => {}} />\n</XDSChatComposerAttachments>`},
],
},
+ {
+ name: 'XDSChatMessageTokenizedText',
+ description: 'Renders text with token patterns replaced by inline XDSBadge components. Use inside XDSChatMessageBubble to display @mentions or other tokens as styled badges.',
+ props: [
+ {name: 'children', type: 'string', description: 'The message text containing token patterns.', required: true},
+ {name: 'tokens', type: 'XDSChatMessageTokenConfig[]', description: 'Token definitions. Each has pattern (string to match), label (display text), and optional variant.'},
+ ],
+ examples: [
+ {label: 'With mentions', code: `<XDSChatMessageBubble>\n <XDSChatMessageTokenizedText\n tokens={[{pattern: '@cindy', label: '@Cindy Zhang', variant: 'blue'}]}\n >\n Hey @cindy, can you review this?\n </XDSChatMessageTokenizedText>\n</XDSChatMessageBubble>`},
+ ],
+ },
],
usage: {
summary: 'Chat components for building AI chat interfaces, including message lists, message bubbles, and a composer.',
@@ -193,6 +206,8 @@ export const docsZh = {
'role="log" 配合 aria-live="polite" 实现无障碍访问',
'编写器布局外壳,具有命名语义插槽',
'ContentEditable 输入框,支持 @ 提及和 / 命令触发菜单',
+ 'ComposerInput 命令式句柄,支持编程式插入标记/文本',
+ '通过 XDSChatMessageTokenizedText 在消息气泡中渲染标记文本',
'XDSSearchSource 集成 — 复用 Typeahead 搜索源',
'同心圆角 — 内部元素跟随外部外壳曲率',
'通过 --composer-radius 和 --composer-padding CSS 变量实现主题化',
@@ -267,9 +282,9 @@ export const docsZh = {
},
{
name: 'XDSChatComposerInput',
- description: '基于 ContentEditable 的富文本输入,支持触发菜单(@ 提及、/ 命令)、内联标记、序列化、消息历史和粘贴/拖放文件处理。',
+ description: '基于 ContentEditable 的富文本输入,支持触发菜单(@ 提及、/ 命令)、内联标记、序列化、消息历史和粘贴/拖放文件处理。提供命令式句柄用于编程式控制。',
propDescriptions: {
- ref: '根元素的引用。',
+ ref: '命令式句柄引用,暴露 insertToken、insertText、focus 和 getValue。',
value: '受控值。',
onChange: '变更处理器。',
placeholder: '占位文本。',
@@ -292,6 +307,14 @@ export const docsZh = {
count: '附件总数。超过可见子元素时显示折叠/展开切换。',
},
},
+ {
+ name: 'XDSChatMessageTokenizedText',
+ description: '渲染带有标记模式的文本,将匹配的模式替换为内联 XDSBadge 组件。在 XDSChatMessageBubble 内使用,以徽章样式显示 @提及或其他标记。',
+ propDescriptions: {
+ children: '包含标记模式的消息文本。',
+ tokens: '标记定义。每个包含 pattern(匹配字符串)、label(显示文本)和可选 variant。',
+ },
+ },
],
};
@@ -311,6 +334,8 @@ export const docsDense = {
'role="log" + aria-live="polite" for a11y',
'composer layout shell w/ named semantic slots',
'ContentEditable input w/ @ mention + / command trigger menus',
+ 'imperative handle on ComposerInput for programmatic token/text insert',
+ 'tokenized text rendering in msg bubbles via XDSChatMessageTokenizedText',
'XDSSearchSource integration; reuses Typeahead search sources',
'concentric radius; inner elements follow outer shell curvature',
'themeable via --composer-radius + --composer-padding CSS vars',
@@ -385,9 +410,9 @@ export const docsDense = {
},
{
name: 'XDSChatComposerInput',
- description: 'ContentEditable rich input w/ trigger menus (@/commands), inline tokens, serialization, msg history, paste/drop files',
+ description: 'ContentEditable rich input w/ trigger menus (@/commands), inline tokens, serialization, msg history, paste/drop files, imperative handle',
propDescriptions: {
- ref: 'root element ref',
+ ref: 'imperative handle ref (insertToken/insertText/focus/getValue)',
value: 'controlled value',
onChange: 'change handler',
placeholder: 'placeholder text',
@@ -410,5 +435,13 @@ export const docsDense = {
count: 'total count; shows collapse/expand when exceeds visible',
},
},
+ {
+ name: 'XDSChatMessageTokenizedText',
+ description: 'renders text w/ token patterns replaced by inline badges; use in bubble for @mentions',
+ propDescriptions: {
+ children: 'msg text w/ token patterns',
+ tokens: 'token defs: pattern+label+variant',
+ },
+ },
],
};
diff --git a/packages/core/src/Chat/XDSChatComposer.tsx b/packages/core/src/Chat/XDSChatComposer.tsx
index eb353310a2..3e2bf1ca4b 100644
--- a/packages/core/src/Chat/XDSChatComposer.tsx
+++ b/packages/core/src/Chat/XDSChatComposer.tsx
@@ -94,7 +94,7 @@ export interface XDSChatComposerProps extends Omit<
sendActions?: ReactNode;
/** Custom send button — replaces the default */
sendButton?: ReactNode;
- /** Status message rendered below the footer */
+ /** Status message rendered below (or above) the composer body */
status?: XDSChatComposerStatus;
/** Where to render the status. @default 'bottom' */
statusPosition?: 'top' | 'bottom';
@@ -161,6 +161,7 @@ const styles = stylex.create({
alignItems: 'center',
gap: spacingVars['--spacing-2'],
marginInlineStart: 'auto',
+ minWidth: '80px',
fontSize: typeScaleVars['--text-supporting-size'],
lineHeight: typeScaleVars['--text-supporting-leading'],
color: colorVars['--color-text-secondary'],
diff --git a/packages/core/src/Chat/XDSChatComposerAttachments.tsx b/packages/core/src/Chat/XDSChatComposerAttachments.tsx
index ef12ddd95a..cd5b170cf4 100644
--- a/packages/core/src/Chat/XDSChatComposerAttachments.tsx
+++ b/packages/core/src/Chat/XDSChatComposerAttachments.tsx
@@ -167,12 +167,14 @@ const styles = stylex.create({
flexWrap: 'wrap',
gap: spacingVars['--spacing-1'],
alignItems: 'flex-start',
+ opacity: 1,
transform: 'translateY(0)',
- transitionProperty: 'transform',
- transitionDuration: durationVars['--duration-medium'],
+ transitionProperty: 'opacity, transform',
+ transitionDuration: `${durationVars['--duration-fast']}, ${durationVars['--duration-medium']}`,
transitionTimingFunction: easeVars['--ease-standard'],
},
contentCollapsed: {
+ opacity: 0,
transform: `translateY(calc(100% + ${spacingVars['--spacing-3']} + ${radiusVars['--radius-page']}))`,
},
});
diff --git a/packages/core/src/Chat/XDSChatComposerInput.test.tsx b/packages/core/src/Chat/XDSChatComposerInput.test.tsx
index 98c031968d..5ab7d74a1a 100644
--- a/packages/core/src/Chat/XDSChatComposerInput.test.tsx
+++ b/packages/core/src/Chat/XDSChatComposerInput.test.tsx
@@ -1,7 +1,10 @@
import {describe, it, expect, vi} from 'vitest';
import {render, screen, fireEvent} from '@testing-library/react';
import {XDSChatComposerInput} from './XDSChatComposerInput';
-import type {XDSChatComposerTrigger} from './XDSChatComposerInput';
+import type {
+ XDSChatComposerTrigger,
+ XDSChatComposerInputHandle,
+} from './XDSChatComposerInput';
import {createStaticSource} from '../Typeahead/createStaticSource';
import type {XDSSearchableItem} from '../Typeahead/types';
@@ -135,9 +138,9 @@ describe('XDSChatComposerInput', () => {
const file = new File(['content'], 'test.txt', {type: 'text/plain'});
fireEvent.paste(textbox, {
clipboardData: {
- files: [file],
- getData: () => '',
- },
+ files: [file],
+ getData: () => '',
+ },
});
expect(onFiles).toHaveBeenCalledWith([file]);
});
@@ -217,11 +220,30 @@ describe('XDSChatComposerInput', () => {
});
});
- describe('ref', () => {
- it('forwards ref to root element', () => {
+ describe('ref (imperative handle)', () => {
+ it('exposes imperative handle via ref', () => {
const ref = vi.fn();
render(<XDSChatComposerInput ref={ref} />);
- expect(ref).toHaveBeenCalledWith(expect.any(HTMLDivElement));
+ expect(ref).toHaveBeenCalledWith(
+ expect.objectContaining({
+ insertToken: expect.any(Function),
+ insertText: expect.any(Function),
+ focus: expect.any(Function),
+ getValue: expect.any(Function),
+ }),
+ );
+ });
+
+ it('getValue returns empty string for empty input', () => {
+ let handle: XDSChatComposerInputHandle | null = null;
+ render(
+ <XDSChatComposerInput
+ ref={h => {
+ handle = h;
+ }}
+ />,
+ );
+ expect(handle!.getValue()).toBe('');
});
});
diff --git a/packages/core/src/Chat/XDSChatComposerInput.tsx b/packages/core/src/Chat/XDSChatComposerInput.tsx
index d66a2535d4..128d6a9b4d 100644
--- a/packages/core/src/Chat/XDSChatComposerInput.tsx
+++ b/packages/core/src/Chat/XDSChatComposerInput.tsx
@@ -23,6 +23,7 @@ import {
useState,
useCallback,
useEffect,
+ useImperativeHandle,
type ReactNode,
type KeyboardEvent,
type ClipboardEvent,
@@ -47,6 +48,18 @@ import {useXDSChatComposerContext} from './XDSChatContext';
// Types
// =============================================================================
+/** Imperative handle exposed by XDSChatComposerInput via ref */
+export interface XDSChatComposerInputHandle {
+ /** Insert a token (badge chip) at the current cursor position */
+ insertToken: (token: XDSChatComposerToken) => void;
+ /** Insert plain text at the current cursor position */
+ insertText: (text: string) => void;
+ /** Focus the input */
+ focus: () => void;
+ /** Get the current serialized value */
+ getValue: () => string;
+}
+
/** Badge config for the common case \u2014 structured, simple, autocomplete-friendly */
export type XDSChatComposerTokenBadge = {
/** Serialized value \u2014 what this token becomes in the onSubmit string */
@@ -122,8 +135,8 @@ export interface XDSChatComposerInputProps extends Omit<
XDSBaseProps<HTMLDivElement>,
'onChange' | 'onPaste' | 'onSubmit'
> {
- /** Ref to the root element */
- ref?: React.Ref<HTMLDivElement>;
+ /** Imperative handle ref for programmatic control */
+ ref?: React.Ref<XDSChatComposerInputHandle>;
/** Controlled value */
value?: string;
/** Change handler */
@@ -288,6 +301,20 @@ export function XDSChatComposerInput(props: XDSChatComposerInputProps) {
const historyIndexRef = useRef(-1);
const currentDraftRef = useRef('');
+ // Stable refs for imperative handle callbacks (avoid re-creating handle on every render)
+ const insertTokenRef = useRef<(token: XDSChatComposerToken) => void>(
+ () => {},
+ );
+ const insertTextRef = useRef<(text: string) => void>(() => {});
+
+ useImperativeHandle(ref, () => ({
+ insertToken: (token: XDSChatComposerToken) => insertTokenRef.current(token),
+ insertText: (text: string) => insertTextRef.current(text),
+ focus: () => editableRef.current?.focus(),
+ getValue: () =>
+ serialize(editableRef.current ?? document.createElement('div')),
+ }));
+
useEffect(() => {
if (controlledValue !== undefined && editableRef.current) {
const current = serialize(editableRef.current);
@@ -357,6 +384,10 @@ export function XDSChatComposerInput(props: XDSChatComposerInputProps) {
insertTextAtCursor(text);
}, []);
+ // Keep stable refs in sync for imperative handle
+ insertTokenRef.current = insertToken;
+ insertTextRef.current = insertText;
+
// --- Trigger menu ---
const triggerMenu = useTriggerMenu({
triggers,
@@ -460,7 +491,6 @@ export function XDSChatComposerInput(props: XDSChatComposerInputProps) {
return (
<div
- ref={ref}
{...mergeProps(
xdsClassName('chat-composer-input'),
stylex.props(styles.root, isDisabled && styles.disabled, xstyle),
diff --git a/packages/core/src/Chat/XDSChatMessageBubble.tsx b/packages/core/src/Chat/XDSChatMessageBubble.tsx
index c782ff1d5a..131907df5a 100644
--- a/packages/core/src/Chat/XDSChatMessageBubble.tsx
+++ b/packages/core/src/Chat/XDSChatMessageBubble.tsx
@@ -75,7 +75,7 @@ const styles = stylex.create({
display: 'flex',
flexDirection: 'column',
maxWidth: '100%',
- borderRadius: radiusVars['--radius-container'],
+ borderRadius: radiusVars['--radius-page'],
fontFamily: typographyVars['--font-family-body'],
fontSize: typeScaleVars['--text-body-size'],
lineHeight: typeScaleVars['--text-body-leading'],
diff --git a/packages/core/src/Chat/XDSChatMessageList.tsx b/packages/core/src/Chat/XDSChatMessageList.tsx
index 67cf49627f..b2c9afc31d 100644
--- a/packages/core/src/Chat/XDSChatMessageList.tsx
+++ b/packages/core/src/Chat/XDSChatMessageList.tsx
@@ -264,7 +264,7 @@ function ScrollToBottomButton({
size="md"
onClick={onClick}
xstyle={styles.scrollButton}>
- {label}
+ {hasNewMessages ? label : undefined}
</XDSButton>
</div>
);
diff --git a/packages/core/src/Chat/XDSChatMessageTokenizedText.test.tsx b/packages/core/src/Chat/XDSChatMessageTokenizedText.test.tsx
new file mode 100644
index 0000000000..8d27d436ea
--- /dev/null
+++ b/packages/core/src/Chat/XDSChatMessageTokenizedText.test.tsx
@@ -0,0 +1,89 @@
+import {describe, it, expect} from 'vitest';
+import {render, screen} from '@testing-library/react';
+import {XDSChatMessageTokenizedText} from './XDSChatMessageTokenizedText';
+
+describe('XDSChatMessageTokenizedText', () => {
+ it('renders plain text when no tokens provided', () => {
+ render(
+ <XDSChatMessageTokenizedText>Hello world</XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getByText('Hello world')).toBeInTheDocument();
+ });
+
+ it('renders plain text when tokens array is empty', () => {
+ render(
+ <XDSChatMessageTokenizedText tokens={[]}>
+ Hello world
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getByText('Hello world')).toBeInTheDocument();
+ });
+
+ it('replaces a single token with a badge', () => {
+ render(
+ <XDSChatMessageTokenizedText
+ tokens={[{pattern: '@cindy', label: '@Cindy Zhang', variant: 'blue'}]}>
+ Hey @cindy!
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getByText('@Cindy Zhang')).toBeInTheDocument();
+ expect(screen.queryByText('@cindy')).not.toBeInTheDocument();
+ });
+
+ it('replaces multiple different tokens', () => {
+ render(
+ <XDSChatMessageTokenizedText
+ tokens={[
+ {pattern: '@cindy', label: '@Cindy Zhang', variant: 'blue'},
+ {pattern: '@navi', label: '@Navi', variant: 'blue'},
+ ]}>
+ Hey @cindy, can @navi help?
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getByText('@Cindy Zhang')).toBeInTheDocument();
+ expect(screen.getByText('@Navi')).toBeInTheDocument();
+ });
+
+ it('handles repeated occurrences of the same token', () => {
+ render(
+ <XDSChatMessageTokenizedText
+ tokens={[{pattern: '@cindy', label: '@Cindy Zhang'}]}>
+ @cindy and @cindy again
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getAllByText('@Cindy Zhang')).toHaveLength(2);
+ });
+
+ it('renders text with no matching tokens as plain text', () => {
+ render(
+ <XDSChatMessageTokenizedText
+ tokens={[{pattern: '@cindy', label: '@Cindy Zhang'}]}>
+ Hello world
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(screen.getByText('Hello world')).toBeInTheDocument();
+ });
+
+ it('handles tokens with special regex characters in pattern', () => {
+ render(
+ <XDSChatMessageTokenizedText
+ tokens={[{pattern: '/search', label: '/search'}]}>
+ Run /search now
+ </XDSChatMessageTokenizedText>,
+ );
+ // The badge should render with the label
+ expect(screen.getByText('/search')).toBeInTheDocument();
+ });
+
+ it('preserves surrounding text', () => {
+ const {container} = render(
+ <XDSChatMessageTokenizedText
+ tokens={[{pattern: '@cindy', label: '@Cindy Zhang'}]}>
+ Before @cindy after
+ </XDSChatMessageTokenizedText>,
+ );
+ expect(container.textContent).toContain('Before');
+ expect(container.textContent).toContain('after');
+ expect(container.textContent).toContain('@Cindy Zhang');
+ });
+});
diff --git a/packages/core/src/Chat/XDSChatMessageTokenizedText.tsx b/packages/core/src/Chat/XDSChatMessageTokenizedText.tsx
new file mode 100644
index 0000000000..bbf194c624
--- /dev/null
+++ b/packages/core/src/Chat/XDSChatMessageTokenizedText.tsx
@@ -0,0 +1,124 @@
+'use client';
+
+/**
+ * @file XDSChatMessageTokenizedText.tsx
+ * @input Uses React, XDSBadge
+ * @output Exports XDSChatMessageTokenizedText component
+ * @position Utility component for rendering tokenized text in message bubbles
+ *
+ * Parses a plain text string and replaces token patterns (e.g. @cindy)
+ * with inline XDSBadge components. Falls back to plain text when no
+ * tokens match.
+ *
+ * SYNC: When modified, update:
+ * - /packages/core/src/Chat/index.ts
+ */
+
+import type {ReactNode} from 'react';
+import {XDSBadge, type XDSBadgeVariant} from '../Badge';
+
+// =============================================================================
+// Types
+// =============================================================================
+
+export interface XDSChatMessageTokenConfig {
+ /** Pattern to match in the text (e.g. '@cindy') */
+ pattern: string;
+ /** Display label for the badge (e.g. '@Cindy Zhang') */
+ label: string;
+ /** Badge variant */
+ variant?: XDSBadgeVariant;
+}
+
+export interface XDSChatMessageTokenizedTextProps {
+ /** The message text containing token patterns */
+ children: string;
+ /** Token definitions to match and render as badges */
+ tokens?: XDSChatMessageTokenConfig[];
+}
+
+// =============================================================================
+// Component
+// =============================================================================
+
+/**
+ * Renders text with token patterns replaced by inline badges.
+ *
+ * @example
+ * ```
+ * <XDSChatMessageTokenizedText
+ * tokens={[{pattern: '@cindy', label: '@Cindy Zhang', variant: 'blue'}]}
+ * >
+ * Hey @cindy, can you review this?
+ * </XDSChatMessageTokenizedText>
+ * ```
+ */
+export function XDSChatMessageTokenizedText({
+ children,
+ tokens,
+}: XDSChatMessageTokenizedTextProps) {
+ if (!tokens || tokens.length === 0) {
+ return <span style={{display: 'inline'}}>{children}</span>;
+ }
+
+ const parts = renderTokens(children, tokens);
+ return <span style={{display: 'inline'}}>{parts}</span>;
+}
+
+XDSChatMessageTokenizedText.displayName = 'XDSChatMessageTokenizedText';
+
+// =============================================================================
+// Helpers
+// =============================================================================
+
+function escapeRegExp(str: string): string {
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+}
+
+/** Parse text and replace token patterns with Badge elements */
+function renderTokens(
+ text: string,
+ tokens: XDSChatMessageTokenConfig[],
+): ReactNode[] {
+ // Build a combined regex matching any token pattern
+ const pattern = tokens.map(t => escapeRegExp(t.pattern)).join('|');
+ const regex = new RegExp(`(${pattern})`, 'g');
+
+ // Build a lookup map for O(1) access
+ const tokenMap = new Map<string, XDSChatMessageTokenConfig>();
+ for (const t of tokens) {
+ tokenMap.set(t.pattern, t);
+ }
+
+ const parts: ReactNode[] = [];
+ let lastIndex = 0;
+ let match: RegExpExecArray | null;
+
+ while ((match = regex.exec(text)) !== null) {
+ // Add text before the match
+ if (match.index > lastIndex) {
+ parts.push(text.slice(lastIndex, match.index));
+ }
+
+ const matched = match[0];
+ const config = tokenMap.get(matched);
+ if (config) {
+ parts.push(
+ <XDSBadge
+ key={`${matched}-${match.index}`}
+ label={config.label}
+ variant={config.variant}
+ />,
+ );
+ }
+
+ lastIndex = match.index + matched.length;
+ }
+
+ // Add remaining text
+ if (lastIndex < text.length) {
+ parts.push(text.slice(lastIndex));
+ }
+
+ return parts;
+}
diff --git a/packages/core/src/Chat/XDSChatToolCalls.test.tsx b/packages/core/src/Chat/XDSChatToolCalls.test.tsx
index ca7199fc3e..f2b610320f 100644
--- a/packages/core/src/Chat/XDSChatToolCalls.test.tsx
+++ b/packages/core/src/Chat/XDSChatToolCalls.test.tsx
@@ -19,7 +19,7 @@ describe('XDSChatToolCalls', () => {
expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
- it('renders group header for multiple calls', () => {
+ it('renders latest call as surface for multiple calls', () => {
render(
<XDSChatToolCalls
calls={[
@@ -29,7 +29,8 @@ describe('XDSChatToolCalls', () => {
]}
/>,
);
- expect(screen.getByText('3 tool calls')).toBeInTheDocument();
+ // Latest call (editFile) shown at surface + in expanded list
+ expect(screen.getAllByText('editFile').length).toBeGreaterThanOrEqual(1);
expect(screen.getByRole('button')).toBeInTheDocument();
});
@@ -42,29 +43,19 @@ describe('XDSChatToolCalls', () => {
expect(screen.queryByText('1.2s')).not.toBeInTheDocument();
});
- it('supports custom label', () => {
+ it('defaults to collapsed', () => {
render(
<XDSChatToolCalls
- label="Running tools"
calls={[
{name: 'a', status: 'complete'},
{name: 'b', status: 'complete'},
]}
/>,
);
- expect(screen.getByText('Running tools')).toBeInTheDocument();
- });
-
- it('auto-expands groups of 3 or fewer', () => {
- render(
- <XDSChatToolCalls
- calls={[
- {name: 'a', status: 'complete'},
- {name: 'b', status: 'complete'},
- ]}
- />,
+ expect(screen.getByRole('button')).toHaveAttribute(
+ 'aria-expanded',
+ 'false',
);
- expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
});
it('auto-collapses groups of more than 3', () => {
@@ -95,10 +86,10 @@ describe('XDSChatToolCalls', () => {
expect(btn).toHaveAttribute('aria-expanded', 'true');
});
- it('shows label when provided', () => {
+ it('shows target when provided', () => {
render(
<XDSChatToolCalls
- calls={[{name: 'bash', label: 'git status', status: 'complete'}]}
+ calls={[{name: 'bash', target: 'git status', status: 'complete'}]}
/>,
);
expect(screen.getByText('git status')).toBeInTheDocument();
diff --git a/packages/core/src/Chat/XDSChatToolCalls.tsx b/packages/core/src/Chat/XDSChatToolCalls.tsx
index 6d99c24b1e..124dbf4533 100644
--- a/packages/core/src/Chat/XDSChatToolCalls.tsx
+++ b/packages/core/src/Chat/XDSChatToolCalls.tsx
@@ -31,6 +31,8 @@ import {
} from '../theme/tokens.stylex';
import {xdsClassName, mergeProps} from '../utils';
import {XDSBadge} from '../Badge';
+import {XDSIcon, type XDSIconName} from '../Icon';
+import {XDSSpinner} from '../Spinner';
// =============================================================================
// Types
@@ -42,38 +44,31 @@ export type XDSChatToolCallStatus =
| 'complete'
| 'error';
-export interface XDSChatToolCallStats {
- /** Number of lines/characters added */
- additions?: number;
- /** Number of lines/characters removed */
- deletions?: number;
- /** Number of files affected */
- files?: number;
- /** Number of search matches */
- matches?: number;
-}
-
export interface XDSChatToolCallItem {
/** Tool/function name. */
name: string;
/** Current execution status. @default 'complete' */
status?: XDSChatToolCallStatus;
- /** Short summary label (e.g. "Edit Button.tsx", "git status"). Shown alongside name. */
- label?: string;
+ /** The target of the action (e.g. "XDSButton.tsx", "yarn test", "CSS anchor positioning"). */
+ target?: string;
/** Duration string (e.g. "1.2s", "340ms"). Shown when complete. */
duration?: string;
/** Sandbox/node name (e.g. "navi", "xds"). Shown as a pill badge. */
node?: string;
- /** Stats like additions/deletions for edits, file/match counts. */
- stats?: XDSChatToolCallStats;
+ /** Lines/characters added. Rendered in green (e.g. "+12"). */
+ additions?: number;
+ /** Lines/characters removed. Rendered in red (e.g. "-3"). */
+ deletions?: number;
+ /** Additional info rendered after the label. Free-form ReactNode. */
+ stats?: ReactNode;
/** Error message when status is 'error'. Shown in a tooltip on the status icon. */
errorMessage?: string;
/** Unique key for React list rendering. Falls back to index. */
key?: string;
/** Arbitrary data passed through to renderDetail. Store tool args, result, etc. */
data?: unknown;
- /** Click handler for the call row. When provided, the row is interactive (pointer cursor, hover state). */
- onClick?: () => void;
+ /** Inline detail content shown when the row is expanded (e.g. code diff, command output). */
+ resultDetail?: ReactNode;
}
export interface XDSChatToolCallsProps extends XDSBaseProps<HTMLDivElement> {
@@ -90,19 +85,6 @@ export interface XDSChatToolCallsProps extends XDSBaseProps<HTMLDivElement> {
}
// =============================================================================
-// Animations
-// =============================================================================
-
-const spinKeyframes = stylex.keyframes({
- '0%': {transform: 'rotate(0deg)'},
- '100%': {transform: 'rotate(360deg)'},
-});
-
-const pulseKeyframes = stylex.keyframes({
- '0%, 100%': {opacity: 1},
- '50%': {opacity: 0.4},
-});
-
// =============================================================================
// Styles
// =============================================================================
@@ -166,9 +148,11 @@ const styles = stylex.create({
list: {
display: 'flex',
flexDirection: 'column',
+ paddingInline: spacingVars['--spacing-1'],
+ marginInline: `calc(-1 * ${spacingVars['--spacing-1']})`,
},
listIndented: {
- paddingInlineStart: spacingVars['--spacing-2'],
+ paddingInlineStart: 0,
},
// Individual call row
@@ -188,25 +172,29 @@ const styles = stylex.create({
backgroundColor: colorVars['--color-overlay-hover'],
},
},
+ callRowToggle: {
+ cursor: 'pointer',
+ },
statusIcon: {
+ position: 'relative',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
width: '16px',
height: '16px',
+ borderRadius: radiusVars['--radius-full'],
},
- spinning: {
- animationName: spinKeyframes,
- animationDuration: '1s',
- animationTimingFunction: 'linear',
- animationIterationCount: 'infinite',
+ statusIconCircle: {
+ position: 'absolute',
+ inset: 0,
+ borderRadius: 'inherit',
+ backgroundColor: 'currentColor',
+ opacity: 0.15,
},
- pulsing: {
- animationName: pulseKeyframes,
- animationDuration: '1.5s',
- animationTimingFunction: 'ease-in-out',
- animationIterationCount: 'infinite',
+ statusIconInner: {
+ position: 'relative',
+ display: 'inline-flex',
},
callName: {
fontSize: typeScaleVars['--text-supporting-size'],
@@ -259,6 +247,34 @@ const styles = stylex.create({
errorText: {
color: colorVars['--color-error'],
},
+
+ // Inline result detail
+ callDetailChevron: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ width: '14px',
+ height: '14px',
+ color: colorVars['--color-text-disabled'],
+ transition: `transform ${durationVars['--duration-fast']} ${easeVars['--ease-standard']}`,
+ marginInlineStart: 'auto',
+ },
+ callDetailContent: {
+ paddingInlineStart: `calc(16px + ${spacingVars['--spacing-1-5']})`,
+ paddingBlockEnd: spacingVars['--spacing-2'],
+ },
+ callCount: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-0-5'],
+ fontSize: typeScaleVars['--text-supporting-size'],
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ fontFamily: typographyVars['--font-family-body'],
+ color: colorVars['--color-text-disabled'],
+ flexShrink: 0,
+ },
+
// Pile effect for grouped tool calls
pileWrapper: {
position: 'relative',
@@ -292,94 +308,11 @@ const styles = stylex.create({
// Status Icons
// =============================================================================
-function PendingIcon() {
- return (
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
- <circle cx="7" cy="7" r="5.5" stroke="currentColor" strokeWidth="1.5" />
- </svg>
- );
-}
-
-function RunningIcon() {
- return (
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
- <circle
- cx="7"
- cy="7"
- r="5.5"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeDasharray="8 6"
- strokeLinecap="round"
- />
- </svg>
- );
-}
-
-function CompleteIcon() {
- return (
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
- <circle cx="7" cy="7" r="6" fill="currentColor" fillOpacity="0.15" />
- <path
- d="M4.5 7L6.5 9L10 5"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
-function ErrorIcon() {
- return (
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
- <circle cx="7" cy="7" r="6" fill="currentColor" fillOpacity="0.15" />
- <path
- d="M5 5L9 9M9 5L5 9"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeLinecap="round"
- />
- </svg>
- );
-}
-
-function WrenchIcon() {
- return (
- <svg
- width="14"
- height="14"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round">
- <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
- </svg>
- );
-}
-
-function ChevronDownIcon() {
- return (
- <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
- <path
- d="M3 4.5L6 7.5L9 4.5"
- stroke="currentColor"
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
-const STATUS_ICONS: Record<XDSChatToolCallStatus, React.FC> = {
- pending: PendingIcon,
- running: RunningIcon,
- complete: CompleteIcon,
- error: ErrorIcon,
+const STATUS_ICON_NAMES: Record<XDSChatToolCallStatus, XDSIconName | null> = {
+ pending: 'clock',
+ running: null,
+ complete: 'check',
+ error: 'close',
};
const STATUS_STYLES: Record<
@@ -398,78 +331,102 @@ const STATUS_STYLES: Record<
function CallRow({call}: {call: XDSChatToolCallItem}) {
const status = call.status ?? 'complete';
- const Icon = STATUS_ICONS[status];
- const isClickable = call.onClick != null;
+ const hasDetail = call.resultDetail != null;
+ const [isDetailOpen, setIsDetailOpen] = useState(false);
- return (
- <div>
- <div
- role={isClickable ? 'button' : undefined}
- tabIndex={isClickable ? 0 : undefined}
- onClick={call.onClick}
- onKeyDown={
- isClickable
- ? (e: React.KeyboardEvent) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault();
- call.onClick?.();
- }
+ const toggleDetail = hasDetail
+ ? () => setIsDetailOpen(prev => !prev)
+ : undefined;
+
+ const row = (
+ <div
+ role={hasDetail ? 'button' : undefined}
+ tabIndex={hasDetail ? 0 : undefined}
+ onClick={toggleDetail}
+ onKeyDown={
+ hasDetail
+ ? (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ toggleDetail?.();
}
- : undefined
- }
- {...stylex.props(
- styles.callRow,
- isClickable && styles.callRowClickable,
- )}>
+ }
+ : undefined
+ }
+ {...stylex.props(styles.callRow, hasDetail && styles.callRowClickable)}>
+ <span
+ title={status === 'error' ? call.errorMessage : undefined}
+ {...stylex.props(styles.statusIcon, STATUS_STYLES[status])}>
+ {status === 'running' ? (
+ <XDSSpinner size="sm" shade="subtle" />
+ ) : status === 'pending' ? (
+ <XDSSpinner size="sm" shade="subtle" />
+ ) : (
+ <>
+ <span {...stylex.props(styles.statusIconCircle)} />
+ <span {...stylex.props(styles.statusIconInner)}>
+ <XDSIcon
+ icon={STATUS_ICON_NAMES[status]!}
+ size="xsm"
+ color="inherit"
+ />
+ </span>
+ </>
+ )}
+ </span>
+ <span {...stylex.props(styles.callName)}>{call.name}</span>
+ {call.node != null && (
+ <XDSBadge
+ label={call.node}
+ variant="neutral"
+ xstyle={styles.nodePill}
+ />
+ )}
+ {call.target != null && (
+ <span {...stylex.props(styles.callLabel)}>{call.target}</span>
+ )}
+ {(call.additions != null ||
+ call.deletions != null ||
+ call.stats != null) && (
+ <span {...stylex.props(styles.stats)}>
+ {call.additions != null && (
+ <span {...stylex.props(styles.statsAdditions)}>
+ +{call.additions}
+ </span>
+ )}
+ {call.deletions != null && (
+ <span {...stylex.props(styles.statsDeletions)}>
+ -{call.deletions}
+ </span>
+ )}
+ {call.stats}
+ </span>
+ )}
+ {call.duration != null && status === 'complete' && (
+ <span {...stylex.props(styles.callDuration)}>{call.duration}</span>
+ )}
+ {hasDetail && (
<span
- title={status === 'error' ? call.errorMessage : undefined}
{...stylex.props(
- styles.statusIcon,
- STATUS_STYLES[status],
- status === 'running' && styles.spinning,
- status === 'pending' && styles.pulsing,
+ styles.callDetailChevron,
+ isDetailOpen && styles.chevronExpanded,
)}>
- <Icon />
+ <XDSIcon icon="chevronDown" size="xsm" color="inherit" />
</span>
- <span {...stylex.props(styles.callName)}>{call.name}</span>
- {call.node != null && (
- <XDSBadge
- label={call.node}
- variant="neutral"
- xstyle={styles.nodePill}
- />
- )}
- {call.label != null && (
- <span {...stylex.props(styles.callLabel)}>{call.label}</span>
- )}
- {call.stats != null && (
- <span {...stylex.props(styles.stats)}>
- {call.stats.files != null && (
- <span>
- {call.stats.files} file{call.stats.files !== 1 ? 's' : ''}
- </span>
- )}
- {call.stats.matches != null && (
- <span>
- {call.stats.matches} match{call.stats.matches !== 1 ? 'es' : ''}
- </span>
- )}
- {call.stats.additions != null && (
- <span {...stylex.props(styles.statsAdditions)}>
- +{call.stats.additions}
- </span>
- )}
- {call.stats.deletions != null && (
- <span {...stylex.props(styles.statsDeletions)}>
- -{call.stats.deletions}
- </span>
- )}
- </span>
- )}
- {call.duration != null && status === 'complete' && (
- <span {...stylex.props(styles.callDuration)}>{call.duration}</span>
- )}
- </div>
+ )}
+ </div>
+ );
+
+ if (!hasDetail) return row;
+
+ return (
+ <div>
+ {row}
+ {isDetailOpen && (
+ <div {...stylex.props(styles.callDetailContent)}>
+ {call.resultDetail}
+ </div>
+ )}
</div>
);
}
@@ -487,6 +444,7 @@ function CallRow({call}: {call: XDSChatToolCallItem}) {
*
* @example
* ```
+ * // Basic — pass the array from your LLM response
* <XDSChatToolCalls
* calls={message.toolCalls.map(tc => ({
* name: tc.toolName,
@@ -494,6 +452,11 @@ function CallRow({call}: {call: XDSChatToolCallItem}) {
* duration: tc.duration,
* }))}
* />
+ * ```
+ *
+ * @example
+ * ```
+ * // With detail rendering
* <XDSChatToolCalls
* calls={toolCalls}
* renderDetail={(call) => (
@@ -517,7 +480,10 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
const hasErrors = calls.some(c => c.status === 'error');
const errorCount = calls.filter(c => c.status === 'error').length;
- const autoDefault = defaultIsExpanded ?? (hasErrors || calls.length <= 3);
+ const isStreaming = calls.some(
+ c => c.status === 'running' || c.status === 'pending',
+ );
+ const autoDefault = defaultIsExpanded ?? false;
const [internalExpanded, setInternalExpanded] = useState(autoDefault);
const isControlled = controlledExpanded !== undefined;
const isExpanded = isControlled ? controlledExpanded : internalExpanded;
@@ -546,16 +512,9 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
);
}
- // Multiple calls: collapsible group
- const label = customLabel ?? `${calls.length} tool calls`;
- const errorLabel = hasErrors ? (
- <>
- {label} ·{' '}
- <span {...stylex.props(styles.errorText)}>{errorCount} failed</span>
- </>
- ) : (
- label
- );
+ // Multiple calls: latest call at surface with chevron to expand all
+ const latestCall = calls[calls.length - 1];
+ const latestStatus = latestCall.status ?? 'complete';
return (
<div
@@ -566,6 +525,7 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
style,
)}
{...rest}>
+ {/* Header: collapsed shows latest call + count, expanded shows summary label */}
<div
role="button"
tabIndex={0}
@@ -577,27 +537,70 @@ export function XDSChatToolCalls(props: XDSChatToolCallsProps) {
toggle();
}
}}
- {...stylex.props(styles.groupHeader)}>
- <span {...stylex.props(styles.groupIcon)}>
- <WrenchIcon />
+ {...stylex.props(styles.callRow, styles.callRowToggle)}>
+ {isExpanded ? (
+ <>
+ <span {...stylex.props(styles.groupIcon)}>
+ <XDSIcon icon="wrench" size="sm" color="inherit" />
+ </span>
+ <span {...stylex.props(styles.groupLabel)}>
+ {calls.length} tool calls
+ </span>
+ </>
+ ) : (
+ <>
+ <span
+ {...stylex.props(styles.statusIcon, STATUS_STYLES[latestStatus])}>
+ {latestStatus === 'running' ? (
+ <XDSSpinner size="sm" shade="subtle" />
+ ) : latestStatus === 'pending' ? (
+ <XDSSpinner size="sm" shade="subtle" />
+ ) : (
+ <>
+ <span {...stylex.props(styles.statusIconCircle)} />
+ <span {...stylex.props(styles.statusIconInner)}>
+ <XDSIcon
+ icon={STATUS_ICON_NAMES[latestStatus]!}
+ size="xsm"
+ color="inherit"
+ />
+ </span>
+ </>
+ )}
+ </span>
+ <span {...stylex.props(styles.callName)}>{latestCall.name}</span>
+ {latestCall.target != null && (
+ <span {...stylex.props(styles.callLabel)}>
+ {latestCall.target}
+ </span>
+ )}
+ </>
+ )}
+ <span {...stylex.props(styles.callCount)}>
+ {!isExpanded && (
+ <>
+ <XDSIcon icon="wrench" size="xsm" color="inherit" />
+ {calls.length}
+ </>
+ )}
</span>
- <span {...stylex.props(styles.groupLabel)}>{errorLabel}</span>
<span
{...stylex.props(
styles.chevron,
isExpanded && styles.chevronExpanded,
)}>
- <ChevronDownIcon />
+ <XDSIcon icon="chevronDown" size="xsm" color="inherit" />
</span>
</div>
+ {/* Expanded: all calls with full metadata */}
<div
{...stylex.props(
styles.groupContent,
isExpanded && styles.groupContentExpanded,
)}>
<div {...stylex.props(styles.groupContentInner)}>
- <div {...stylex.props(styles.list, styles.listIndented)}>
+ <div {...stylex.props(styles.list)}>
{calls.map((call, i) => (
<CallRow key={call.key ?? i} call={call} />
))}
diff --git a/packages/core/src/Chat/index.ts b/packages/core/src/Chat/index.ts
index 0d4244c4fd..c4d068b6ba 100644
--- a/packages/core/src/Chat/index.ts
+++ b/packages/core/src/Chat/index.ts
@@ -22,11 +22,18 @@ export {
} from './XDSChatComposerInput';
export type {
XDSChatComposerInputProps,
+ XDSChatComposerInputHandle,
XDSChatComposerToken,
XDSChatComposerTrigger,
XDSChatComposerTriggerItem,
} from './XDSChatComposerInput';
+export {XDSChatMessageTokenizedText} from './XDSChatMessageTokenizedText';
+export type {
+ XDSChatMessageTokenizedTextProps,
+ XDSChatMessageTokenConfig,
+} from './XDSChatMessageTokenizedText';
+
export {XDSChatMessageList} from './XDSChatMessageList';
export type {XDSChatMessageListProps} from './XDSChatMessageList';
@@ -56,13 +63,9 @@ export type {UseAutoScrollOptions, UseAutoScrollReturn} from './useAutoScroll';
export type {XDSChatMessageSender, XDSChatDensity} from './XDSChatContext';
-export {XDSChatReasoning} from './XDSChatReasoning';
-export type {XDSChatReasoningProps} from './XDSChatReasoning';
-
export {XDSChatToolCalls} from './XDSChatToolCalls';
export type {
XDSChatToolCallsProps,
XDSChatToolCallItem,
XDSChatToolCallStatus,
- XDSChatToolCallStats,
} from './XDSChatToolCalls';
diff --git a/packages/core/src/Icon/defaultIcons.tsx b/packages/core/src/Icon/defaultIcons.tsx
index 7926211da4..a329519d7c 100644
--- a/packages/core/src/Icon/defaultIcons.tsx
+++ b/packages/core/src/Icon/defaultIcons.tsx
@@ -235,4 +235,10 @@ export const defaultIcons: XDSIconRegistry = {
<path d="M9 13l4 4L21 7" />
</svg>
),
+
+ wrench: (
+ <svg {...svgProps}>
+ <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
+ </svg>
+ ),
};
diff --git a/packages/core/src/Icon/globalIconRegistry.tsx b/packages/core/src/Icon/globalIconRegistry.tsx
index 3bfa171c65..4913ae891f 100644
--- a/packages/core/src/Icon/globalIconRegistry.tsx
+++ b/packages/core/src/Icon/globalIconRegistry.tsx
@@ -44,7 +44,8 @@ export type XDSIconName =
| 'eyeSlash'
| 'viewColumns'
| 'copy'
- | 'checkDouble';
+ | 'checkDouble'
+ | 'wrench';
/**
* Icon registry mapping semantic names to React nodes.
diff --git a/packages/core/src/Markdown/XDSMarkdown.tsx b/packages/core/src/Markdown/XDSMarkdown.tsx
index 6982160b95..a4e52e8864 100644
--- a/packages/core/src/Markdown/XDSMarkdown.tsx
+++ b/packages/core/src/Markdown/XDSMarkdown.tsx
@@ -100,6 +100,8 @@ const styles = stylex.create({
color: colorVars['--color-text-primary'],
lineHeight: typeScaleVars['--text-body-leading'],
fontSize: typeScaleVars['--text-body-size'],
+ minWidth: 0,
+ overflowWrap: 'break-word',
},
// Headings
headingBase: {
@@ -229,6 +231,7 @@ const styles = stylex.create({
// Table
tableWrapper: {
overflowX: 'auto',
+ minWidth: 0,
},
table: {
borderCollapse: 'collapse',
diff --git a/packages/core/src/ProgressBar/XDSProgressBar.tsx b/packages/core/src/ProgressBar/XDSProgressBar.tsx
index 3eb5480cc9..4cd244abf0 100644
--- a/packages/core/src/ProgressBar/XDSProgressBar.tsx
+++ b/packages/core/src/ProgressBar/XDSProgressBar.tsx
@@ -44,6 +44,7 @@ export interface XDSProgressBarVariantMap {
accent: true;
positive: true;
warning: true;
+ neutral: true;
negative: true;
}
@@ -220,6 +221,9 @@ const variantStyles = stylex.create({
negative: {
backgroundColor: colorVars['--color-error'],
},
+ neutral: {
+ backgroundColor: colorVars['--color-text-disabled'],
+ },
});
function defaultFormatValueLabel(value: number, max: number): string {
diff --git a/packages/core/src/Spinner/XDSSpinner.tsx b/packages/core/src/Spinner/XDSSpinner.tsx
index 25e6fc16a4..2cc7f169c1 100644
--- a/packages/core/src/Spinner/XDSSpinner.tsx
+++ b/packages/core/src/Spinner/XDSSpinner.tsx
@@ -30,7 +30,7 @@ const SPREAD = 0.75;
const START_POINT = 1.5;
const SIZES = {
- sm: {diameter: 10, border: 3},
+ sm: {diameter: 10, border: 2},
md: {diameter: 14, border: 3},
lg: {diameter: 18, border: 3},
xl: {diameter: 28, border: 4},
@@ -77,7 +77,7 @@ const styles = stylex.create({
export type XDSSpinnerSize = keyof typeof SIZES;
-export type XDSSpinnerShade = 'default' | 'onMedia';
+export type XDSSpinnerShade = 'default' | 'onMedia' | 'subtle';
export interface XDSSpinnerProps {
/** Ref forwarded to the root element */
@@ -93,7 +93,9 @@ export interface XDSSpinnerProps {
size?: XDSSpinnerSize;
/**
* Color shade.
- * 'default' for light backgrounds, 'onMedia' for dark/accent backgrounds.
+ * - 'default': accent color on light backgrounds
+ * - 'onMedia': white on dark/accent backgrounds
+ * - 'subtle': secondary text color, less prominent — for inline use in lists
* @default 'default'
*/
shade?: XDSSpinnerShade;
@@ -182,17 +184,24 @@ export function XDSSpinner({
shade === 'onMedia'
? computedStyle.getPropertyValue(colorVars['--color-on-dark']) ||
'#FFFFFF'
- : computedStyle.getPropertyValue(colorVars['--color-accent']) ||
- '#0064E0';
+ : shade === 'subtle'
+ ? computedStyle.getPropertyValue(
+ colorVars['--color-text-secondary'],
+ ) || '#65676B'
+ : computedStyle.getPropertyValue(colorVars['--color-accent']) ||
+ '#0064E0';
const backgroundColor =
- shade === 'onMedia' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.1)';
+ shade === 'onMedia' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.08)';
const radius = (diameter / 2) * pixelRatio;
const lineWidth = border * pixelRatio;
- const frameSize = (radius + lineWidth) * 2;
+ // Ensure even frame size so center is always on a whole pixel (prevents rotation jitter)
+ const rawFrameSize = Math.ceil((radius + lineWidth) * 2);
+ const frameSize = rawFrameSize + (rawFrameSize % 2);
+ const cssSize = frameSize / pixelRatio;
canvas.height = canvas.width = frameSize;
- canvas.style.width = canvas.style.height = frameSize / pixelRatio + 'px';
+ canvas.style.width = canvas.style.height = cssSize + 'px';
context.lineCap = 'round';
context.lineWidth = lineWidth;
diff --git a/packages/core/src/Chat/XDSChatReasoning.test.tsx b/packages/lab/src/ChatReasoning/XDSChatReasoning.test.tsx
similarity index 100%
rename from packages/core/src/Chat/XDSChatReasoning.test.tsx
rename to packages/lab/src/ChatReasoning/XDSChatReasoning.test.tsx
diff --git a/packages/core/src/Chat/XDSChatReasoning.tsx b/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
similarity index 98%
rename from packages/core/src/Chat/XDSChatReasoning.tsx
rename to packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
index a99267b020..43913765dc 100644
--- a/packages/core/src/Chat/XDSChatReasoning.tsx
+++ b/packages/lab/src/ChatReasoning/XDSChatReasoning.tsx
@@ -14,7 +14,7 @@
*/
import {useState, useCallback, type ReactNode} from 'react';
-import type {XDSBaseProps} from '../XDSBaseProps';
+import type {XDSBaseProps} from '@xds/core/XDSBaseProps';
import * as stylex from '@stylexjs/stylex';
import {
colorVars,
@@ -25,8 +25,8 @@ import {
fontWeightVars,
durationVars,
easeVars,
-} from '../theme/tokens.stylex';
-import {xdsClassName, mergeProps} from '../utils';
+} from '@xds/core/theme/tokens.stylex';
+import {xdsClassName, mergeProps} from '@xds/core/utils';
// =============================================================================
// Types
diff --git a/packages/lab/src/index.ts b/packages/lab/src/index.ts
index 112a9bf7d7..1ab709bad8 100644
--- a/packages/lab/src/index.ts
+++ b/packages/lab/src/index.ts
@@ -17,3 +17,9 @@ export {
SYNC_TOKENIZE_THRESHOLD,
type Token,
} from '@xds/core/CodeBlock';
+
+// Chat — experimental reasoning display
+export {
+ XDSChatReasoning,
+ type XDSChatReasoningProps,
+} from './ChatReasoning/XDSChatReasoning';
diff --git a/packages/themes/daily/src/icons.tsx b/packages/themes/daily/src/icons.tsx
index fbe6b26d34..da610c2ab5 100644
--- a/packages/themes/daily/src/icons.tsx
+++ b/packages/themes/daily/src/icons.tsx
@@ -25,6 +25,7 @@ import {
Columns,
Copy,
CheckCheck,
+ Wrench,
} from 'lucide-react';
const iconProps = {
@@ -56,4 +57,5 @@ export const dailyIconRegistry: XDSIconRegistry = {
viewColumns: <Columns {...iconProps} />,
copy: <Copy {...iconProps} />,
checkDouble: <CheckCheck {...iconProps} />,
+ wrench: <Wrench {...iconProps} />,
};
diff --git a/packages/themes/default/src/icons.tsx b/packages/themes/default/src/icons.tsx
index 025ed24cfa..b5fc3ecf0e 100644
--- a/packages/themes/default/src/icons.tsx
+++ b/packages/themes/default/src/icons.tsx
@@ -30,6 +30,7 @@ import {
EyeSlashIcon,
ViewColumnsIcon,
ClipboardDocumentIcon,
+ WrenchIcon,
} from '@heroicons/react/24/outline';
import {
@@ -69,4 +70,5 @@ export const defaultIconRegistry: XDSIconRegistry = {
viewColumns: <ViewColumnsIcon {...iconProps} />,
copy: <ClipboardDocumentIcon {...iconProps} />,
checkDouble: <CheckIcon {...iconProps} />,
+ wrench: <WrenchIcon {...iconProps} />,
};
diff --git a/packages/themes/meta/src/icons.tsx b/packages/themes/meta/src/icons.tsx
index 0542955882..a00b8aabb0 100644
--- a/packages/themes/meta/src/icons.tsx
+++ b/packages/themes/meta/src/icons.tsx
@@ -31,6 +31,7 @@ import {
EyeSlashIcon,
ViewColumnsIcon,
ClipboardDocumentIcon,
+ WrenchScrewdriverIcon,
} from '@heroicons/react/24/outline';
import {
@@ -70,4 +71,5 @@ export const metaIconRegistry: XDSIconRegistry = {
viewColumns: <ViewColumnsIcon {...iconProps} />,
copy: <ClipboardDocumentIcon {...iconProps} />,
checkDouble: <CheckIcon {...iconProps} />,
+ wrench: <WrenchScrewdriverIcon {...iconProps} />,
};
diff --git a/packages/themes/neutral/src/icons.tsx b/packages/themes/neutral/src/icons.tsx
index 0ea78c6f53..c59c9933c3 100644
--- a/packages/themes/neutral/src/icons.tsx
+++ b/packages/themes/neutral/src/icons.tsx
@@ -35,6 +35,7 @@ import {
Columns,
Copy,
CheckCheck,
+ Wrench,
} from 'lucide-react';
const iconProps = {
@@ -66,4 +67,5 @@ export const neutralIconRegistry: XDSIconRegistry = {
viewColumns: <Columns {...iconProps} />,
copy: <Copy {...iconProps} />,
checkDouble: <CheckCheck {...iconProps} />,
+ wrench: <Wrench {...iconProps} />,
};
diff --git a/packages/themes/whatsapp/src/icons.tsx b/packages/themes/whatsapp/src/icons.tsx
index d8625b8ef0..75c439b70a 100644
--- a/packages/themes/whatsapp/src/icons.tsx
+++ b/packages/themes/whatsapp/src/icons.tsx
@@ -28,6 +28,7 @@ import {
EyeSlashIcon,
ViewColumnsIcon,
ClipboardDocumentIcon,
+ WrenchScrewdriverIcon,
} from '@heroicons/react/24/outline';
import {
@@ -67,4 +68,5 @@ export const whatsappIconRegistry: XDSIconRegistry = {
viewColumns: <ViewColumnsIcon {...iconProps} />,
copy: <ClipboardDocumentIcon {...iconProps} />,
checkDouble: <CheckIcon {...iconProps} />,
+ wrench: <WrenchScrewdriverIcon {...iconProps} />,
};