Skip to content

fix(ChatComposerInput): announce the trigger menu's loading text through the shared channel - #7900

Merged
cixzhang merged 5 commits into
meta:mainfrom
HelloOjasMutreja:fix/trigger-menu-loading-announcement
Oct 22, 2026
Merged

cixzhang merged 5 commits into
meta:mainfrom
HelloOjasMutreja:fix/trigger-menu-loading-announcement

Conversation

@HelloOjasMutreja

@HelloOjasMutreja HelloOjasMutreja commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7859

User impact

A screen reader user typing @ or / in a chat composer with an async trigger source gets no spoken cue that a search is running. The "Searching…" row is inserted as a new role="status" element that already holds its text, and it is removed when results arrive. Screen readers commonly skip a live region that is born with its content, so the loading state is silent.

Problem and solution fit

  • Why does it happen? useTriggerMenu renders the loading row as <div role="status">, mounted only while a search is pending.
  • Why does it hurt? A live region that mounts with its text is not reliably announced.
  • Why does it matter? spec:AST-086 FR2 says a transient message announces through the shared channel, and FR6 says once per occasion.

Fix: the loading row loses its live role and useTriggerMenu announces the trigger's loadingText through useAnnounce once per loading episode. Typing more characters while the same search is still pending does not repeat it, a StrictMode effect replay does not repeat it, and the next search after results arrive is a new occasion. The default text now comes from the catalog (@astryx.chatTriggerMenu.searching, one key shared by the row and the announcement, spec:AST-086 FR7). The announcement follows the row's own render condition (an active trigger and not hidden), and dismissing the menu clears a search still waiting out its debounce, so a press outside the menu cannot announce "Searching…" with no menu open. The visible row and loadingText are otherwise unchanged.

Testing

  • ChatComposerInput.test.tsx gains three cases: no live role on the row, one announcement across keystrokes under StrictMode with a second one for the next search, and a custom loadingText. All three fail without the source change.
  • Chat suite: 391 passed. tsc --noEmit for core, eslint and prettier clean.
  • The dismissal-within-debounce path is not exercised by a test: jsdom does not run the popover's light dismiss, so that fix is verified by reading the code path only.
  • Not a visual change, so no screenshot. Spoken output was not checked with a real screen reader (AST-009 asks for that for spoken-output claims); the announcement call itself is covered by the tests above.

Assistive technology (spec:AST-009)

  • Classification: FR4 (announcement content and timing). The intended result depends on what the live channel says and when, for a transient loading state.
  • Scenario: in a chat composer with an async @ trigger source, type @ and a letter. Expected: the screen reader says the loading text once while results load, then reads the results as the highlighted option changes; typing more letters during the same search does not repeat it; the row itself is not read as a live region.
Row State
NVDA + Chrome (Windows) pending
VoiceOver + Safari (macOS) pending

Per FR17 the real-AT rows and the release-block record are needed before a stable release; I do not have these assistive technologies available, so a maintainer or another contributor with access would need to record them.

@vercel

vercel Bot commented Oct 22, 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 22, 2026 3:33pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 22, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: 2 accessibility violation(s) found — 2 serious.

ChatComposer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/19 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatComposerInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

46 of 494 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@HelloOjasMutreja
HelloOjasMutreja marked this pull request as ready for review October 22, 2026 07:13

@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.

Thanks for the fix: the loading row no longer carries role="status", and the trigger's loading text now reaches the shared polite channel once per search. Three changes are needed before this can merge:

  • In useTriggerMenu.tsx, derive the announcement flag from the same state that renders the row (include state.activeTrigger !== null) and clear the debounce timer in the popover's onHide, because a click outside the menu within the debounce window currently announces “Searching…” with no menu open and then leaves the next search silent.
  • Resolve the default loading text through the i18n catalog (one en.json key shared by the row and the announcement) instead of the 'Searching…' literal, as docs/architecture/internationalization.md INV1a requires for live-region announcements.
  • Add the AST-009 FR4 classification to the description, with the NVDA + Chrome (Windows) and VoiceOver + Safari (macOS) rows marked pending and a short reproduction scenario, since AST-009 FR17 needs those and a release-block record before merge.

[Automated review]

// loading row goes away, so the next search is a new occasion.
const announce = useAnnounce();
const hasAnnouncedLoadingRef = useRef(false);
const isLoadingRowShown = state.isLoading && !state.isHidden;

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 flag is looser than the row's own render condition: renderMenu returns nothing while activeTrigger is null (line 889). When the popover's onHide runs inside the debounce window, the timer from line 606 still calls doSearch, which sets isLoading: true with activeTrigger: null, so this effect announces “Searching…” with no menu open; the stale result is then discarded, isLoading stays true, and the next search is not announced. Adding state.activeTrigger !== null && here removes both symptoms with the existing tests still passing, and clearing searchTimeoutRef in onHide fixes the stale timer itself. A regression test that dismisses within debounceMs and then starts a new search would lock it in.

const announce = useAnnounce();
const hasAnnouncedLoadingRef = useRef(false);
const isLoadingRowShown = state.isLoading && !state.isHidden;
const loadingAnnouncement = state.activeTrigger?.loadingText ?? 'Searching…';

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 adds a live-region announcement whose default is a literal; docs/architecture/internationalization.md INV1a requires Astryx-owned announcements to come from an en.json key through the translator. Because AST-086 FR7 ties the spoken words to the row's default at line 898, one catalog key resolved once and used for both satisfies both rules, and translations may omit the key and fall back to English (INV6).

@HelloOjasMutreja
HelloOjasMutreja force-pushed the fix/trigger-menu-loading-announcement branch from 1cddc53 to aa86ad0 Compare October 22, 2026 08:07
@HelloOjasMutreja

Copy link
Copy Markdown
Contributor Author

All three addressed in aa86ad0: the announcement flag now mirrors the row's render condition (active trigger, not hidden); onHide clears a pending debounce timer; and the default text comes from one catalog key, @astryx.chatTriggerMenu.searching, shared by the row and the announcement. The AST-009 FR4 classification, scenario and pending NVDA and VoiceOver rows are in the description. The dismissal-in-debounce path is not covered by a test because jsdom does not run the popover's light dismiss; the description says so.

@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.

Thanks for the update: the dismissal path, the catalog-backed default and the AST-009 classification all check out on this revision, and the new tests fail on main and pass here. One fix is still needed: a synchronous source such as createStaticSource (every trigger story except Async Search) still enters the loading state on each keystroke (useTriggerMenu.tsx:590), so the new effect writes “Searching…” to the polite channel after every key while the results are already listed. Applying a synchronous result directly, so that only a pending search shows the loading row and announces, plus a createStaticSource test that expects no announcement, would fix it. AST-009 FR17 also needs the durable release-block record to exist before merge, with only the pending screen-reader receipts waiting for the stable release; AST-009's entry for #6950 shows its shape.

[Automated review]

return;
}
hasAnnouncedLoadingRef.current = true;
announce(loadingText, '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.

With a synchronous source (createStaticSource), doSearch still sets isLoading: true (line 590) before applying the array result a microtask later, so every keystroke turns isLoadingRowShown on and off and this call writes “Searching…” to the polite region after each key while the results are already listed (AST-086 FR7: “The announced words match the shown words”). Keeping a synchronous result out of the loading state, so only a pending search shows the row and announces, plus a createStaticSource test that expects no announcement, would fix it.

cixzhang added a commit that referenced this pull request Oct 22, 2026
## Exact decision needed

Whether merge or stable release may wait on real assistive-technology (NVDA, VoiceOver) evidence that contributors cannot produce.

## Existing authority searched

- `spec:AST-009` (current): FR4/FR8/FR17–FR19 required an explicit trigger classification, a named real-AT matrix, a scenario, and a durable release-block record, and blocked the first stable release until real-AT receipts passed or an owner exception applied.
- Linked records that restated the block or required screen-reader checks: `spec:AST-001` (browser evidence and FR7 row), `module:Table/useTableRowStatus` AR6, `module:Table/useTableColumnResize` verification, `spec:AST-056` (browser evidence line), `spec:AST-021` (release boundary phrase), `spec:AST-086` (FR6 real-AT row and platform line), `component:FieldStatus` AR5 and its verification row, `spec:AST-020` FR6 ("real-AT contract").
- Open PRs that add release-block sections to AST-009: #7732, #7275, #7272. Under this record those sections are no longer needed.

## Decision

- No requirement gates merge or release on evidence that cannot be produced (Intent, FR17, DEC-4).
- Merge and stable release need only the unit, DOM, accessibility-tree, axe, and real-browser evidence the owning records require (FR17).
- Announcements are proved by their routing: which element or channel carries them, their text, urgency, and update count per occasion (FR4, FR19).
- Real-AT observation is recommended follow-up when an outcome depends on AT behavior, may be tracked in a public issue, and holds no pull request or release (FR1–FR6, FR18).
- A change with an AT-dependent claim says so and names its lower-layer evidence; no matrix, scenario, or release record is needed to merge (FR8).
- Evidence-layer boundaries, the representative matrix, failure handling, and durable receipts stay, scoped to when a real-AT check runs.
- The exception process (old FR23–FR26) is removed because nothing remains to except.

## Rejected alternatives

- Holding stable releases until named real-AT receipts pass: fixes for known accessibility defects stall when no contributor can run the required pairings.

## Claim scope and non-goals

Only the evidence bar for merge and release, and the status of real-AT observation. Component accessibility requirements, evidence-layer boundaries, and focus/announcement behavior stay with their owners.

## Evidence and implementation relationship

Status-announcement conformance PRs (#7869, #7870, #7871, #7892, #7900, #7910) stall on the old real-AT release-block requirement because nobody in the review loop can run NVDA or VoiceOver. No implementation is included.

## Writing rubric results

- R1 narration: none; present-tense rules throughout. The two earlier holds are described as current follow-ups.
- R2 research in the record: none.
- R3 evidence naming a change: none; the earlier hold sections that named pull requests are replaced by the facts (story names and claims).
- R4 rejected alternatives over one line or outside a decision: one per decision, one line each.
- R5 pull request or issue references remaining: none in AST-009 or the edited lines.
- R6 ruled open questions still listing options: none.

## Scope

- [x] This PR contains specification records only.
- [x] It records observable behavior and preserves equivalent internal implementations.
- [x] Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract.
- [x] Verification states the evidence layer and failure signal without prescribing CI job/workflow topology.
- [x] It records one intentional durable decision, not a rescue for a separable tagalong.
- [x] The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision.
- [x] Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them.
- [x] Public text and artifacts contain no internal Meta context.

## Validation

- `pnpm check:knowledge`
- Prettier
- `git diff --check`
…loading

A source that returns an array, such as createStaticSource, already has its
results, so the trigger menu no longer enters the loading state for it and
the loading announcement never fires while the results are listed
(spec:AST-086 FR7). Async sources are unchanged.

@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.

Thanks for the update: static sources such as createStaticSource now stay silent, an async search is announced once per search, and dismissing the menu announces nothing, all confirmed in the browser on this revision. One fix is still needed: with debounceMs={0}, a source whose promise is already settled (a cache hit, or an async search over local data) still writes “Searching…” to the polite region on every keystroke although the loading row never reaches the screen, which AST-086 FR7 rules out. Announcing on the next animation frame, and cancelling in the effect's cleanup when the row goes first, fixes it; please add a test with such a source that expects no announcement. The release-block record requested earlier is no longer needed, since AST-009 FR17 now treats real screen-reader checks as optional follow-up.

[Automated review]

return;
}
hasAnnouncedLoadingRef.current = true;
announce(loadingText, '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.

With debounceMs={0} and a source whose promise is already settled (a cache hit, or an async search over local data), this call runs before the results commit, which lands one microtask later, so “Searching…” reaches the polite region on every keystroke although no frame ever shows the row (AST-086 FR7). Scheduling the call with requestAnimationFrame and cancelling it in the effect's cleanup when the row goes first fixes it, together with a settled-source test under debounceMs={0} that expects no announcement.

…ainted

The loading announcement now waits for the second animation frame, which
runs after the first paint, and is cancelled when the row goes first. A
search whose promise settles before then, such as a cache hit or an async
search over local data, never shows the row and announces nothing
(spec:AST-086 FR7).
@HelloOjasMutreja

Copy link
Copy Markdown
Contributor Author

The settled-source case is covered by a17768c, which was pushed to this branch after the last review ran: the announcement is scheduled two animation frames after the row mounts and cancelled when the row goes first, so a search that settles before a frame is painted announces nothing, and a test with such a source under debounceMs={0} expects no announcement. I re-ran the Chat suite on that head: 393 passed. Thanks for the note that the real-AT release record is no longer needed; I left the AT section in the description as follow-up.

@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.

Thanks for the update: this revision addresses the earlier review points and looks ready to merge from this automated review. The loading row no longer carries a live role, the trigger's loading text reaches the shared polite channel once per pending search, and nothing is announced for static sources, already-settled searches or a dismissed menu, as the new tests and browser checks show. You may also want to refresh the description, which still lists three new tests and treats the NVDA and VoiceOver rows as a release requirement, while AST-009 FR17 now makes them optional follow-up.

[Automated review]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 22, 2026
@cixzhang
cixzhang merged commit 51ad2f4 into meta:main Oct 22, 2026
66 checks passed

This branch was successfully deployed

1 active deployment
Preview — a17768c3 Deployed Oct 22, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Chat trigger menu: the loading row mounts as a live region already holding its text

2 participants