An open source design system that's fully customizable and agent ready
TypeScript
fix(core): expose ChatToolCalls error detail to assistive tech (#4005)
Baraa Hamodi73002c99fd65
diff --git a/.changeset/chattoolcalls-error-text.md b/.changeset/chattoolcalls-error-text.mdnew file mode 100644index 0000000000..60ceeaf346--- /dev/null+++ b/.changeset/chattoolcalls-error-text.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] Chat: tool-call error details are now exposed to screen readers and keyboard users instead of living only in a hover-only title attribute.++@bhamodidiff --git a/packages/core/src/Chat/ChatToolCalls.test.tsx b/packages/core/src/Chat/ChatToolCalls.test.tsxindex 232a1e8ddb..f864bca9dd 100644--- a/packages/core/src/Chat/ChatToolCalls.test.tsx+++ b/packages/core/src/Chat/ChatToolCalls.test.tsx@@ -133,6 +133,70 @@ describe('ChatToolCalls', () => {expect(panel).toHaveTextContent('file contents here');});+ it('exposes the error message as text without requiring hover', () => {+ render(+ <ChatToolCalls+ calls={[+ {+ name: 'bash',+ status: 'error',+ errorMessage: 'Command exited with code 1',+ },+ ]}+ />,+ );+ // The message must exist as real (screen-reader-visible) text content,+ // not only inside a hover-only title attribute.+ expect(screen.getByText(/Command exited with code 1/)).toBeInTheDocument();+ });++ it('includes the error message in the accessible name of an expandable error row', () => {+ render(+ <ChatToolCalls+ calls={[+ {+ name: 'bash',+ status: 'error',+ errorMessage: 'Command exited with code 1',+ resultDetail: <div>stderr output</div>,+ },+ ]}+ />,+ );+ expect(+ screen.getByRole('button', {name: /Command exited with code 1/}),+ ).toBeInTheDocument();+ });++ it('keeps the hover tooltip on the error status icon', () => {+ const {container} = render(+ <ChatToolCalls+ calls={[+ {+ name: 'bash',+ status: 'error',+ errorMessage: 'Command exited with code 1',+ },+ ]}+ />,+ );+ expect(+ container.querySelector('[title="Command exited with code 1"]'),+ ).not.toBeNull();+ });++ it('renders no error text for non-error calls', () => {+ render(+ <ChatToolCalls+ calls={[+ {name: 'bash', status: 'complete', errorMessage: 'stale message'},+ ]}+ />,+ );+ expect(screen.queryByText(/stale message/)).not.toBeInTheDocument();+ expect(screen.queryByText(/Error:/)).not.toBeInTheDocument();+ });+it('points the group header aria-controls at the content region', () => {render(<ChatToolCallsdiff --git a/packages/core/src/Chat/ChatToolCalls.tsx b/packages/core/src/Chat/ChatToolCalls.tsxindex 9263fb1e36..58337f287a 100644--- a/packages/core/src/Chat/ChatToolCalls.tsx+++ b/packages/core/src/Chat/ChatToolCalls.tsx@@ -35,6 +35,7 @@ import {getKey, mergeProps} from '../utils';import {Badge} from '../Badge';import {Icon, type IconName} from '../Icon';import {Spinner} from '../Spinner';+import {VisuallyHidden} from '../VisuallyHidden';import {themeProps} from '../utils/themeProps';// =============================================================================@@ -60,7 +61,11 @@ export interface ChatToolCallItem {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. */+ /**+ * Error message when status is 'error'. Rendered as visually hidden text in+ * the row (so screen readers and keyboard users perceive it) and echoed in a+ * hover tooltip on the status icon.+ */errorMessage?: string;/** Unique key for React list rendering. Derived from stable metadata if omitted. */key?: string;@@ -395,6 +400,13 @@ function CallRow({call}: {call: ChatToolCallItem}) {</span></>)}+ {status === 'error' && call.errorMessage != null && (+ // The title attribute above is hover-only; expose the error detail+ // as real text so it reaches screen readers, keyboard, and touch+ // users. Rendering it inside the row also folds it into the+ // accessible name of expandable (role="button") rows.+ <VisuallyHidden>{`Error: ${call.errorMessage}`}</VisuallyHidden>+ )}</span><span {...stylex.props(styles.callName)}>{call.name}</span>{call.node != null && (