Skip to content

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

TypeScript

Name ChatToolCalls statuses for assistive technology (#5666)

rubyycheung0443933b693c
diff --git a/.changeset/chat-tool-call-status-a11y.md b/.changeset/chat-tool-call-status-a11y.md
new file mode 100644
index 0000000000..1eca2a3b64
--- /dev/null
+++ b/.changeset/chat-tool-call-status-a11y.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] ChatToolCalls now announces pending, running, complete, and failed statuses to assistive technology, including expandable rows and collapsed tool-call groups. (#5666)
+
+@rubyycheung
diff --git a/packages/core/locales/en.json b/packages/core/locales/en.json
index 3834113dc6..98c365b9fc 100644
--- a/packages/core/locales/en.json
+++ b/packages/core/locales/en.json
@@ -951,6 +951,22 @@
"defaultMessage": "Error: {message}",
"description": "Screen-reader text for a tool call that failed. {message} is the error detail."
},
+ "@astryx.chatToolCalls.status.pending": {
+ "defaultMessage": "Pending",
+ "description": "Screen-reader-only status label for a tool call that is waiting to begin."
+ },
+ "@astryx.chatToolCalls.status.running": {
+ "defaultMessage": "Running",
+ "description": "Screen-reader-only status label for a tool call that is currently running."
+ },
+ "@astryx.chatToolCalls.status.complete": {
+ "defaultMessage": "Complete",
+ "description": "Screen-reader-only status label for a tool call that completed successfully."
+ },
+ "@astryx.chatToolCalls.status.error": {
+ "defaultMessage": "Failed",
+ "description": "Screen-reader-only status label for a failed tool call when no error detail is supplied."
+ },
"@astryx.chatToolCalls.groupLabel": {
"defaultMessage": "{count} tool calls",
"description": "Summary label shown in the group header when multiple tool calls are expanded. {count} is the number of calls."
diff --git a/packages/core/src/Chat/ChatToolCalls.test.tsx b/packages/core/src/Chat/ChatToolCalls.test.tsx
index 15a0b6a34f..fcab2817fc 100644
--- a/packages/core/src/Chat/ChatToolCalls.test.tsx
+++ b/packages/core/src/Chat/ChatToolCalls.test.tsx
@@ -46,6 +46,50 @@ describe('ChatToolCalls', () => {
expect(screen.queryByText('1.2s')).not.toBeInTheDocument();
});
+ it.each([
+ ['pending', 'Pending'],
+ ['running', 'Running'],
+ ['complete', 'Complete'],
+ ['error', 'Failed'],
+ ] as const)(
+ 'names the %s status for assistive technology',
+ (status, label) => {
+ render(<ChatToolCalls calls={[{name: 'bash', status}]} />);
+ expect(screen.getByText(label)).toBeInTheDocument();
+ },
+ );
+
+ it('includes the status in an expandable row accessible name', () => {
+ render(
+ <ChatToolCalls
+ calls={[
+ {
+ name: 'readFile',
+ status: 'running',
+ resultDetail: <div>file contents</div>,
+ },
+ ]}
+ />,
+ );
+ expect(
+ screen.getByRole('button', {name: /Running.*readFile/}),
+ ).toBeInTheDocument();
+ });
+
+ it('includes the latest status in a collapsed group accessible name', () => {
+ render(
+ <ChatToolCalls
+ calls={[
+ {name: 'searchCode', status: 'complete'},
+ {name: 'editFile', status: 'running'},
+ ]}
+ />,
+ );
+ expect(
+ screen.getByRole('button', {name: /Running.*editFile/}),
+ ).toBeInTheDocument();
+ });
+
it('defaults to collapsed', () => {
render(
<ChatToolCalls
diff --git a/packages/core/src/Chat/ChatToolCalls.tsx b/packages/core/src/Chat/ChatToolCalls.tsx
index f22bb1f9cb..19c01c8cd4 100644
--- a/packages/core/src/Chat/ChatToolCalls.tsx
+++ b/packages/core/src/Chat/ChatToolCalls.tsx
@@ -365,6 +365,26 @@ const STATUS_STYLES: Record<
error: styles.colorError,
};
+function getStatusAnnouncement(
+ t: ReturnType<typeof useTranslator>,
+ status: ChatToolCallStatus,
+ errorMessage?: string,
+): string {
+ if (status === 'error' && errorMessage != null) {
+ return t('@astryx.chatToolCalls.error', {message: errorMessage});
+ }
+ switch (status) {
+ case 'pending':
+ return t('@astryx.chatToolCalls.status.pending');
+ case 'running':
+ return t('@astryx.chatToolCalls.status.running');
+ case 'complete':
+ return t('@astryx.chatToolCalls.status.complete');
+ case 'error':
+ return t('@astryx.chatToolCalls.status.error');
+ }
+}
+
function getToolCallKey(call: ChatToolCallItem): string {
return getKey(call.key, () =>
[
@@ -390,6 +410,11 @@ function CallRow({call}: {call: ChatToolCallItem}) {
const hasDetail = call.resultDetail != null;
const [isDetailOpen, setIsDetailOpen] = useState(false);
const detailId = useId();
+ const statusAnnouncement = getStatusAnnouncement(
+ t,
+ status,
+ call.errorMessage,
+ );
const toggleDetail = hasDetail
? () => setIsDetailOpen(prev => !prev)
@@ -417,9 +442,9 @@ function CallRow({call}: {call: ChatToolCallItem}) {
title={status === 'error' ? call.errorMessage : undefined}
{...stylex.props(styles.statusIcon, STATUS_STYLES[status])}>
{status === 'running' ? (
- <Spinner size="sm" shade="subtle" />
+ <Spinner size="sm" shade="subtle" aria-hidden="true" />
) : status === 'pending' ? (
- <Spinner size="sm" shade="subtle" />
+ <Spinner size="sm" shade="subtle" aria-hidden="true" />
) : (
<>
<span {...stylex.props(styles.statusIconCircle)} />
@@ -432,17 +457,7 @@ 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>
- {t('@astryx.chatToolCalls.error', {
- message: call.errorMessage ?? '',
- })}
- </VisuallyHidden>
- )}
+ <VisuallyHidden>{statusAnnouncement}</VisuallyHidden>
</span>
<span {...stylex.props(styles.callName)}>{call.name}</span>
{call.node != null && (
@@ -581,6 +596,11 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
// Multiple calls: latest call at surface with chevron to expand all
const latestCall = calls[calls.length - 1];
const latestStatus = latestCall.status ?? 'complete';
+ const latestStatusAnnouncement = getStatusAnnouncement(
+ t,
+ latestStatus,
+ latestCall.errorMessage,
+ );
return (
<div
@@ -620,9 +640,9 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
<span
{...stylex.props(styles.statusIcon, STATUS_STYLES[latestStatus])}>
{latestStatus === 'running' ? (
- <Spinner size="sm" shade="subtle" />
+ <Spinner size="sm" shade="subtle" aria-hidden="true" />
) : latestStatus === 'pending' ? (
- <Spinner size="sm" shade="subtle" />
+ <Spinner size="sm" shade="subtle" aria-hidden="true" />
) : (
<>
<span {...stylex.props(styles.statusIconCircle)} />
@@ -635,6 +655,7 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
</span>
</>
)}
+ <VisuallyHidden>{latestStatusAnnouncement}</VisuallyHidden>
</span>
<span {...stylex.props(styles.callName)}>{latestCall.name}</span>
{latestCall.target != null && (