Skip to content

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

TypeScript

fix(ChatSystemMessage): leave notices inside a chat log to the log (#7869)

Cindy Zhang0a4c894d5c4c
diff --git a/.changeset/chatsystemmessage-no-live-role.md b/.changeset/chatsystemmessage-no-live-role.md
new file mode 100644
index 0000000000..a30f918813
--- /dev/null
+++ b/.changeset/chatsystemmessage-no-live-role.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] `ChatSystemMessage` no longer forces `role="status"` on its root, in either variant, so a new chat notice inside a `ChatMessageList` has one live owner, the list's polite log, instead of being a second live region nested in it (WCAG 2.2 SC 4.1.3 Status Messages; `spec:AST-086` FR1 and FR4). Date and divider rows are no longer presented as status messages. Before, every system message was a status region inside the list's polite log; now the log owns content added inside it, and a `role` passed to the component reaches its root. Tests that found a system message by the `status` role should query it by its text instead.
+
+@cixzhang
diff --git a/apps/storybook/stories/StatusMessageA11y.stories.tsx b/apps/storybook/stories/StatusMessageA11y.stories.tsx
index 809cf85bd1..0edb9da8da 100644
--- a/apps/storybook/stories/StatusMessageA11y.stories.tsx
+++ b/apps/storybook/stories/StatusMessageA11y.stories.tsx
@@ -77,7 +77,6 @@ export const SpinnerDefaultLabelMounted = coreStory(
export const SpinnerVisibleLabelMounted = coreStory(
'spinner-visible-label-mounted',
);
-export const ChatSystemStatusMounted = coreStory('chat-system-status-mounted');
export const ProgressLoadingToComplete = coreStory(
'progress-loading-to-complete',
);
diff --git a/packages/core/src/Chat/ChatSystemMessage.doc.mjs b/packages/core/src/Chat/ChatSystemMessage.doc.mjs
index 911607b28a..978981c2d8 100644
--- a/packages/core/src/Chat/ChatSystemMessage.doc.mjs
+++ b/packages/core/src/Chat/ChatSystemMessage.doc.mjs
@@ -52,7 +52,7 @@ export const docs = {
},
usage: {
description:
- 'Use ChatSystemMessage for concise, non-sender content inside a chat transcript. Choose the default variant for factual status notices and the divider variant for date or section breaks. Long default content wraps within the available width. The component exposes status semantics and the divider branch includes a labelled separator.',
+ 'Use ChatSystemMessage for concise, non-sender content inside a chat transcript. Choose the default variant for factual status notices and the divider variant for date or section breaks. Long default content wraps within the available width. It carries no live role: inside a ChatMessageList, the log announces new notices. The divider branch includes a labelled separator.',
bestPractices: [
{
guidance: true,
diff --git a/packages/core/src/Chat/ChatSystemMessage.test.tsx b/packages/core/src/Chat/ChatSystemMessage.test.tsx
index 502cd7709e..1d37107cd2 100644
--- a/packages/core/src/Chat/ChatSystemMessage.test.tsx
+++ b/packages/core/src/Chat/ChatSystemMessage.test.tsx
@@ -4,6 +4,7 @@ import {createRef, Fragment} from 'react';
import {describe, expect, it} from 'vitest';
import {render, screen} from '@testing-library/react';
import * as stylex from '@stylexjs/stylex';
+import {ChatMessageList} from './ChatMessageList';
import {ChatSystemMessage} from './ChatSystemMessage';
const xstyleProbe = stylex.create({
@@ -100,7 +101,7 @@ describe('ChatSystemMessage', () => {
expect(root).toHaveStyle({outlineOffset: '3px'});
expectProbeClasses(root);
expect(root).toHaveAttribute('aria-label', `${variant} system message`);
- expect(root).toHaveAttribute('role', 'status');
+ expect(root).toHaveAttribute('role', 'note');
expect(root).toHaveAttribute('data-variant', variant);
},
);
@@ -125,7 +126,7 @@ describe('ChatSystemMessage', () => {
</ChatSystemMessage>,
);
const root = screen.getByTestId('empty-partition');
- expect(root).toHaveAttribute('role', 'status');
+ expect(root).not.toHaveAttribute('role');
expect(root).toHaveTextContent(text);
});
@@ -148,7 +149,7 @@ describe('ChatSystemMessage', () => {
</ChatSystemMessage>,
);
const root = screen.getByTestId('empty-partition');
- expect(root).toHaveAttribute('role', 'status');
+ expect(root).not.toHaveAttribute('role');
expect(root).toContainElement(screen.getByRole('separator'));
});
@@ -164,4 +165,25 @@ describe('ChatSystemMessage', () => {
expect(separator).toHaveAccessibleName('0');
expect(separator).toHaveAttribute('aria-labelledby');
});
+
+ it.each(['default', 'divider'] as const)(
+ 'leaves a %s row inside a chat log to the log (spec:AST-086 FR4)',
+ variant => {
+ render(
+ <ChatMessageList>
+ <ChatSystemMessage variant={variant} data-testid="notice">
+ Ana joined
+ </ChatSystemMessage>
+ </ChatMessageList>,
+ );
+ const notice = screen.getByTestId('notice');
+ expect(notice.closest('[role="log"]')).not.toBeNull();
+ for (const el of [notice, ...notice.querySelectorAll('*')]) {
+ expect(el).not.toHaveAttribute('aria-live');
+ expect(['status', 'alert', 'log']).not.toContain(
+ el.getAttribute('role'),
+ );
+ }
+ },
+ );
});
diff --git a/packages/core/src/Chat/ChatSystemMessage.tsx b/packages/core/src/Chat/ChatSystemMessage.tsx
index 3dbf48d3cb..262f030baf 100644
--- a/packages/core/src/Chat/ChatSystemMessage.tsx
+++ b/packages/core/src/Chat/ChatSystemMessage.tsx
@@ -104,6 +104,10 @@ const styles = stylex.create({
* "user joined", status changes. Supports a divider variant with horizontal
* lines on each side of the text.
*
+ * It carries no live role: a notice added to a `ChatMessageList` is announced
+ * by the list's log, which owns content added inside it (`spec:AST-086` FR4),
+ * and a date or divider row is ordinary transcript content.
+ *
* @example
* ```
* <ChatSystemMessage>Conversation started</ChatSystemMessage>
@@ -131,8 +135,7 @@ export function ChatSystemMessage({
className,
styleProp,
)}
- {...rest}
- role="status">
+ {...rest}>
<Divider label={children} />
</div>
);
@@ -147,8 +150,7 @@ export function ChatSystemMessage({
className,
styleProp,
)}
- {...rest}
- role="status">
+ {...rest}>
<span {...stylex.props(styles.content)}>
{icon != null && <span {...stylex.props(styles.icon)}>{icon}</span>}
{children}
diff --git a/packages/core/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts b/packages/core/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts
index 8352332459..3a0ddf8a2c 100644
--- a/packages/core/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts
+++ b/packages/core/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts
@@ -458,7 +458,8 @@ async function capture(
forcedColors: false,
coarsePointer: options.coarsePointer ?? false,
touchPoints: options.touchPoints ?? false,
- role: 'status',
+ // No live role of its own: the chat log delivers it (spec:AST-086 FR4).
+ role: null,
variant: auditCase.variant,
text: auditCase.text,
separatorCount: auditCase.variant === 'divider' ? 1 : 0,
@@ -488,7 +489,7 @@ async function capture(
check(actual.selectorCount === 1, 'expected exactly one audit subject');
check(actual.visible, 'audit subject has no visible geometry');
check(actual.text === expected.text, 'visible content drifted');
- check(actual.role === expected.role, 'status role drifted');
+ check(actual.role === expected.role, 'root role drifted');
check(actual.variant === expected.variant, 'variant reflection drifted');
check(
actual.separatorCount === expected.separatorCount,
@@ -915,11 +916,11 @@ test.afterAll(async () => {
},
emptyContentPartitions: {
emptyString:
- 'Focused unit evidence: the default variant keeps role=status and renders the content unchanged (empty). In the divider variant, the status root and separator remain; no visible label or accessible name is produced.',
+ 'Focused unit evidence: the default variant has no root role and renders the content unchanged (empty). In the divider variant, the root and separator remain; no visible label or accessible name is produced.',
numericZero:
- 'Focused unit evidence: the default variant keeps role=status and renders the content unchanged as one 0. In the divider variant, the status root and separator remain; Divider paints two zero text nodes (textContent="00") with no accessible name.',
+ 'Focused unit evidence: the default variant has no root role and renders the content unchanged as one 0. In the divider variant, the root and separator remain; Divider paints two zero text nodes (textContent="00") with no accessible name.',
emptyFragment:
- 'Focused unit evidence: the default variant keeps role=status and renders the content unchanged (empty). In the divider variant, the status root and separator remain; no visible label or accessible name is produced.',
+ 'Focused unit evidence: the default variant has no root role and renders the content unchanged (empty). In the divider variant, the root and separator remain; no visible label or accessible name is produced.',
},
sharedAdvisories: {
dividerFalseyLabel:
@@ -933,9 +934,7 @@ test.afterAll(async () => {
forcedColors:
'Forced-colors rendering was not exercised. The default row makes no support claim, and the disappearing Divider rule is a shared component:Divider advisory.',
assistiveTechnology:
- 'Browser role exposure is measured, but spoken announcement timing and output were not verified with real assistive technology.',
- nestedLiveRegions:
- 'The nested-log frame records role=status inside ChatMessageList role=log aria-live=polite, but double-announcement behavior is unverified under spec:AST-009/FR4 and FR10.',
+ 'Browser role exposure is measured; spoken output was not recorded with real assistive technology, which spec:AST-009 does not require for routing claims.',
},
stateVisualConformance: {
default: ['text', 'text-with-icon', 'wrapped-long-content'],
@@ -943,7 +942,7 @@ test.afterAll(async () => {
'labelled-separator',
'unresolved-divider-icon-observation',
],
- nestedLiveLog: ['status-inside-polite-log-unverified'],
+ nestedLiveLog: ['no-live-role-inside-polite-log'],
colorModes: ['light', 'dark'],
narrowCoarsePointer: [
'default-with-icon',
diff --git a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx
index 9e0a05aa6c..a57e3e45f7 100644
--- a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx
+++ b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx
@@ -10,7 +10,6 @@
*/
import {useEffect, useState, type ReactElement, type ReactNode} from 'react';
-import {ChatSystemMessage} from '../../Chat/ChatSystemMessage';
import {ProgressBar} from '../../ProgressBar/ProgressBar';
import {Spinner} from '../../Spinner/Spinner';
import {Toast} from '../../Toast/Toast';
@@ -198,22 +197,6 @@ function SpinnerHarness({visibleLabel}: {visibleLabel: boolean}) {
);
}
-function ChatSystemMessageHarness() {
- const initial = 'Conversation started';
- const [message, setMessage] = useState(initial);
- return (
- <Frame>
- <TransitionButton name="show" onClick={() => setMessage(initial)} />
- <TransitionButton
- name="replace"
- onClick={() => setMessage('A file was shared')}
- />
- <TransitionButton name="clear" onClick={() => setMessage('')} />
- <ChatSystemMessage>{message}</ChatSystemMessage>
- </Frame>
- );
-}
-
function ProgressHarness({
initial,
progressValue = 40,
@@ -289,7 +272,6 @@ export const CORE_STATUS_MESSAGE_STATE_RENDERS: Record<
<SpinnerHarness visibleLabel={false} />
),
'spinner-visible-label-mounted': () => <SpinnerHarness visibleLabel />,
- 'chat-system-status-mounted': () => <ChatSystemMessageHarness />,
'progress-loading-to-complete': () => <ProgressHarness />,
'progress-custom-range': () => (
<ProgressHarness
diff --git a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts
index ba33800d3a..34192d6122 100644
--- a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts
+++ b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts
@@ -14,7 +14,6 @@ export type CoreStatusMessageBinding =
| 'Toast card'
| 'FieldStatus announcement channel'
| 'Spinner'
- | 'ChatSystemMessage'
| 'ProgressBar';
export interface CoreStatusMessageBindingDefinition {
@@ -188,20 +187,6 @@ export const CORE_STATUS_MESSAGE_BINDING_STATES = [
}),
storyId: 'a11y-status-message-pattern--spinner-visible-label-mounted',
},
- {
- id: 'chat-system-status-mounted',
- binding: 'ChatSystemMessage',
- summary: 'a chat status notice is mounted with its live-region content',
- facts: liveFacts({
- role: 'status',
- politeness: 'polite',
- initialMessage: 'Conversation started',
- message: 'Conversation started',
- replacement: 'A file was shared',
- semanticTransitions: ['replace', 'clear'],
- }),
- storyId: 'a11y-status-message-pattern--chat-system-status-mounted',
- },
{
id: 'progress-loading-to-complete',
binding: 'ProgressBar',
@@ -279,10 +264,10 @@ export const CORE_STATUS_MESSAGE_EXCLUSIONS = [
'A composing control that marks Spinner aria-hidden owns the surrounding busy semantics; the decorative ring is not another status message.',
},
{
- owner: 'ChatSystemMessage divider',
- part: 'date or section separator',
+ owner: 'ChatSystemMessage',
+ part: 'chat notice or date separator',
reason:
- 'A divider does not report success, results, waiting, progress, or an error. Its current forced status role is tracked as a separate ownership mismatch rather than adopted here.',
+ 'spec:AST-086 FR4: a notice added to a chat log is delivered by the log, so neither the notice row nor the divider carries its own live role; a date or section separator is ordinary transcript content.',
},
{
owner: 'ChatMessageList and streaming logs',
diff --git a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx
index 44c3c59056..9156b98906 100644
--- a/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx
+++ b/packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx
@@ -128,7 +128,6 @@ describe('Core status-message binding inventory', () => {
),
].sort(),
).toEqual([
- 'ChatSystemMessage',
'FieldStatus announcement channel',
'ProgressBar',
'Spinner',
@@ -141,7 +140,7 @@ describe('Core status-message binding inventory', () => {
expect(CORE_STATUS_MESSAGE_EXCLUSIONS.map(entry => entry.part)).toEqual([
'visible validation text',
'aria-hidden decorative spinner',
- 'date or section separator',
+ 'chat notice or date separator',
'role=log transcript updates',
'composer errors and tool-run states',
'busy announcement',