Skip to content

spec(AST-086): identical same-frame repeats are one message; no busy start after its outcome - #8102

Merged
cixzhang merged 1 commit into
mainfrom
spec/ast086-fr8-fr9-repeats
Oct 24, 2026
Merged

cixzhang merged 1 commit into
mainfrom
spec/ast086-fr8-fr9-repeats

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Exact decision needed

What the shared announcement channel does with an identical message repeated in one frame, and whether a busy start may be announced after its operation's outcome.

Existing authority searched

  • spec:AST-086 FR6 (once per occasion), FR8 (busy owner announces once per busy start), FR9 (same-frame messages are joined in order; none is dropped).
  • FR9's join rule, read literally, keeps two copies of an identical same-frame message. FR8 does not say what happens when an operation settles before its busy announcement is exposed, so a stale "Loading" can follow the outcome.

Decision

  • FR9: an identical message repeated within the same frame is one message (one occasion under FR6).
  • FR8: a busy start is not announced after the same operation's outcome has been announced; when the outcome announces first, the pending busy announcement is dropped.

Rejected alternatives

  • Joining identical same-frame repeats as separate announcements: screen-reader users hear the same words twice for one occasion.

Claim scope and non-goals

Only same-frame identical repeats in the shared channel and busy-start ordering against the operation's outcome. Other FR8/FR9 behavior is unchanged.

Evidence and implementation relationship

Conformance work on same-frame joining in the shared channel surfaced both cases. No implementation is included.

Writing rubric results

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none; verification names test states.
  • R4 rejected alternatives over one line or outside a decision: none added to the record.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.

Scope

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

Validation

  • pnpm check:knowledge (CI lint)
  • Prettier
  • git diff --check

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@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 5:35am UTC

Request Review

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 63c5b22

@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, 6:04 AM UTC

@github-actions github-actions Bot added the spec-auto-merge Auto-merge was enabled by the spec owner gate label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current change has no visual or preview-producing scope. Visual checks are not applicable; preview links are not shown.

The exact-head preview is not available yet.


Generated by PR Enrichment workflow | View current CI run

@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 spec change looks ready: the FR8 and FR9 amendments to spec:AST-086 are approved by an engineering owner for this exact head, and the record passes knowledge validation. One optional clarification before the implementation lands: FR8 drops a pending busy announcement when "the same operation's outcome" announces first, but that outcome is usually announced by the caller through useAnnounce, which carries no link to the busy control, so naming the observable trigger (for example, the control leaving busy, or a later message reaching the channel) would make the rule testable in every ordering.

[Automated review]

- **FR8 — Indicators inside an owner are silent.** A visual indicator composed
inside a component that owns the task, such as a Spinner in a busy control,
announces nothing and carries no live role. The owning component announces its busy state once per busy start (FR6), through the channel or through a persistent region that FR3 allows.
announces nothing and carries no live role. The owning component announces its busy state once per busy start (FR6), through the channel or through a persistent region that FR3 allows. A busy start is not announced after the same operation's outcome has been announced; when the outcome announces first, the pending busy announcement is dropped.

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.

Optional clarification: this sentence keys the drop to "the same operation's outcome", but that outcome is usually announced by the caller through useAnnounce (Banner FR8), and useAnnounce(message, politeness) carries nothing that ties a message to this control's operation. Naming the observable trigger (for example, a busy announcement that is not yet exposed is withdrawn when its owner leaves busy, or when a later message reaches the channel) would make the rule testable when the outcome is announced while the control still renders busy, and would say what FR9's "none is dropped" does not cover.

@cixzhang
cixzhang merged commit 34056d8 into main Oct 24, 2026
52 checks passed
@github-actions
github-actions Bot deleted the spec/ast086-fr8-fr9-repeats branch October 24, 2026 06:20
cixzhang added a commit that referenced this pull request Oct 24, 2026
…#8235)

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

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

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.
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 — 63c5b22b 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. spec-auto-merge Auto-merge was enabled by the spec owner gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant