Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 494 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Requesting changes: the fix does what spec:AST-086 FR8 asks, and with a search that settles inside the busy-start frame, BaseTypeahead and CommandPalette no longer announce "Loading" after the result count. Two things need to change before this can be approved:
registerBusyAnnouncementSettleis public API becauseCommandPaletteContextValueanduseCommandPaletteContext()are exported, so please move the registration behind a non-exported context, asTypeahead/busyIndicatorLane.tsxdoes for BaseTypeahead, and give any remaining registration Effect a comment saying what it synchronizes.- The new tests would still pass if BaseTypeahead's settle call ran before the search starts, which brings the stale "Loading" back, so please add owner-level cases to
BusyOwnerAnnouncement.test.tsxwith a source that resolves inside the busy-start frame (FR8's "operation that settles before its busy announcement is exposed").
[Automated review]
| * The input's way to drop a busy start not yet announced; the palette | ||
| * calls it when a query's outcome is about to be announced (spec:AST-086 FR8). | ||
| */ | ||
| registerBusyAnnouncementSettle?: (settle: (() => void) | null) => void; |
There was a problem hiding this comment.
CommandPaletteContextValue and useCommandPaletteContext are exported from the package (CommandPalette/index.ts), so this member ships as public API whatever its comment says (architecture:public-component-api INV12). A non-exported context provided by CommandPalette, like Typeahead/busyIndicatorLane.tsx, would carry the same settle function without adding public surface.
| useEffect(() => { | ||
| if (registerSettle == null) { | ||
| return; | ||
| } | ||
| registerSettle(settleBusyAnnouncement); | ||
| return () => registerSettle(null); | ||
| }, [registerSettle, settleBusyAnnouncement]); |
There was a problem hiding this comment.
If this registration stays an Effect, please add a comment naming what it synchronizes (the palette's settle slot); architecture:react-component-runtime INV3 asks every new Effect to name it.
| ); | ||
| settle.mockClear(); | ||
| fireEvent.change(screen.getByRole('combobox'), {target: {value: 'Ap'}}); | ||
| await waitFor(() => expect(settle).toHaveBeenCalled()); |
There was a problem hiding this comment.
With the hook mocked, this proves only that settle was called at some point: it also passes if BaseTypeahead calls settle before await searchSource.search(...), where it drops nothing. An owner-level case in BusyOwnerAnnouncement.test.tsx with a source that resolves inside the busy-start frame would pin FR8's outcome.
… (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.
6175a5d to
d2e7895
Compare
There was a problem hiding this comment.
This restores spec:AST-086 FR8 for BaseTypeahead and CommandPalette: a typed query's pending "Loading" is dropped once its outcome is announced, and the new owner-level cases in BusyOwnerAnnouncement.test.tsx fail without the fix and pass with it, so I recommend approval. Two optional touch-ups: the changeset could name BaseTypeahead rather than Typeahead, since the styled Typeahead never had this race, and a rerender with a changed message while still busy would pin the hasAnnouncedRef line in settle.
[Automated review]
…s message changes; name BaseTypeahead in the changeset
There was a problem hiding this comment.
Changes requested for one build break: the fix itself does what spec:AST-086 FR8 asks, and the new owner-level cases show BaseTypeahead and CommandPalette no longer announcing “Loading” after a fast search's result count. The newest hook test fails pnpm -F @astryxdesign/core typecheck with TS2353 at useBusyAnnouncement.test.tsx:68, because renderHook infers its props type from initialProps: {isBusy: true}; typing the props, for example {initialProps: {isBusy: true} as {isBusy: boolean; message?: string}}, fixes it and keeps the tests green. Optionally, drop “or the no-results message” from the changeset, since an empty result never announced “Loading” after its message.
[Automated review]
| }); | ||
| // Still busy until the settled state commits: nothing is rescheduled, | ||
| // even when the busy message changes (a locale switch, say). | ||
| rerender({isBusy: true, message: 'Chargement'}); |
There was a problem hiding this comment.
tsc rejects this call (TS2353: message does not exist in type { isBusy: boolean; }), and the core typecheck fails on it: renderHook takes its props type from initialProps on line 27, not from the callback's annotation. Typing the props there, for example {initialProps: {isBusy: true} as {isBusy: boolean; message?: string}}, makes the typecheck pass and keeps the three tests green.
…#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.
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 the no-results message, or replacing them. 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
useBusyAnnouncementannounces 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.spec:AST-086FR8 (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-086FR8: 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.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 exportedCommandPaletteContextValueis 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.
useBusyAnnouncementand the new context are internal and are not exported.Evidence
main,useBusyAnnouncement.test.tsx"drops a busy start its owner settled before it was announced" fails, because the hook returns nothing to call.BusyOwnerAnnouncement.test.tsxadds 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.BusyOwnerAnnouncementsuite passes.cancelAnimationFramefails two hook tests.Scope
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 --noEmitfor core and eslint on the touched files are clean.spec:AST-009FR4, FR19): announcement routing and counts, with no screen-reader claim.