Skip to content

fix(useAnnounce): messages announced in the same frame are joined, an identical repeat once - #8244

Merged
cixzhang merged 5 commits into
mainfrom
fix/announce-same-frame-join-v2
Oct 24, 2026
Merged

cixzhang merged 5 commits into
mainfrom
fix/announce-same-frame-join-v2

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

User impact

When two status messages are announced in the same frame, a screen-reader user hears only the last one. For example, a search's result count and a confirmation announced together lose the count. The shared announcer (useAnnounce) gives each message its own frame, and each frame overwrites the previous text.

After this change, messages announced in the same frame are spoken together, in order, and an identical repeat is spoken once. An empty message still clears the region, including messages joined but not yet spoken.

Problem and solution fit

  • Why does it happen? useAnnounce clears the region and schedules one animation frame per message. Two messages in one frame write first one, then the other, so the region exposes only the second.
  • Why does it hurt? An earlier status is silently dropped, and the user never learns it.
  • Why does it matter? spec:AST-086 FR9 (current since spec(AST-086): identical same-frame repeats are one message; no busy start after its outcome #8102) says messages written before the previous one is exposed are joined in order, none is dropped, an identical repeat within one frame is one message, and an empty message clears joined-but-unexposed text.

Expected behavior and authority

Smallest restoration

  • Joining: useAnnounce keeps one pending frame per region and one queue of messages. The frame exposes the queue joined with spaces. An identical message already queued is not queued again, and an empty message clears the queue with the region.
  • Withdrawing a busy start: useBusyAnnouncement's settle function (from fix(core): a search's busy start is never announced after its outcome #8235) also withdraws a busy start it already wrote to the channel but that has not been exposed. Each pending message counts the announcers waiting on it, so one owner withdrawing leaves another owner's identical "Loading" in place. The helpers are module-private; nothing new is exported from the hooks index.
  • Tests: lab ListInput tests clear the shared region between tests with an empty announcement, because one test stubs animation frames. A same-frame grab and return is now expected as one joined announcement. The Selector and MultiSelector tests that assert what one search query announces now paste the query as one change. Typing it key by key can land several keystrokes in one frame, and FR9 joins their counts.

There is no public API change.

Evidence

  • Before: on main, these useAnnounce tests fail:
    • "joins polite/assertive messages announced in the same frame, in order";
    • "starts a new announcement for a message after the joined one is exposed";
    • "keeps an identical message repeated in the same frame once".
      The busy-start test "withdraws a busy start written to the channel but not yet exposed" also fails without the withdrawal.
  • After: all pass. Existing announcement tests (result counts, empty states, busy starts) pass across Selector, MultiSelector, Typeahead, CommandPalette, Tokenizer and DropdownMenu, with no doubled ("1 result 1 result") or stale ("2 results Loading") text.
  • Mutation-sensitive proof:
    • Removing the identical-repeat check fails its test.
    • Removing the clear of queued messages fails "clears messages joined but not yet exposed".
    • Removing the withdrawal fails its test.
    • Removing the per-announcer count fails "withdraws only its own busy start when another owner wrote the same words".

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Modal routing (FR14) is out of scope and untouched.

Testing

  • pnpm exec vitest run packages/core/src/hooks packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx packages/core/src/Typeahead packages/core/src/CommandPalette packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/Tokenizer packages/core/src/DropdownMenu: 1764 tests.
    • All announcement tests pass.
    • The CommandPalette perf benchmark and two DropdownMenu jsdom audit runs timed out while the machine was heavily loaded. They pass when re-run alone, on both this branch and main.
  • Core typecheck and eslint on the touched files are clean, and pnpm check:repo passes.
  • Evidence is DOM-level (spec:AST-009 FR4, FR19): which region carries the text, the text itself and how many updates, with no screen-reader claim.

…FR9)

WIP, held: joining exposes producer duplicates and a stale busy announcement
in Selector, MultiSelector, CommandPalette and Typeahead tests.
…in the channel (AST-086 FR8)

Once FR9 joins same-frame messages, a busy start written to the channel can
still be waiting when its outcome announces. Settling now withdraws it, so a
screen reader hears the outcome alone rather than 'Loading 1 result'.
…ne change

Keystrokes typed in one frame are joined into one announcement (spec:AST-086
FR9), so tests asserting what one query announces paste it instead of typing
it key by key.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 3:42pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 4:11 PM UTC

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joining same-frame messages in useAnnounce matches spec:AST-086 FR9 and the new hook tests prove it, but two things need fixing before this can merge.

  • useBusyAnnouncement's settle withdraws the first queued message with the same words, so when a Typeahead's search resolves in the frame where another busy control has just written "Loading" (every default busy label in English), that control's busy start is never announced (FR8, FR9); please withdraw only the settling owner's own pending write and add a two-owner test.
  • CI test-ui (3/4) fails on two tests in packages/lab/src/ListInput/ListInput.test.tsx (lines 584 and 1281) that pass on main: they assert exact live-region text that FR9 now joins, including text queued by earlier tests in the same file.

[Automated review]

}
// Written to the channel but not yet exposed: withdraw it too.
if (channelMessageRef.current != null) {
withdrawPendingAnnouncement(channelMessageRef.current, 'polite');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the first queued entry with these words, whoever wrote it. Identical same-frame messages share one entry, and channelMessageRef keeps the words after they were exposed, so a settle here can withdraw another busy control's pending "Loading" (every default busy label is "Loading" in English), and that control's busy start is never announced (spec:AST-086 FR8, FR9). Withdrawing only this owner's own still-pending write, for example through a handle from an internal enqueue plus a writer count on a deduplicated entry, and a two-owner test would close it.

…y start; ListInput tests read FR9's joined text

Each pending channel message counts the announcers waiting on it, so one owner
settling leaves another owner's identical 'Loading' in place. ListInput's tests
clear the shared region between tests and expect a same-frame grab and return
to be spoken together.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joining same-frame messages in useAnnounce and withdrawing only a busy control's own pending start now match spec:AST-086 FR9 and FR8, and the new hook tests prove both, including the two-owner case. The earlier withdrawal and ListInput test problems are fixed, so this is ready from a spec and correctness standpoint. The one red check, pr-a11y, fails because the workflow on main now runs packages/lab/src/__tests__/ReorderGripPinchZoom.a11y.chromium.spec.ts, which this branch predates; updating the branch from main should clear it.

[Automated review]

@cixzhang
cixzhang merged commit d794476 into main Oct 24, 2026
65 of 66 checks passed
@cixzhang
cixzhang deleted the fix/announce-same-frame-join-v2 branch October 24, 2026 16:13
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 24, 2026
…e the query

Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
…e the query

Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 25, 2026
…e the query

Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
…e the query

Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
…thdrawn, not joined (#8640)

## Why

When input outpaces a frame (a barcode scanner, dictation, automation), a screen-reader user hears MultiSelector's stale statuses joined together: `1 result Create "Urg" Create "Urge" Create "Urgen" Create "Urgent"`.

## What led to it

Found while checking the text-entry components' accessibility tests (part of bringing Astryx's touch behavior to parity with iOS's UIKit, text entry first). #8244 made the announcer join every message written before the previous one is read out (`spec:AST-086` FR9), so two components speaking in the same frame are both heard. MultiSelector states its search's status on every keystroke, so fast typing joins statuses that no longer apply. Its CreateRow accessibility spec failed on that, and now accepts the joined text.

## The record

#9070, approved by the spec owner, amends `spec:AST-086` FR9, FR13 and FR14: a `useAnnounce` instance created with `hasReplace` withdraws its own previous message while it is not yet exposed, whatever their urgencies, and the newer is spoken in the region of its own urgency; messages from other instances still join. This pull request implements it and lands after #9070, so its public option is settled by that record, not decided here (`spec:AST-002` FR19).

## Options and tradeoffs

- Debounce MultiSelector's status: delays every announcement, and every component would repeat it.
- Keep the joined text: scanner and dictation users keep hearing stale counts.
- Replace per announcer instance, in the shared announcer: fixes it once for every caller, and different instances still join.

## Why this choice

It is the shape #9070 records. `useAnnounce({hasReplace: true})` is one optional field; the `announce(message, politeness)` it returns is unchanged. Each write gives its announcer a receipt kept beside the words, wherever the route put them: the shared region, a modal's container, words held for an exiting modal, or a message waiting for its modal to be presented. When a modal hands its waiting words on (it leaves the accessibility tree, exits, closes, a step is left, or its write frame finds it unexposed), they move one delivery per announcer and each receipt follows its words. A receipt takes back only its own share and only while the words wait, so it never reaches equal words another announcer wrote after its own were spoken. The busy-announcement hook takes its start back through the same receipt. MultiSelector sends its result count, its create row and its empty-panel message through one such instance; selection changes keep their own. Selector, Typeahead and the others adopt it separately.

## How to check it

1. Run `MultiSelector/CreateRow.a11y.chromium.spec.ts` in Chromium. It types into the create row at about four keystrokes per frame. It now reads the two search statuses exactly, in place of the `newestMessage` regex; the creation message, which comes from another announcer and can still join, keeps the regex. Expected: on main it fails on the joined statuses; with this change the polite region reads `1 result`, then `Create "Urgent"`.
2. With a screen reader, type into MultiSelector at a normal pace. Expected: each status is read as before.

## Evidence

- CreateRow spec, tightened as above: on main 560c666 it failed 6 of 10 runs alone and 35 of 48 at 8 workers, reading `Create "Urge" Create "Urgen" Create "Urgent"`; with this change it passes 10 of 10 alone and 48 of 48 at 8 workers.
- Unit tests that fail on main first: four statuses in one frame say the last; a count then an empty panel, and an empty panel then a count, say the newer; the same inside a Dialog's container; a `hasReplace` instance's messages in one frame, polite then assertive, inside a modal and in the commit that presents one; and its first message, handed on by its modal before it was exposed (the Dialog leaving the accessibility tree and coming back, a sheet's exit and close, the Dialog closing, a step left for the next one, or its write frame finding it unexposed), is taken back by its next. Guards that pass on main and with the change: other instances and plain instances still join, a shared share stays, an exposed message stays, a selection change and a count in one frame are both said, and inside a modal an equal message another announcer writes after the count's was spoken, and another announcer's share of words held while a sheet exits, both stay.
- Local gates at 4e89f16 (one commit on main bb18c81): build, typecheck, repo checks and Prettier pass; the core UI suite passes (16,616 tests); the node suite passes except the two `cache.test.mjs` lock tests that fail on this machine without the change too (#8520).

This branch was successfully deployed

1 active deployment
Preview — e50baafa Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant