Skip to content

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

TypeScript

spec(AST-086): a status is replaced by its owner's next status, not joined (#9070)

Christopher Chedeau94a2a8ee5c9f
diff --git a/docs/specs/AST-075-owned-field-combobox/spec.md b/docs/specs/AST-075-owned-field-combobox/spec.md
index 14ea25be2e..ec6668b77c 100644
--- a/docs/specs/AST-075-owned-field-combobox/spec.md
+++ b/docs/specs/AST-075-owned-field-combobox/spec.md
@@ -81,7 +81,9 @@ the behavior from hooks; every such field behaves and announces the same way.
keep focus through the press.
- **FR7 — Result count.** When the options change for a new query, the number of
options, or that there are none, MUST be announced politely through the shared
- announcer rather than a live region per field.
+ announcer rather than a live region per field, through the field's own
+ `useAnnounce({hasReplace: true})` instance (`spec:AST-086` FR9), so a newer
+ count replaces one not yet spoken.
- **FR8 — The hooks are discoverable as hooks.** Each public hook that
implements this contract MUST be returned by `astryx hook <name>` and
`astryx search` with its parameters, its return fields, and the requirements
@@ -108,9 +110,9 @@ the behavior from hooks; every such field behaves and announces the same way.
option, opens and closes, and handles the keys for Selector and CommandPalette.
For a single-line `input` the caller renders, over any option type with a
string `value`, its `getFieldProps`, `getListboxProps`, and `getOptionProps`
- carry FR1–FR6. It does not yet take a multi-line field (DEC-3), and the
- caller announces the result count through `useAnnounce` (FR7), as DEC-2
- describes.
+ carry FR1–FR6. It does not yet take a multi-line field (DEC-3), and the caller
+ announces the result count through its own `useAnnounce({hasReplace: true})`
+ instance (FR7), as DEC-2 describes.
- `useMultiCombobox` (exported from `@astryxdesign/core/MultiSelector`) does the
same for MultiSelector's own control. It takes MultiSelector's option type,
leaves the ARIA wiring to the caller, and does not guard keys during an
@@ -128,7 +130,7 @@ the behavior from hooks; every such field behaves and announces the same way.
| FR1–FR3 | Chromium accessibility-tree binding under `spec:AST-021`; unit tests | input, textarea, contenteditable; list in a layer and in flow | focus leaves the field, a stale `aria-activedescendant` or `aria-controls` remains, or axe reports `aria-allowed-role` or `aria-allowed-attr` on the field |
| FR4, FR6 | real keyboard and pointer input in Chromium | arrows, Enter, Escape inside a dialog, hover and press; ArrowDown on a hidden list in an `input` and in a `textarea` | a key or press picks, dismisses, or blurs the field at the wrong time |
| FR5 | composition event tests | candidate selection confirmed with Enter | Enter during composition picks an option |
-| FR7 | shared announcer tests | results, none, a new query | no announcement, or an announcement from a per-field live region |
+| FR7 | shared announcer tests | results, none, a new query, two queries in one frame | no announcement, or an announcement from a per-field live region, or a superseded count spoken with the newer one |
| FR8 | CLI hook discovery tests over core's exported hooks | each public hook named in DEC-2; a hook exported from a component's entry point | a combobox hook is exported without a hook doc, or `astryx hook <name>` denies it exists |
## Decision log
diff --git a/docs/specs/AST-086-status-announcements/spec.md b/docs/specs/AST-086-status-announcements/spec.md
index 44385aa21a..b1d1ce4d9c 100644
--- a/docs/specs/AST-086-status-announcements/spec.md
+++ b/docs/specs/AST-086-status-announcements/spec.md
@@ -92,10 +92,21 @@ announcement channel.
assertive region per document. They are created empty, stay mounted for the
document's lifetime, and clear their text shortly after each announcement so
stale text does not linger. Messages written to a region before the previous
- one is exposed are joined in order into one announcement; none is dropped. An
- identical message repeated within the same frame is one message (FR6). An
- empty message clears the region, including messages joined but not yet
- exposed.
+ one is exposed are joined in order into one announcement; none is dropped,
+ except a message a `hasReplace` instance withdraws. A `useAnnounce` instance
+ created with `hasReplace` states one current state of its owner, such as a
+ search's result count: each message it writes withdraws that instance's
+ previous message while it is not yet exposed, whatever their urgencies, and is
+ spoken in the region of its own urgency; a message already exposed has been
+ heard and stays. Messages from other instances, and from instances without
+ `hasReplace`, still join. `useAnnounce` takes an optional options object with
+ one field, `hasReplace` (default `false`), offered to every caller, Astryx's
+ components and apps alike (`spec:AST-075` DEC-2):
+ `useAnnounce({hasReplace: true})`; the `announce(message, politeness)` it
+ returns is unchanged. FR13 says when an own-content message comes from such an
+ instance. An identical message repeated within the same frame is one message
+ (FR6). An empty message clears the region, including messages joined but not
+ yet exposed.
`useAnnounce` is the public way to reach it. When an open native modal encloses the
caller, it follows FR14 instead.
- **FR10 — Modal-hosted owners keep their own channel.** While the shared
@@ -132,7 +143,11 @@ announcement channel.
rerender, dependency change, and StrictMode replay, does no work while the
element is hidden, and leaves nothing behind after unmount. Action
announcements, such as a result count from a query handler or FR8 busy
- starts, keep their own owner. Content revealed without a re-render of its
+ starts, keep their own owner. A picker's own empty-panel message (FR11) comes
+ from its search's `hasReplace` instance (FR9), so it replaces the search's
+ result count not yet exposed, and the search's next count replaces it while it
+ is not yet exposed. Content revealed
+ without a re-render of its
owner, such as when an ancestor's `hidden` attribute is removed outside
React, is announced on the owner's next render, and nothing watches for the
reveal while the content is hidden (`architecture:react-component-runtime`
@@ -172,10 +187,13 @@ announcement channel.
containers. FR14's containers are direct children of the modal's dialog
element, created empty on first use (FR3), carry `status` and `alert`
respectively (FR5), and clear shortly after each announcement; messages
- written to one before the previous is exposed are joined in order, an
- identical message repeated within the same frame is one message, and an
- empty message clears it, including messages joined but not yet exposed, as
- FR9 says of the shared channel. FR6 applies to each owner's messages. A busy owner's FR8 region inside a modal is
+ written to one before the previous is exposed are joined in order, except that
+ a message from a `hasReplace` instance withdraws that instance's previous
+ message not yet exposed, in either container, as FR9 says. An identical
+ message repeated within the same frame is one message, and an empty message
+ clears it, including messages joined but not yet exposed, as FR9 says of the
+ shared channel. FR6 applies to each owner's
+ messages. A busy owner's FR8 region inside a modal is
FR14's polite container. When a later modal opens above the owner's modal
(`spec:AST-003` FR17), the owner's containers are inert with its modal, and
a message it announces while covered is not heard — the container clears it
@@ -289,31 +307,43 @@ announcement channel.
is a new outcome or persistent content. FR11 and FR12 cover components that
announce their own content.
- `useAnnounce`: messages written in the same frame are joined instead of the
- last one replacing the others (FR9).
+ last one replacing the others, except from a `hasReplace` instance (FR9).
- `useAnnounce` collapses an identical message repeated in the same frame into
one (FR9), and busy owners drop a pending busy announcement once the same
operation's outcome has announced (FR8).
+- Selector, MultiSelector, Typeahead, Tokenizer's sheet, CommandPalette, and
+ PowerSearch announce a result count on each query change, and MultiSelector
+ also its create row. Written within one frame, as a barcode scanner,
+ dictation, or automation types, one owner's superseded counts are joined
+ (`1 result Create "Urg" Create "Urge" …`), and a count followed by the empty
+ panel's message says both. Under FR9, FR13, and FR14 each sends its result
+ count, and MultiSelector its create row, through a separate
+ `useAnnounce({hasReplace: true})` instance, so only the current one is spoken,
+ and selection messages keep their own plain instance. `useAnnounce` gains that
+ optional option; Astryx's own result counts use it, including the comboboxes
+ `spec:AST-075` DEC-2 composes (its FR7) and Tokenizer's sheet. Instances
+ without it keep joining.
- `spec:AST-037` FR9 (Timer adds no unsolicited live region) already conforms.
- Consumer tests that query these elements by `status` or `alert` role change.
Release notes name each affected component.
## Verification
-| Contract | Verification | Representative states | Mutation or failure expectation |
-| ------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| FR1, FR4 | Shared test: one live owner per announced message | Toast shown; busy Switch; system notice, FieldStatus error, and failure Banner inside a chat log; busy Button and invalid DateInput inside a chat log (pass) | A live role on a second element, or a channel announcement of content added inside a live container, fails |
-| FR2, FR3 | Shared test: no live element mounts holding its text | Conditional status, toast card, standalone Spinner | Mounting `role="status"` with text fails |
-| FR5 | Channel routing tests | Error, warning, success, loading | Routing an error to polite, or a success to assertive, fails |
-| FR6 | StrictMode and rerender tests on the channel spy | Busy start, repeated rerender, same-value update, new occasion | Two announcements for one occasion, or none for a new one, fails |
-| FR7 | Accessibility-tree check of the visible message | FieldStatus attached/detached, toast card | Hiding the visible text or a word mismatch fails |
-| FR8 | Shared test: no live role inside a busy owner; channel spy on the owner | Busy TextInput, Selector, Switch thumb, ChatMessageList loader, busy CommandPalette (region inside its dialog), operation that settles before its busy announcement is exposed | A composed indicator with a live role or its own announcement, or a busy owner that announces nothing, fails, or a busy start announced after its outcome, fails |
-| FR9 | `useAnnounce` tests | First use, many components, region removed, server render, two messages in one frame, clear after a joined message, the same message twice in one frame | A second document-level region pair, stale text after the clear delay, a dropped same-frame message, or a joined message surviving a clear fails, or an identical same-frame repeat announced twice, fails |
-| FR10 | Accessibility-tree check with a Dialog open | Info and error toast shown over an open Dialog | A toast that reaches only the body-level channel, or no exposed live container, fails |
-| FR14 | Hook tests and an accessibility-tree check with an Astryx modal open | Owner outside any modal, inside an open non-modal dialog, inside an open modal (polite and assertive, repeat of the same words, empty message), busy start inside a modal, busy start inside a native modal an app renders without Astryx, alone and opened inside an Astryx Dialog; a modal sheet's row toggle in a real engine, app code calling `useAnnounce` inside a Dialog, CommandPalette result count and Lightbox position message while each is open, a message followed by closing its Dialog before it is exposed (inside another open modal and on the page), a message pending when a CommandPalette opened over a Dialog closes, app code calling `useAnnounce` outside the Dialog it renders (body-level channel) | A channel message from inside an open modal that reaches only the body-level channel, an FR14 container mounted holding its text, a second FR14 container of one urgency in one dialog, an FR14 container the engine's accessibility tree omits, a dropped message of two written before the first is exposed, an empty message that leaves text in the modal's FR14 container, an app `useAnnounce` message from inside an Astryx modal that reaches only the body-level channel, a CommandPalette or Lightbox message about its open modal that reaches only the body-level channel, a message lost when its modal closes before it is exposed, or a pending message handed to a channel still inert after the close, a busy start inside an app-rendered native modal that reaches only the body-level channel, or one inside an app-rendered native modal nested in an Astryx Dialog that is delivered to the Dialog's FR14 container fails |
-| FR11, FR12 | Helper and component tests | EmptyState present at page load, server-rendered, inserted later, text changed, hidden and shown again, brought in by a client-rendered route change, inside a chat log, empty Selector panel open at page load, server-rendered message inserted by client navigation, message inserted after first render but before the document finishes loading (silent) | Announcing at page load or during a server render (other than an announcement-only message), missing a later insertion or a server-rendered message inserted by client navigation, a client-rendered route change, or an empty Selector panel at page load, repeating one occasion, or also using the channel inside a live container fails |
-| FR12 (server) | Server-safe component boundary check plus a server render of each adopter | EmptyState rendered on the server and hydrated | An adopter that fails the boundary check, or emits an announcement or live role from a server render, fails |
-| FR13 | Helper StrictMode, hide/show, and unmount tests on each adopter | EmptyState, Spinner, ChatComposer status bar, ChatTypingIndicator; an ancestor's `hidden` attribute removed outside React | A duplicate announcement under StrictMode, work while hidden, or a resource left after unmount fails; revealed content not announced on the owner's next render, or an observer, listener, or timer running while the content is hidden, fails |
-| FR6 (AT) | Recommended `spec:AST-009` real-AT follow-up | Toast, busy Switch, chat notice | Missing, repeated, or out-of-order speech fails |
+| Contract | Verification | Representative states | Mutation or failure expectation |
+| ------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| FR1, FR4 | Shared test: one live owner per announced message | Toast shown; busy Switch; system notice, FieldStatus error, and failure Banner inside a chat log; busy Button and invalid DateInput inside a chat log (pass) | A live role on a second element, or a channel announcement of content added inside a live container, fails |
+| FR2, FR3 | Shared test: no live element mounts holding its text | Conditional status, toast card, standalone Spinner | Mounting `role="status"` with text fails |
+| FR5 | Channel routing tests | Error, warning, success, loading | Routing an error to polite, or a success to assertive, fails |
+| FR6 | StrictMode and rerender tests on the channel spy | Busy start, repeated rerender, same-value update, new occasion | Two announcements for one occasion, or none for a new one, fails |
+| FR7 | Accessibility-tree check of the visible message | FieldStatus attached/detached, toast card | Hiding the visible text or a word mismatch fails |
+| FR8 | Shared test: no live role inside a busy owner; channel spy on the owner | Busy TextInput, Selector, Switch thumb, ChatMessageList loader, busy CommandPalette (region inside its dialog), operation that settles before its busy announcement is exposed | A composed indicator with a live role or its own announcement, or a busy owner that announces nothing, fails, or a busy start announced after its outcome, fails |
+| FR9 | `useAnnounce` tests | First use, many components, region removed, server render, two messages in one frame, clear after a joined message, the same message twice in one frame, a `hasReplace` instance's messages written in one frame, two pickers' result counts in one frame, a result count followed by its picker's empty-panel message and the reverse, a `hasReplace` message already exposed when the next is written, messages from instances without `hasReplace` in one frame, one picker's result count and selection message in one frame (separate instances), a polite message followed by an assertive one from one `hasReplace` instance | A second document-level region pair, stale text after the clear delay, a dropped same-frame message from another instance or from an instance without `hasReplace`, a `hasReplace` instance's superseded message spoken with its next one, its polite message still spoken after its assertive one, the newer spoken at the older's urgency, an exposed message taken back, or a joined message surviving a clear fails, or an identical same-frame repeat announced twice, fails |
+| FR10 | Accessibility-tree check with a Dialog open | Info and error toast shown over an open Dialog | A toast that reaches only the body-level channel, or no exposed live container, fails |
+| FR14 | Hook tests and an accessibility-tree check with an Astryx modal open | Owner outside any modal, inside an open non-modal dialog, inside an open modal (polite and assertive, repeat of the same words, empty message), busy start inside a modal, busy start inside a native modal an app renders without Astryx, alone and opened inside an Astryx Dialog; a modal sheet's row toggle in a real engine, app code calling `useAnnounce` inside a Dialog, CommandPalette result count and Lightbox position message while each is open, a message followed by closing its Dialog before it is exposed (inside another open modal and on the page), a message pending when a CommandPalette opened over a Dialog closes, app code calling `useAnnounce` outside the Dialog it renders (body-level channel); a search's result counts written in one frame inside a modal sheet; a polite then an assertive message from one `hasReplace` instance inside a modal; a result count followed by its picker's empty-panel message inside a modal sheet | A channel message from inside an open modal that reaches only the body-level channel, an FR14 container mounted holding its text, a second FR14 container of one urgency in one dialog, an FR14 container the engine's accessibility tree omits, a dropped message of two from different instances written before the first is exposed, a `hasReplace` instance's superseded message spoken from an FR14 container, its polite message still spoken from the modal's polite container after its assertive one, or a count spoken with its picker's empty-panel message from an FR14 container, an empty message that leaves text in the modal's FR14 container, an app `useAnnounce` message from inside an Astryx modal that reaches only the body-level channel, a CommandPalette or Lightbox message about its open modal that reaches only the body-level channel, a message lost when its modal closes before it is exposed, or a pending message handed to a channel still inert after the close, a busy start inside an app-rendered native modal that reaches only the body-level channel, or one inside an app-rendered native modal nested in an Astryx Dialog that is delivered to the Dialog's FR14 container fails |
+| FR11, FR12 | Helper and component tests | EmptyState present at page load, server-rendered, inserted later, text changed, hidden and shown again, brought in by a client-rendered route change, inside a chat log, empty Selector panel open at page load, server-rendered message inserted by client navigation, message inserted after first render but before the document finishes loading (silent) | Announcing at page load or during a server render (other than an announcement-only message), missing a later insertion or a server-rendered message inserted by client navigation, a client-rendered route change, or an empty Selector panel at page load, repeating one occasion, or also using the channel inside a live container fails |
+| FR12 (server) | Server-safe component boundary check plus a server render of each adopter | EmptyState rendered on the server and hydrated | An adopter that fails the boundary check, or emits an announcement or live role from a server render, fails |
+| FR13 | Helper StrictMode, hide/show, and unmount tests on each adopter | EmptyState, Spinner, ChatComposer status bar, ChatTypingIndicator; an ancestor's `hidden` attribute removed outside React | A duplicate announcement under StrictMode, work while hidden, or a resource left after unmount fails; revealed content not announced on the owner's next render, or an observer, listener, or timer running while the content is hidden, fails |
+| FR6 (AT) | Recommended `spec:AST-009` real-AT follow-up | Toast, busy Switch, chat notice | Missing, repeated, or out-of-order speech fails |
## Decision log
@@ -370,6 +400,28 @@ stay silent; admitting the shared channel to modal hosting — `spec:AST-003` ow
hosting and has not admitted it; a per-component region for each message —
competing regions and two-owner duplicates inside one dialog.
+### DEC-4 — A `hasReplace` instance replaces its own pending message
+
+**Reference:** `spec:AST-086/DEC-4`
+**Decider:** pending (the approving engineering owner)
+
+FR9 joins messages written before the previous one is exposed, so two components
+speaking in the same frame are both heard. Messages that state one current state
+differ: each supersedes the one before, so joining them speaks states that no
+longer apply, and a search typed into faster than a frame says every count in
+between. An instance created with `hasReplace` withdraws its own pending
+message, which keeps every owner heard and speaks only what is true now, in the
+shared channel and in FR14's containers alike. The reasons are those of
+`architecture:interaction-modality` INV8, under which superseded work does not
+change the current status or announcement, and of FR8, which drops a busy start
+its outcome overtakes. The instance is the unit, so a component gives each state
+it reports its own instance, and `useAnnounce` offers the option to every
+caller, because Astryx's comboboxes compose the same hook products do
+(`spec:AST-075` DEC-2); an instance without it keeps joining.
+
+Rejected: each owner debouncing its own messages — every announcement waits,
+and every owner repeats the rule.
+
## Open questions
None.
diff --git a/packages/core/src/MultiSelector/MultiSelector.spec.md b/packages/core/src/MultiSelector/MultiSelector.spec.md
index d7090ce694..e9b4a439be 100644
--- a/packages/core/src/MultiSelector/MultiSelector.spec.md
+++ b/packages/core/src/MultiSelector/MultiSelector.spec.md
@@ -182,10 +182,13 @@ and `aria-controls` for the listbox, the listbox carries `aria-label` from
focused element that owns arrow, Enter, Escape, and typeahead keys while open,
so an anchor that cannot take focus still leaves a keyboard path.
-The create row is a `role="option"` with `aria-selected="false"` and no
-checkbox indicator. When it is the only result, the polite live region
-announces its label rather than the empty-search message, so what is announced
-matches what is on screen; picking it announces the creation.
+The create row is a `role="option"` with `aria-selected="false"` and no checkbox
+indicator. When it is the only result, the polite live region announces its
+label rather than the empty-search message, so what is announced matches what is
+on screen; picking it announces the creation. The result count and the create
+row's label come from the search's own `useAnnounce({hasReplace: true})`
+instance, so a newer one replaces one not yet spoken (`spec:AST-086` FR9), and
+selection messages keep their own instance.
## Design relationships
diff --git a/packages/core/src/Tokenizer/Tokenizer.spec.md b/packages/core/src/Tokenizer/Tokenizer.spec.md
index a9ae784044..39e77b0de8 100644
--- a/packages/core/src/Tokenizer/Tokenizer.spec.md
+++ b/packages/core/src/Tokenizer/Tokenizer.spec.md
@@ -371,9 +371,11 @@ presentation.
once the confirmation has closed, since a message sent while the
confirmation covers the sheet is not heard — `spec:AST-086/FR14`), the
search's busy start, and how each search
- ended — the result count for a non-empty query, or the empty state's text
- when it shows — are announced once per occasion from inside the sheet
- through `useAnnounce`, which `spec:AST-086/FR14` routes into the persistent
+ ended — the result count for a non-empty query, or the empty state's text when
+ it shows, both from the search's own `useAnnounce({hasReplace: true})`
+ instance (`spec:AST-086/FR9`, FR13), so a newer one replaces one not yet
+ spoken — are announced once per occasion from inside the sheet through
+ `useAnnounce`, which `spec:AST-086/FR14` routes into the persistent
polite container of the sheet's own dialog while it is open, because the
shared page-body channel is not exposed behind a native modal; the
container follows FR3, FR5, and FR6 of that record (WCAG 2.2 SC 4.1.3