[loop cycle 4] fix(notifications): de-duplicate burst-repeated native toasts#12
Merged
Merged
Conversation
WhatsApp can raise the same alert more than once in a quick burst (a React re-render, or one message surfacing through two notification code paths). A browser collapses those by tag, but a native OS toast stacks each call as a separate visible popup, so the user sees the same notification two or three times. Add a nativeNotify(title, body) helper that suppresses an identical title+body seen within a 3500ms window (pruning stale keys each call so the map stays bounded), and route the window.Notification shim through it. Distinct messages — including different messages from the same chat — are never suppressed, and an identical alert is allowed again once the window expires. The title/body coercion is unchanged, and lock/settings suppression still happens downstream in the Rust notify command. Verified in a real WebKitGTK engine (origin spoofed to web.whatsapp.com): 5 fires with 2 identical immediate duplicates -> 3 native notifies; distinct title/body messages all delivered; the same alert re-fires after the window expires. Note: the dedup key uses a single-space separator. An earlier iteration used a NUL byte, which (being passed to the engine as a C string) truncated the whole injected script; that was caught by the engine harness and fixed before this commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016o9cWBaPy4zU4BAurUVoTp
karem505
added a commit
that referenced
this pull request
Jun 28, 2026
Bundles six loop-shipped fixes: - perf(dnd): stream dropped files as base64 to cut peak memory on large videos (#9) - fix(notifications): forward service-worker showNotification to the native toast (#10) - feat(calls): expose a minimal window.chrome so WhatsApp enables call buttons (#11) - fix(notifications): de-duplicate burst-repeated native toasts (#12) - fix(dnd): route AVIF/HEIF photos as photos; broaden MIME labels (#13) - fix(calls/capability): return a complete Chrome high-entropy client-hints set (#14) Plus integration: SW notifications share the dedup window; base64_encode is test-only now. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016o9cWBaPy4zU4BAurUVoTp
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.
What
Stops the same notification showing up two or three times. WhatsApp can raise the same alert more than once in a quick burst (a React re-render, or one message surfacing through two notification code paths). A browser collapses those by
tag, but a native OS toast stacks every call as a separate visible popup.How
Add a
nativeNotify(title, body)helper that suppresses an identicaltitle+bodyseen within a 3500ms window (pruning stale keys each call so the map stays bounded), and route thewindow.Notificationshim through it.notifycommand.Object.create(null)(no prototype-key hazards).Verification
Gate 1 —
cargo build --locked+cargo test: PASS (51 tests; bridge embedded viainclude_str!).Gate 2 — real WebKitGTK engine harness (origin spoofed,
invokerecorder): PASSGate 3 — generation-blind code review: APPROVE, severity none, no must-fix. Confirmed dedup correctness,
Object.create(null)key safety, safefor..in+delete prune, strict-mode legality, behavior parity.🤖 PR-ONLY — do not auto-merge. Releasing whatRust is manual via a
v*tag; this loop never merges, bumps the version, or tags a release. Opened by thewhatrust-fix-loop(cycle 4/6).