Repository navigation
fix: clear clicked notifications and collapse per-window duplicates - #1408
Merged
Merged
Conversation
A clicked notification stayed in Notification Center, and with `--multi-window` every Pake window raised its own copy of the same message. `NSUserNotificationCenter` keeps an activated notification until it is explicitly withdrawn, so `didActivateNotification:` now removes it, the same way `close()` and tag replacement already withdraw theirs. With `--multi-window` every window runs its own instance of the site, so a single incoming message produced one identical notification per window, all competing for the same click and all indistinguishable; the page counted each one too, multiplying the dock badge by the window count. A *different* window repeating the same title+body within 1s now collapses into the first notification, while a site legitimately repeating a message inside one window still gets every notification. Suppression is reported back to the page as `suppressed`, so it stops tracking a notification no click can reach, fires no `show`, and leaves the badge alone. Also declares the objc2-foundation features this module actually uses: `NSUserNotification` and `NSArray` were only reaching it through feature unification from other crates, so an unrelated dependency change could break the build with no local cause. Dedupe is covered by unit tests in the module; the page-side suppression and badge paths by tests/unit/notification-bridge.test.js.
The dock badge is one count for the whole app. When a window's copy of a message is suppressed, the window that delivered it has already counted it, but the suppressed window never marked its auto badge as active, so clicking or typing there left the shared badge in place. A suppressed reply now arms the clear without incrementing, under the same unread and page-managed rules as a delivered one. Cross-window dedupe is also limited to the macOS native-click path. Only that path routes a click to the exact window that raised the notification. The Windows/Linux fallback (and macOS without a native center) arms a focus click per window, so suppressing a copy there loses the click whenever the OS activates the suppressed window, while the owner keeps a stale focus target that can fire a phantom click later.
Owner
|
@yhcharles Thanks for following up on #1394. This is merged and shipped in pake-cli 3.17.3. Before merging I pushed one fix onto your branch: a window whose copy was suppressed can now still clear the shared dock badge when you click or type in it. I also limited the cross-window dedupe to the macOS native click path, because Windows and Linux cannot tell which window a toast belongs to, so collapsing copies there could lose the click. Run |
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.
Follow-up to #1394, covering the two pieces of the original notification work that did not land with it.
Problem
NSUserNotificationCenterkeeps an activated notification until it is explicitly withdrawn; fix: route native notification clicks back to the page聽#1394 withdraws onclose()and tag replacement, but not on activation.--multi-window, every window runs its own instance of the site, so one incoming message raises one identical notification per window. They all compete for the same click, are indistinguishable in Notification Center, and each one increments the dock badge, so the badge multiplies by the window count.Fix
didActivateNotification:removes the activated notification from the center before dispatching the click.sendkeeps a small, time-bounded registry keyed on title+body. A different window repeating the same message within 1s is reported back assuppressedinstead of being delivered. A site legitimately repeating a message inside one window still gets every notification, and a repeat after the window has passed is delivered normally.suppressedoutcome forgets the notification (no click can ever reach it), fires noshow, and does not touch the badge. This sits after the existing stale-reply check, so the close/replacement ordering guarantees from fix: route native notification clicks back to the page聽#1394 are unchanged.objc2-foundationnow declares theNSUserNotificationandNSArrayfeaturesnotification.rsuses. They currently reach the module only through feature unification from other crates, so an unrelated dependency change could break the build with no local cause.A suppressed window's notification is not clickable, so a click always lands in the window whose copy was delivered. That matches today's behavior, where each window's notification routes to that window.
Verification
cargo test --lib: the 5 new dedupe tests innotification.rspass. Locally, two existing redirect tests ininvoke.rs(redirects_keep_the_limit_relative_locations_and_statuses,redirects_recheck_cookies_and_never_restore_full_referrer) fail on my machine; they fail identically on unmodifiedmain, while Quality & Testing is green onmain, so they look environment-specific and unrelated to this change.npx vitest run: 538 passed, including 3 new cases intests/unit/notification-bridge.test.js(suppressed notification is not clickable and fires noshow; suppressed does not increment the badge; delivered does).cargo clippy --all-targets: no new warnings.cargo fmt --check,prettier --check: clean.