ECHOES-1357 Aggregate repeated same-text toasts of the same variety with a counter badge#693
Conversation
✅ Deploy Preview for echoes-react ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
29fc534 to
00d336b
Compare
00d336b to
c1a873a
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds automatic aggregation for repeated “same text + same variety” toast notifications, showing a repetition counter badge instead of rendering duplicate toasts. It extends the toast utility to track repetition state and refresh the auto-close timer on repeats, while updating the Toast UI to display the new counter in an accessible way.
Changes:
- Implemented automatic same-text toast aggregation in
src/utils/toasts.tsx, including deterministic IDs, repetition tracking, and timer refresh behavior. - Updated
Toastto accept and render arepetitionCountbadge (capped at99+) with a screen-reader announcement, plus added a new i18n key. - Added Storybook coverage and unit tests validating aggregation, variety separation, non-text exclusion, counter capping, and timer reset behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| stories/Toast-stories.tsx | Adds an “AggregatedRepeatedToasts” story and aligns controls/defaults to the updated toast behavior. |
| src/utils/toasts.tsx | Core aggregation logic: computes aggregation IDs from plain text, tracks repetition state, refreshes duration, and clears state on dismiss/auto-close. |
| src/utils/tests/toasts-test.tsx | Adds unit tests covering aggregation behavior, counter capping, non-text exclusion, and timer refresh. |
| src/components/badges/BadgeCounter.tsx | Broadens badge props to support standard <span> attributes while keeping value as the rendered content. |
| src/common/components/Toast.tsx | Renders repetition counter badge + screen-reader label, and adjusts trailing layout to accommodate badge + dismiss button. |
| i18n/keys.json | Adds toast.repetition-count message used for the repetition announcement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c1a873a to
46535ce
Compare
46535ce to
48c1d64
Compare
48c1d64 to
2a8f2ea
Compare
2a8f2ea to
d2dd6fe
Compare
|
|
||
| export interface BadgeCounterProps { | ||
| className?: string; | ||
| export interface BadgeCounterProps extends Omit<ComponentProps<'span'>, 'children'> { |
There was a problem hiding this comment.
the type was not reflecting what the component was actually accepting. Now we're using it with aria-hidden explicitly, this type is more faithful to the truth.
d2dd6fe to
a707905
Compare
a707905 to
36ab138
Compare
36ab138 to
7a983ca
Compare
7a983ca to
3ab6cbe
Compare
Agentic Analysis: Early ResultsAgentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action. 2 issue(s) found across 2 file(s):
Analyzed by SonarQube Agentic Analysis in 3.2 s |
3ab6cbe to
5a63a0b
Compare
5a63a0b to
2b049c6
Compare
2b049c6 to
135ac47
Compare
135ac47 to
16619bd
Compare
|
16619bd to
64896cb
Compare
…ith a counter badge
64896cb to
406cf77
Compare
CI failed: The test 'toast utility - automatic aggregation' failed due to a synchronization issue where the toast component fails to update the DOM correctly before the assertion. This is likely a race condition in the test's state management that needs to be resolved with proper act() wrappers.OverviewOne functional test failure was identified in the FailuresToast aggregation test failure (confidence: high)
Summary
Code Review ✅ Approved 10 resolved / 10 findingsAggregates repeated text toasts with a capped counter badge and refines lifecycle management to ensure timer consistency. All identified concerns regarding i18n, accessibility, and state management have been successfully resolved. ✅ 10 resolved✅ Edge Case: Repetition counter badge has no upper bound
✅ Quality: Screen-reader "Repeated {count} times" is off-by-one vs occurrences
✅ Quality: New i18n key 'toast.repetition-count' missing from i18n/keys.json
✅ Quality: hasActiveToast relies on undocumented sonner internals
✅ Quality: Timer refresh relies on undocumented Sonner duration behavior
...and 5 more resolved from earlier reviews Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
| if (!isDefined(titleText) || !isDefined(descriptionText)) { | ||
| return undefined; | ||
| } |
| * **Aggregating repeated toasts** | ||
| * | ||
| * When no explicit `id` is provided, repeated calls with the same plain-text `title`, the same | ||
| * plain-text `description`, and the same `variety` reuse the existing toast instead of creating | ||
| * duplicates. The toast keeps its original text and shows a counter badge on the right. |




Summary by Gitar
id.repetitionCountbadge to toasts that occur multiple times, capping display at99+.registerToastDismissHandleranddismissToastto manage tracking and cleanup of aggregated toasts.This will update automatically on new commits.