Repository navigation
fix(notifications): restore exact prior state on undo - #1300
Merged
greatest0fallt1me merged 3 commits intoOct 24, 2026
Merged
Conversation
|
@Tekgodfrey Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
@greatest0fallt1me kindly review sir |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # src/lib/draw-credit-pricing.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
fix(notifications): restore exact prior state on undo and fix Shift+R shortcut
Description
Closes #1225
This PR ensures that
NotificationCenter's undo actions restore the exact prior state the user had, makes undo actions resilient against category mute preferences, and fixes theShift+Rkeyboard shortcut so it fires reliably in real browsers while ignoring inputs in editable fields.Undo Semantics & Architecture
1. Exact Undo for "Mark All as Read"
handleMarkAllAsReadfilters and captures only the IDs of notifications that were unread at execution time (notifications.filter(n => !n.read).map(n => n.id)).undoRead(unreadIds), marking only those captured items as unread. Notifications that were already read before the action maintain their read state.undoReadwith the same IDs is an idempotent state transition.2. Merge-Safe Undo for "Clear All"
restoreNotifications(snapshot)merges the cleared snapshot with any notifications that arrived or updated during the undo window via the pure helpermergeNotifications(snapshot, current, cap).id(with newer arrivals taking precedence), sorted descending bytimestamp(newest first), and capped at the 100-notification limit.3. Category Preferences Bypass (
bypassPreferences)bypassPreferences?: booleantoAddToastOptions.bypassPreferences: trueis set,addToastbypasses category mute checks (such aspreferences.system = false).4. Keyboard Shortcut (
Shift+R)e.key === 'r'toe.key.toLowerCase() === 'r'alongsidee.shiftKeyto account for standard browser keyboard event dispatching where holdingShiftsetse.key === 'R'.isEditableTarget(e.target)to suppress the shortcut if focus or the event target is inside an<input>,<textarea>,<select>, orisContentEditableelement.isPanelOpen === true) andunreadCount > 0.Regression Proof
mainbecauseundoRead(prior.map(n => n.id))marked all 5 notifications unread.preferences.system = false, Mark all): Failed onmainbecause the undo toast defaulted to category'system'andaddToastreturned'', suppressing the toast.mainbecause the existing test"activates mark all read with Shift+R keyboard shortcut"dispatchedRwithShift, which failed to matche.key === 'r'.All 3 scenarios now pass reliably.
Verification Results
Test Suite
npm test -- --run src/components/notifications/NotificationCenter.test.tsx src/context/__tests__/notificationMerge.test.ts