Skip to content

fix(core): a search's busy start is never announced after its outcome - #8235

Merged
cixzhang merged 4 commits into
mainfrom
fix/busy-start-after-outcome-v3
Oct 24, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/busy-start-after-outcome-v3

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Replaces #8137, which was closed at its review-round limit. This version carries that PR's last revision plus a typing fix to one test. A maintainer approved the retry.

User impact

A screen-reader user who types into a BaseTypeahead or CommandPalette can hear "Loading" after the results are already in: either right after the result count, or replacing it. This happens when a search finishes within about a frame of starting. The busy start's announcement waits a frame, and when the search beats it, the stale "Loading" is still spoken.

After this change, a busy start that has not been announced yet is dropped once the same search's outcome is about to be announced.

Problem and solution fit

  • Why does it happen? useBusyAnnouncement announces a busy start one frame after the owner becomes busy, and only React's commit of the settled state cancels that frame. When the search resolves before that commit, the owner announces the outcome first and the busy start's frame fires afterwards.
  • Why does it hurt? The last thing the user hears is "Loading", which is false, or "Loading" replaces the count they needed.
  • Why does it matter? spec:AST-086 FR8 (current since spec(AST-086): identical same-frame repeats are one message; no busy start after its outcome #8102) says a pending busy start is dropped once the same operation's outcome has announced.

Expected behavior and authority

spec:AST-086 FR8: each busy start is announced once, and a pending busy start is dropped once the same operation's outcome has announced.

Smallest restoration

  • useBusyAnnouncement: returns a settle function. It cancels a busy start still waiting for its frame and does not reschedule it while the owner is still busy. Callers that ignore the return value are unchanged.
  • BaseTypeahead: calls it when a typed query's search settles. That outcome is announced next, either as a count or from the rendered empty state.
  • CommandPalette: calls it at the same point. The busy start lives in CommandPaletteInput, so the input registers its settle function with the palette through a new context, busyStartSettle.ts. The package does not export that context, so the exported CommandPaletteContextValue is unchanged. The opening (bootstrap) load announces no outcome, so it does not settle, and its busy start behaves as before.

There is no public API change. useBusyAnnouncement and the new context are internal and are not exported.

Evidence

  • Before: on main, useBusyAnnouncement.test.tsx "drops a busy start its owner settled before it was announced" fails, because the hook returns nothing to call.
  • After: a settled busy start is never announced, even if its message changes while the owner is still busy, and the next busy start after the owner stops being busy announces normally. The styled Typeahead hands its busy state to a separate indicator that re-renders in the same task, so it never had this race; its owner-level case passes either way.
  • Owner-level race: BusyOwnerAnnouncement.test.tsx adds cases for BaseTypeahead, Typeahead and an inline CommandPalette. Each search settles in a frame callback that runs before the busy start's frame. Each frame callback runs in its own task, as browsers run microtasks between frame callbacks, which jsdom does not. The outcome is announced, and "Loading" never is. These cases fail when the settle call is removed, and fail for BaseTypeahead when the settle call is moved to before the search starts.
  • Unchanged path: busy starts that are not overtaken still announce once, including from inside a modal dialog. The BusyOwnerAnnouncement suite passes.
  • Mutation-sensitive proof:
    • Removing the hook's cancelAnimationFrame fails two hook tests.
    • Removing the BaseTypeahead call fails its adopter test.
    • Removing the CommandPalette call fails its adopter test.
    • Removing the input's registration fails the CommandPalette adopter test.
    • Removing either adopter's settle call also fails its owner-level race case.

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.

The FR9 conformance change (joining same-frame messages in the shared channel, keeping an identical repeat once, and withdrawing a busy start its outcome overtook in the channel) follows in a separate PR. It builds on this one.

Testing

  • pnpm exec vitest run packages/core/src/hooks packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx packages/core/src/Typeahead packages/core/src/CommandPalette: 875 passed (the CommandPalette perf benchmark times out only when the machine is overloaded, and passes alone).
  • tsc --noEmit for core and eslint on the touched files are clean.
  • Evidence is DOM-level (spec:AST-009 FR4, FR19): announcement routing and counts, with no screen-reader claim.

… (AST-086 FR8)

useBusyAnnouncement returns a settle function that drops a busy start still
waiting for its frame. BaseTypeahead and CommandPalette call it when a typed
query's search settles, whose outcome (a count, or the rendered empty state)
is announced next, so a fast search's 'Loading' can no longer follow or
replace it.
…-internal context

The input's settle registration moves off the exported CommandPaletteContext
value onto a context this package does not export, and owner-level tests
cover a search that settles before its busy start is announced.
…s message changes; name BaseTypeahead in the changeset
…k passes; trim the changeset to what changes
@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 12:56pm UTC

Request Review

@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, 1:24 PM UTC

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

github-actions Bot commented Oct 24, 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: No accessibility violations detected.

Visual Regression

46 of 498 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

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

This looks good to me: dropping a typed query's pending “Loading” once its search settles matches spec:AST-086 FR8, and the new owner-level cases reproduce the stale announcement before the fix and pass after it. No changes are needed. As a follow-up outside this pull request, the modal CommandPalette still sends its result count to the page-level live region that the open dialog hides, so a fast query there is now silent until counts are delivered inside the modal.

[Automated review]

@cixzhang
cixzhang merged commit db7e945 into main Oct 24, 2026
69 checks passed
@cixzhang
cixzhang deleted the fix/busy-start-after-outcome-v3 branch October 24, 2026 13:27
cixzhang added a commit that referenced this pull request Oct 24, 2026
… identical repeat once (#8244)

## 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 #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

- `spec:AST-086` FR9 governs joining, the identical repeat and the clear.
- FR8 (with #8235) says a pending busy start is dropped once its outcome has announced. This covers the last case FR9 makes possible: a busy start already written to the channel when its outcome arrives.

## 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 #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

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] 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.

This branch was successfully deployed

1 active deployment
Preview — 93562281 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