An open source design system that's fully customizable and agent ready
TypeScript
feat(Chat): add Reasoning, ToolCall, and ToolCallGroup components (#1192)
Cindy Zhang572a5ffb92dc
diff --git a/apps/storybook/stories/ChatReasoning.stories.tsx b/apps/storybook/stories/ChatReasoning.stories.tsxnew file mode 100644index 0000000000..534ed56fea--- /dev/null+++ b/apps/storybook/stories/ChatReasoning.stories.tsx@@ -0,0 +1,105 @@+import type {Meta, StoryObj} from '@storybook/react';+import {+ XDSChatMessageList,+ XDSChatMessage,+ XDSChatMessageBubble,+ XDSChatReasoning,+} from '@xds/core/Chat';+import {XDSAvatar} from '@xds/core/Avatar';+import {XDSMarkdown} from '@xds/core/Markdown';+import {useState, useEffect} from 'react';++const meta: Meta = {+ title: 'Chat/XDSChatReasoning',+ component: XDSChatReasoning,+ tags: ['autodocs'],+ parameters: {+ layout: 'centered',+ },+ decorators: [+ Story => (+ <div style={{width: 600, padding: 40}}>+ <Story />+ </div>+ ),+ ],+};+export default meta;++/** Collapsed (default) — shows label, duration, and ellipsis preview */+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...+ </XDSChatReasoning>+ ),+};++/** Expanded — shows full reasoning content */+export const Expanded: StoryObj = {+ render: () => (+ <XDSChatReasoning duration="8s" defaultIsExpanded>+ <XDSMarkdown density="compact">{`First, I need to understand the constraints:+1. Three fields, three crops (wheat, corn, soy)+2. No adjacent fields can have the same crop+3. No field can repeat its crop from the previous year++For **Year 1**: 3 \u00d7 2 \u00d7 2 = 12 arrangements...`}</XDSMarkdown>+ </XDSChatReasoning>+ ),+};++/** Streaming — shimmer effect on label while thinking */+export const Streaming: StoryObj = {+ render: () => {+ const [streaming, setStreaming] = useState(true);+ useEffect(() => {+ const t = setTimeout(() => setStreaming(false), 5000);+ return () => clearTimeout(t);+ }, []);+ return (+ <div>+ <XDSChatReasoning isStreaming={streaming} label="Thinking">+ Working through the combinatorial constraints...+ </XDSChatReasoning>+ {!streaming && (+ <p style={{marginTop: 8, fontSize: 13, color: '#888'}}>+ (Shimmer stopped after 5s)+ </p>+ )}+ </div>+ );+ },+};++/** Custom label */+export const CustomLabel: StoryObj = {+ render: () => (+ <XDSChatReasoning label="Analyzing" duration="3s">+ Checking the codebase for similar patterns...+ </XDSChatReasoning>+ ),+};++/** In a message — reasoning above the response */+export const InMessage: StoryObj = {+ render: () => (+ <XDSChatMessageList>+ <XDSChatMessage sender="user">+ <XDSChatMessageBubble>+ How many valid planting arrangements are possible over 3 years?+ </XDSChatMessageBubble>+ </XDSChatMessage>+ <XDSChatMessage+ sender="assistant"+ avatar={<XDSAvatar name="AI" size="small" />}>+ <XDSChatReasoning duration="12s">+ Let me work through the constraints systematically...+ </XDSChatReasoning>+ <XDSMarkdown density="compact">{`There are **42** valid planting arrangements over 3 years.`}</XDSMarkdown>+ </XDSChatMessage>+ </XDSChatMessageList>+ ),+};diff --git a/apps/storybook/stories/ChatToolCalls.stories.tsx b/apps/storybook/stories/ChatToolCalls.stories.tsxnew file mode 100644index 0000000000..bbd5cf469a--- /dev/null+++ b/apps/storybook/stories/ChatToolCalls.stories.tsx@@ -0,0 +1,328 @@+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',+ component: XDSChatToolCalls,+ tags: ['autodocs'],+ parameters: {+ layout: 'centered',+ },+ decorators: [+ Story => (+ <div style={{width: 500, padding: 40}}>+ <Story />+ </div>+ ),+ ],+};++export default meta;+type Story = StoryObj<typeof XDSChatToolCalls>;++// =============================================================================+// Stories+// =============================================================================++/** Single tool call — renders inline, no group chrome */+export const SingleCall: Story = {+ render: () => (+ <XDSChatToolCalls+ calls={[+ {name: 'bash', label: 'git status', status: 'complete', duration: '1.2s'},+ ]}+ />+ ),+};++/** Multiple calls — pile visual with collapsible group */+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}},+ ]}+ />+ ),+};++/** With node badges — shows which sandbox ran each tool */+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'},+ ]}+ />+ ),+};++/** With stats — additions, deletions, file counts */+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}},+ ]}+ />+ ),+};++/** Error state — shows error indicator on group and individual calls */+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'},+ ]}+ />+ ),+};++/** Running state — spinner on active calls */+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'},+ ]}+ />+ ),+};++/** Streaming — tool calls arrive one by one with status transitions */+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'},+ ];++ const [calls, setCalls] = useState<XDSChatToolCallItem[]>([]);+ const [isRunning, setIsRunning] = useState(false);++ const start = useCallback(() => {+ setCalls([]);+ setIsRunning(true);+ let i = 0;++ const addNext = () => {+ if (i >= allCalls.length) {+ setIsRunning(false);+ return;+ }+ // Add as running+ const call = allCalls[i]!;+ 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);++ i++;+ };++ addNext();+ }, []);++ return (+ <div style={{display: 'flex', flexDirection: 'column', gap: 16}}>+ <button+ onClick={start}+ disabled={isRunning}+ style={{+ padding: '8px 16px',+ borderRadius: 8,+ border: '1px solid #ccc',+ cursor: isRunning ? 'not-allowed' : 'pointer',+ opacity: isRunning ? 0.5 : 1,+ }}>+ {isRunning ? 'Running...' : 'Start streaming'}+ </button>+ {calls.length > 0 && <XDSChatToolCalls calls={calls} />}+ </div>+ );+ },+};++/** Many calls — auto-collapses when >3 */+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'},+ ]}+ />+ ),+};++/** 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({+ gap: spacingVars['--spacing-2'],+ paddingBlock: spacingVars['--spacing-2'],+ paddingInline: spacingVars['--spacing-3'],+- '--button-radius': radiusVars['--radius-element'],+- borderRadius: 'var(--button-radius)',++ borderRadius: 'var(--button-radius, var(--radius-element))',+ fontFamily: 'inherit',+ fontSize: typeScaleVars['--text-label-size'],+ lineHeight: typeScaleVars['--text-label-leading'],+@@ -93,6 +93,10 @@ const styles = stylex.create({+ '--button-icon-only-aspect': '1 / 1',+ aspectRatio: 'var(--button-icon-only-aspect)',+ },++ // Focus ring offset for accessibility++ focusVisible: {++ outline: '2px solid var(--color-ring-focus)',++ outlineOffset: '2px',++ },+ });`;++ const testOutput = `$ yarn test+ PASS packages/core/src/Button/XDSButton.test.tsx+ PASS packages/core/src/Chat/XDSChatToolCalls.test.tsx+ PASS packages/core/src/Chat/XDSChatComposerInput.test.tsx++Test Suites: 7 passed, 7 total+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}+ </>+ );+ },+};++/** Error with modal — clicking a failed call shows error detail with banner */+export const ErrorWithModal: 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++ ● XDSChatToolCalls > renders group header for multiple calls++ 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}+ </>+ );+ },+};diff --git a/packages/core/src/Chat/XDSChatReasoning.test.tsx b/packages/core/src/Chat/XDSChatReasoning.test.tsxnew file mode 100644index 0000000000..806f0c27bf--- /dev/null+++ b/packages/core/src/Chat/XDSChatReasoning.test.tsx@@ -0,0 +1,55 @@+import {render, screen, fireEvent} from '@testing-library/react';+import {XDSChatReasoning} from './XDSChatReasoning';++describe('XDSChatReasoning', () => {+ it('renders collapsed by default', () => {+ render(<XDSChatReasoning>Some reasoning text</XDSChatReasoning>);+ expect(screen.getByText('Thinking')).toBeInTheDocument();+ expect(screen.getByRole('button')).toHaveAttribute(+ 'aria-expanded',+ 'false',+ );+ });++ it('shows preview text when collapsed', () => {+ render(+ <XDSChatReasoning>+ Some reasoning text about constraints+ </XDSChatReasoning>,+ );+ expect(+ screen.getAllByText('Some reasoning text about constraints').length,+ ).toBeGreaterThanOrEqual(1);+ });++ it('expands on click', () => {+ render(<XDSChatReasoning>Reasoning content here</XDSChatReasoning>);+ const button = screen.getByRole('button');+ fireEvent.click(button);+ expect(button).toHaveAttribute('aria-expanded', 'true');+ });++ it('shows duration when not streaming', () => {+ render(<XDSChatReasoning duration="12s">Text</XDSChatReasoning>);+ expect(screen.getByText('12s')).toBeInTheDocument();+ });++ it('hides duration when streaming', () => {+ render(+ <XDSChatReasoning duration="12s" isStreaming>+ Text+ </XDSChatReasoning>,+ );+ expect(screen.queryByText('12s')).not.toBeInTheDocument();+ });++ it('supports custom label', () => {+ render(<XDSChatReasoning label="Processing">Text</XDSChatReasoning>);+ expect(screen.getByText('Processing')).toBeInTheDocument();+ });++ it('supports defaultIsExpanded', () => {+ render(<XDSChatReasoning defaultIsExpanded>Content</XDSChatReasoning>);+ expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');+ });+});diff --git a/packages/core/src/Chat/XDSChatReasoning.tsx b/packages/core/src/Chat/XDSChatReasoning.tsxnew file mode 100644index 0000000000..a99267b020--- /dev/null+++ b/packages/core/src/Chat/XDSChatReasoning.tsx@@ -0,0 +1,318 @@+'use client';++/**+ * @file XDSChatReasoning.tsx+ * @input Uses React, StyleX, theme tokens+ * @output Exports XDSChatReasoning component+ * @position Chat component — compact collapsible reasoning/thinking display+ *+ * Renders model reasoning/thinking content as a compact single-line+ * collapsed element. Expanding reveals the full reasoning text.+ *+ * Design: extremely compact by default. One line with ellipsis overflow.+ * Expandable on click.+ */++import {useState, useCallback, type ReactNode} from 'react';+import type {XDSBaseProps} from '../XDSBaseProps';+import * as stylex from '@stylexjs/stylex';+import {+ colorVars,+ spacingVars,+ radiusVars,+ typeScaleVars,+ typographyVars,+ fontWeightVars,+ durationVars,+ easeVars,+} from '../theme/tokens.stylex';+import {xdsClassName, mergeProps} from '../utils';++// =============================================================================+// Types+// =============================================================================++export interface XDSChatReasoningProps extends XDSBaseProps<HTMLDivElement> {+ /** Reasoning content. String renders as plain text; ReactNode for XDSMarkdown etc. */+ children: ReactNode;+ /** Header label. @default 'Thinking' */+ label?: string;+ /** Duration string shown after label (e.g. "12s"). */+ duration?: string;+ /** Whether reasoning is still streaming. Shows shimmer on label. */+ isStreaming?: boolean;+ /** Controlled expanded state. */+ isExpanded?: boolean;+ /** Default expanded state (uncontrolled). @default false */+ defaultIsExpanded?: boolean;+ /** Callback when expanded state changes. */+ onExpandedChange?: (isExpanded: boolean) => void;+}++// =============================================================================+// Animations+// =============================================================================++const shimmerKeyframes = stylex.keyframes({+ '0%': {backgroundPosition: '200% 0'},+ '100%': {backgroundPosition: '-200% 0'},+});++// =============================================================================+// Styles+// =============================================================================++const styles = stylex.create({+ root: {+ display: 'flex',+ flexDirection: 'column',+ marginBlockStart: spacingVars['--spacing-2'],+ },+ header: {+ display: 'flex',+ alignItems: 'center',+ gap: spacingVars['--spacing-1-5'],+ cursor: 'pointer',+ userSelect: 'none',+ minHeight: '24px',+ paddingBlock: spacingVars['--spacing-0-5'],+ },+ icon: {+ display: 'inline-flex',+ alignItems: 'center',+ justifyContent: 'center',+ flexShrink: 0,+ width: '16px',+ height: '16px',+ color: colorVars['--color-text-secondary'],+ },+ labelRow: {+ display: 'flex',+ alignItems: 'center',+ gap: spacingVars['--spacing-1'],+ minWidth: 0,+ overflow: 'hidden',+ },+ label: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ fontWeight: fontWeightVars['--font-weight-medium'],+ color: colorVars['--color-text-secondary'],+ whiteSpace: 'nowrap',+ flexShrink: 0,+ },+ duration: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-disabled'],+ whiteSpace: 'nowrap',+ flexShrink: 0,+ },+ separator: {+ fontSize: typeScaleVars['--text-supporting-size'],+ color: colorVars['--color-text-disabled'],+ flexShrink: 0,+ },+ preview: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-disabled'],+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ minWidth: 0,+ },+ chevron: {+ 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']}`,+ },+ chevronExpanded: {+ transform: 'rotate(180deg)',+ },+ shimmer: {+ backgroundImage: `linear-gradient(90deg, ${colorVars['--color-text-secondary']} 0%, ${colorVars['--color-text-disabled']} 50%, ${colorVars['--color-text-secondary']} 100%)`,+ backgroundSize: '200% 100%',+ backgroundClip: 'text',+ color: 'transparent',+ animationName: shimmerKeyframes,+ animationDuration: '4s',+ animationTimingFunction: 'linear',+ animationIterationCount: 'infinite',+ },+ content: {+ display: 'grid',+ gridTemplateRows: '0fr',+ transition: `grid-template-rows ${durationVars['--duration-medium']} ${easeVars['--ease-standard']}`,+ },+ contentExpanded: {+ gridTemplateRows: '1fr',+ },+ contentInner: {+ overflow: 'hidden',+ minHeight: 0,+ },+ contentPadding: {+ paddingBlockStart: spacingVars['--spacing-2'],+ paddingInlineStart: `calc(16px + ${spacingVars['--spacing-1-5']})`,+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-secondary'],+ },+});++// =============================================================================+// Icons+// =============================================================================++function ThinkingIcon() {+ 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="3 2"+ />+ <circle cx="5.5" cy="7" r="0.75" fill="currentColor" />+ <circle cx="8.5" cy="7" r="0.75" fill="currentColor" />+ </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>+ );+}++// =============================================================================+// Component+// =============================================================================++/**+ * Compact collapsible display for model reasoning/thinking content.+ *+ * Renders as a single line: icon + label + duration + ellipsized preview.+ * Expands to show full reasoning on click.+ *+ * @example+ * ```+ * <XDSChatMessage sender="assistant">+ * <XDSChatReasoning duration="12s">+ * Let me work through the constraints on adjacent fields...+ * </XDSChatReasoning>+ * <XDSMarkdown>{response}</XDSMarkdown>+ * </XDSChatMessage>+ * ```+ */+export function XDSChatReasoning(props: XDSChatReasoningProps) {+ const {+ children,+ label = 'Thinking',+ duration,+ isStreaming = false,+ isExpanded: controlledExpanded,+ defaultIsExpanded = false,+ onExpandedChange,+ xstyle,+ className,+ style,+ ...rest+ } = props;++ const [internalExpanded, setInternalExpanded] = useState(defaultIsExpanded);+ const isControlled = controlledExpanded !== undefined;+ const isExpanded = isControlled ? controlledExpanded : internalExpanded;++ const toggle = useCallback(() => {+ const next = !isExpanded;+ if (!isControlled) setInternalExpanded(next);+ onExpandedChange?.(next);+ }, [isExpanded, isControlled, onExpandedChange]);++ const previewText = typeof children === 'string' ? children : null;++ return (+ <div+ {...mergeProps(+ xdsClassName('chat-reasoning', {+ expanded: isExpanded ? 'expanded' : null,+ streaming: isStreaming ? 'streaming' : null,+ }),+ stylex.props(styles.root, xstyle),+ className,+ style,+ )}+ {...rest}>+ <div+ role="button"+ tabIndex={0}+ aria-expanded={isExpanded}+ onClick={toggle}+ onKeyDown={e => {+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ toggle();+ }+ }}+ {...stylex.props(styles.header)}>+ <span {...stylex.props(styles.icon)}>+ <ThinkingIcon />+ </span>+ <div {...stylex.props(styles.labelRow)}>+ <span {...stylex.props(styles.label, isStreaming && styles.shimmer)}>+ {label}+ </span>+ {duration != null && !isStreaming && (+ <>+ <span {...stylex.props(styles.separator)}>·</span>+ <span {...stylex.props(styles.duration)}>{duration}</span>+ </>+ )}+ {!isExpanded && previewText && !isStreaming && (+ <>+ <span {...stylex.props(styles.separator)}>—</span>+ <span {...stylex.props(styles.preview)}>{previewText}</span>+ </>+ )}+ </div>+ <span+ {...stylex.props(+ styles.chevron,+ isExpanded && styles.chevronExpanded,+ )}>+ <ChevronDownIcon />+ </span>+ </div>++ <div+ {...stylex.props(styles.content, isExpanded && styles.contentExpanded)}>+ <div {...stylex.props(styles.contentInner)}>+ <div {...stylex.props(styles.contentPadding)}>{children}</div>+ </div>+ </div>+ </div>+ );+}++XDSChatReasoning.displayName = 'XDSChatReasoning';diff --git a/packages/core/src/Chat/XDSChatToolCalls.test.tsx b/packages/core/src/Chat/XDSChatToolCalls.test.tsxnew file mode 100644index 0000000000..ca7199fc3e--- /dev/null+++ b/packages/core/src/Chat/XDSChatToolCalls.test.tsx@@ -0,0 +1,106 @@+import {render, screen, fireEvent} from '@testing-library/react';+import {XDSChatToolCalls} from './XDSChatToolCalls';++describe('XDSChatToolCalls', () => {+ it('renders nothing for empty calls', () => {+ const {container} = render(<XDSChatToolCalls calls={[]} />);+ expect(container.firstChild).toBeNull();+ });++ it('renders single call inline without group chrome', () => {+ render(+ <XDSChatToolCalls+ calls={[{name: 'bash', status: 'complete', duration: '1.2s'}]}+ />,+ );+ expect(screen.getByText('bash')).toBeInTheDocument();+ expect(screen.getByText('1.2s')).toBeInTheDocument();+ // No group header / expand button for single call+ expect(screen.queryByRole('button')).not.toBeInTheDocument();+ });++ it('renders group header for multiple calls', () => {+ render(+ <XDSChatToolCalls+ calls={[+ {name: 'searchCode', status: 'complete'},+ {name: 'readFile', status: 'complete'},+ {name: 'editFile', status: 'running'},+ ]}+ />,+ );+ expect(screen.getByText('3 tool calls')).toBeInTheDocument();+ expect(screen.getByRole('button')).toBeInTheDocument();+ });++ it('hides duration when not complete', () => {+ render(+ <XDSChatToolCalls+ calls={[{name: 'bash', status: 'running', duration: '1.2s'}]}+ />,+ );+ expect(screen.queryByText('1.2s')).not.toBeInTheDocument();+ });++ it('supports custom label', () => {+ 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', 'true');+ });++ it('auto-collapses groups of more than 3', () => {+ render(+ <XDSChatToolCalls+ calls={[{name: 'a'}, {name: 'b'}, {name: 'c'}, {name: 'd'}]}+ />,+ );+ expect(screen.getByRole('button')).toHaveAttribute(+ 'aria-expanded',+ 'false',+ );+ });++ it('toggles on click', () => {+ render(+ <XDSChatToolCalls+ defaultIsExpanded={false}+ calls={[+ {name: 'a', status: 'complete'},+ {name: 'b', status: 'complete'},+ ]}+ />,+ );+ const btn = screen.getByRole('button');+ expect(btn).toHaveAttribute('aria-expanded', 'false');+ fireEvent.click(btn);+ expect(btn).toHaveAttribute('aria-expanded', 'true');+ });++ it('shows label when provided', () => {+ render(+ <XDSChatToolCalls+ calls={[{name: 'bash', label: '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.tsxnew file mode 100644index 0000000000..2710767088--- /dev/null+++ b/packages/core/src/Chat/XDSChatToolCalls.tsx@@ -0,0 +1,597 @@+'use client';++/**+ * @file XDSChatToolCalls.tsx+ * @input Uses React, StyleX, theme tokens+ * @output Exports XDSChatToolCalls component+ * @position Chat component — displays tool/function call invocations+ *+ * Single component that handles both individual and grouped tool calls.+ * Accepts an array of call data matching the shape LLM APIs already return.+ * Single call renders inline; multiple calls get a collapsible summary.+ *+ * Design rationale: every LLM API (Vercel AI SDK, Anthropic, OpenAI)+ * returns tool calls as an array on the message. One component with a+ * data prop matches that shape directly — no nested compound components+ * for builders to wire up.+ */++import React, {useState, useCallback, type ReactNode} from 'react';+import type {XDSBaseProps} from '../XDSBaseProps';+import * as stylex from '@stylexjs/stylex';+import {+ colorVars,+ spacingVars,+ typeScaleVars,+ typographyVars,+ fontWeightVars,+ radiusVars,+ durationVars,+ easeVars,+} from '../theme/tokens.stylex';+import {xdsClassName, mergeProps} from '../utils';+import {XDSBadge} from '../Badge';++// =============================================================================+// Types+// =============================================================================++export type XDSChatToolCallStatus =+ | 'pending'+ | 'running'+ | '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;+ /** 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;+ /** 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;+}++export interface XDSChatToolCallsProps extends XDSBaseProps<HTMLDivElement> {+ /** Array of tool call data. */+ calls: XDSChatToolCallItem[];+ /** Custom summary label for groups. Auto-generated from count if omitted. */+ label?: string;+ /** Whether the group is expanded. Uncontrolled by default. */+ isExpanded?: boolean;+ /** Default expanded state. @default true for ≤3 calls, false for >3. */+ defaultIsExpanded?: boolean;+ /** Callback when expanded state changes. */+ onExpandedChange?: (isExpanded: boolean) => void;+}++// =============================================================================+// 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+// =============================================================================++const styles = stylex.create({+ root: {+ display: 'flex',+ flexDirection: 'column',+ marginBlockStart: spacingVars['--spacing-2'],+ },+ groupHeader: {+ display: 'flex',+ alignItems: 'center',+ gap: spacingVars['--spacing-1-5'],+ cursor: 'pointer',+ userSelect: 'none',+ minHeight: '24px',+ paddingBlock: spacingVars['--spacing-0-5'],+ },+ groupIcon: {+ display: 'inline-flex',+ alignItems: 'center',+ justifyContent: 'center',+ flexShrink: 0,+ width: '16px',+ height: '16px',+ color: colorVars['--color-text-secondary'],+ },+ groupLabel: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ fontWeight: fontWeightVars['--font-weight-medium'],+ color: colorVars['--color-text-secondary'],+ },+ chevron: {+ 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']}`,+ },+ chevronExpanded: {+ transform: 'rotate(180deg)',+ },+ groupContent: {+ display: 'grid',+ gridTemplateRows: '0fr',+ transition: `grid-template-rows ${durationVars['--duration-medium']} ${easeVars['--ease-standard']}`,+ },+ groupContentExpanded: {+ gridTemplateRows: '1fr',+ },+ groupContentInner: {+ overflow: 'hidden',+ minHeight: 0,+ },+ list: {+ display: 'flex',+ flexDirection: 'column',+ },+ listIndented: {+ paddingInlineStart: spacingVars['--spacing-2'],+ },++ // Individual call row+ callRow: {+ display: 'flex',+ alignItems: 'center',+ gap: spacingVars['--spacing-1-5'],+ minHeight: '24px',+ paddingBlock: spacingVars['--spacing-0-5'],+ },+ callRowClickable: {+ cursor: 'pointer',+ borderRadius: radiusVars['--radius-element'],+ paddingInline: spacingVars['--spacing-1'],+ marginInline: `calc(-1 * ${spacingVars['--spacing-1']})`,+ ':hover': {+ backgroundColor: colorVars['--color-overlay-hover'],+ },+ },+ statusIcon: {+ display: 'inline-flex',+ alignItems: 'center',+ justifyContent: 'center',+ flexShrink: 0,+ width: '16px',+ height: '16px',+ },+ spinning: {+ animationName: spinKeyframes,+ animationDuration: '1s',+ animationTimingFunction: 'linear',+ animationIterationCount: 'infinite',+ },+ pulsing: {+ animationName: pulseKeyframes,+ animationDuration: '1.5s',+ animationTimingFunction: 'ease-in-out',+ animationIterationCount: 'infinite',+ },+ callName: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-code'],+ fontWeight: fontWeightVars['--font-weight-medium'],+ color: colorVars['--color-text-secondary'],+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ minWidth: 0,+ },+ callLabel: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-disabled'],+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ minWidth: 0,+ },+ callDuration: {+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-disabled'],+ whiteSpace: 'nowrap',+ flexShrink: 0,+ },+ nodePill: {+ flexShrink: 0,+ },+ stats: {+ display: 'flex',+ alignItems: 'center',+ gap: spacingVars['--spacing-1'],+ fontSize: typeScaleVars['--text-supporting-size'],+ lineHeight: typeScaleVars['--text-supporting-leading'],+ fontFamily: typographyVars['--font-family-body'],+ color: colorVars['--color-text-disabled'],+ flexShrink: 0,+ },+ statsAdditions: {+ color: colorVars['--color-success'],+ },+ statsDeletions: {+ color: colorVars['--color-error'],+ },+ errorText: {+ color: colorVars['--color-error'],+ },+ // Pile effect for grouped tool calls+ pileWrapper: {+ position: 'relative',+ },+ pileCard: {+ position: 'absolute',+ insetInline: 0,+ top: 0,+ height: '100%',+ borderRadius: radiusVars['--radius-element'],+ backgroundColor: colorVars['--color-background-muted'],+ opacity: 0.5,+ },+ pileCard1: {+ transform: 'translateY(-3px) scale(0.985)',+ opacity: 0.3,+ },+ pileCard2: {+ transform: 'translateY(-6px) scale(0.97)',+ opacity: 0.15,+ },++ // Status colors+ colorPending: {color: colorVars['--color-text-disabled']},+ colorRunning: {color: colorVars['--color-accent']},+ colorComplete: {color: colorVars['--color-success']},+ colorError: {color: colorVars['--color-error']},+});++// =============================================================================+// 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_STYLES: Record<+ XDSChatToolCallStatus,+ ReturnType<typeof stylex.create>[string]+> = {+ pending: styles.colorPending,+ running: styles.colorRunning,+ complete: styles.colorComplete,+ error: styles.colorError,+};++// =============================================================================+// Internal: single call row+// =============================================================================++function CallRow({+ call,+}: {+ call: XDSChatToolCallItem;+}) {+ const status = call.status ?? 'complete';+ const Icon = STATUS_ICONS[status];+ const isClickable = call.onClick != null;++ 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?.();+ }+ } : undefined}+ {...stylex.props(+ styles.callRow,+ isClickable && styles.callRowClickable,+ )}>+ <span+ title={status === 'error' ? call.errorMessage : undefined}+ {...stylex.props(+ styles.statusIcon,+ STATUS_STYLES[status],+ status === 'running' && styles.spinning,+ status === 'pending' && styles.pulsing,+ )}>+ <Icon />+ </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>+ );+}++// =============================================================================+// Component+// =============================================================================++/**+ * Displays tool/function call invocations from an LLM response.+ *+ * Accepts a `calls` array matching the shape LLM APIs return. Single call+ * renders inline without group chrome. Multiple calls get a collapsible+ * summary header.+ *+ * @example+ * ```+ * // Basic — pass the array from your LLM response+ * <XDSChatToolCalls+ * calls={message.toolCalls.map(tc => ({+ * name: tc.toolName,+ * status: tc.state,+ * duration: tc.duration,+ * }))}+ * />+ * ```+ *+ * @example+ * ```+ * // With detail rendering+ * <XDSChatToolCalls+ * calls={toolCalls}+ * renderDetail={(call) => (+ * <XDSCodeBlock code={call.args} language="json" />+ * )}+ * />+ * ```+ */+export function XDSChatToolCalls(props: XDSChatToolCallsProps) {+ const {+ calls,+ label: customLabel,+ isExpanded: controlledExpanded,+ defaultIsExpanded,+ onExpandedChange,+ xstyle,+ className,+ style,+ ...rest+ } = props;++ 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 [internalExpanded, setInternalExpanded] = useState(autoDefault);+ const isControlled = controlledExpanded !== undefined;+ const isExpanded = isControlled ? controlledExpanded : internalExpanded;++ const toggle = useCallback(() => {+ const next = !isExpanded;+ if (!isControlled) setInternalExpanded(next);+ onExpandedChange?.(next);+ }, [isExpanded, isControlled, onExpandedChange]);++ if (calls.length === 0) return null;++ // Single call: render inline, no group chrome+ if (calls.length === 1) {+ return (+ <div+ {...mergeProps(+ xdsClassName('chat-tool-calls'),+ stylex.props(styles.root, xstyle),+ className,+ style,+ )}+ {...rest}>+ <CallRow call={calls[0]} />+ </div>+ );+ }++ // Multiple calls: collapsible group+ const label = customLabel ?? `${calls.length} tool calls`;+ const errorLabel = hasErrors ? (+ <>+ {label} · <span {...stylex.props(styles.errorText)}>{errorCount} failed</span>+ </>+ ) : label;++ return (+ <div+ {...mergeProps(+ xdsClassName('chat-tool-calls'),+ stylex.props(styles.root, xstyle),+ className,+ style,+ )}+ {...rest}>+ <div+ role="button"+ tabIndex={0}+ aria-expanded={isExpanded}+ onClick={toggle}+ onKeyDown={e => {+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ toggle();+ }+ }}+ {...stylex.props(styles.groupHeader)}>+ <span {...stylex.props(styles.groupIcon)}>+ <WrenchIcon />+ </span>+ <span {...stylex.props(styles.groupLabel)}>{errorLabel}</span>+ <span+ {...stylex.props(+ styles.chevron,+ isExpanded && styles.chevronExpanded,+ )}>+ <ChevronDownIcon />+ </span>+ </div>++ <div+ {...stylex.props(+ styles.groupContent,+ isExpanded && styles.groupContentExpanded,+ )}>+ <div {...stylex.props(styles.groupContentInner)}>+ <div {...stylex.props(styles.list, styles.listIndented)}>+ {calls.map((call, i) => (+ <CallRow+ key={call.key ?? i}+ call={call}+ />+ ))}+ </div>+ </div>+ </div>+ </div>+ );+}++XDSChatToolCalls.displayName = 'XDSChatToolCalls';diff --git a/packages/core/src/Chat/index.ts b/packages/core/src/Chat/index.tsindex 2fa6e8b96b..0d4244c4fd 100644--- a/packages/core/src/Chat/index.ts+++ b/packages/core/src/Chat/index.ts@@ -55,3 +55,14 @@ export {useAutoScroll} from './useAutoScroll';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/CodeBlock/XDSCodeBlock.tsx b/packages/core/src/CodeBlock/XDSCodeBlock.tsxindex baeb2454bd..5571cd8179 100644--- a/packages/core/src/CodeBlock/XDSCodeBlock.tsx+++ b/packages/core/src/CodeBlock/XDSCodeBlock.tsx@@ -46,6 +46,8 @@ import {applyHighlightRangesChunked} from './highlightRanges';const styles = stylex.create({root: {position: 'relative',+ display: 'flex',+ flexDirection: 'column',margin: 0,borderRadius: radiusVars['--radius-element'],backgroundColor: 'var(--color-syntax-background)',