Collapse identical notifications from the same sender into one toast (#13522)

* Collapse identical notifications from the same sender into one toast

A web app open in several tabs fires one notification per tab for a single
reminder, stacking identical toasts. A new notification matching an on-screen
toast's app, summary, and body now replaces it like a replaces_id update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Only collapse live duplicates that share image and click target

Screen recording toasts share text but preview and open different files, and
replayed history rows share images with entries still in history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Compare a notification's current content when collapsing duplicates

A replaces_id update can land while the insert is deferred, so the initial
snapshot may no longer describe what the notification says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Opus 5.5 authored and GitHub committed 2026-09-28 12:04:15 +02:00
1 parent f814639556
commit de63134b88
3 files changed
+85

No files matched your search

@@ -223,6 +223,23 @@ function popupRowChanged(row, updated) {
return false
}
// The same message from the same sender under a new id. A web app open in
// several tabs (HEY, Gmail, Calendar) fires one notification per tab for a
// single reminder, all within the same moment — what the user means by that
// is one toast, not a stack of identical ones. The image and click target
// count too: every screen recording toast shares its text but previews and
// opens a different file.
var DUPLICATE_ROLES = ["app", "summary", "body", "image", "execArgv"]
function isDuplicatePopup(row, snapshot) {
if (!row || !snapshot || row.originalId === snapshot.originalId) return false
for (var i = 0; i < DUPLICATE_ROLES.length; i++) {
var role = DUPLICATE_ROLES[i]
if ((row[role] || "") !== (snapshot[role] || "")) return false
}
return true
}
// A client updating a notification through replaces_id keeps the identity of
// the popup it took over: the file name is the timestamp and id the popup was
// first persisted under, and the restore, replace and archive paths all key
@@ -462,6 +479,7 @@ if (typeof module !== "undefined") {
snapshotOf: snapshotOf,
popupRoles: popupRoles,
popupRowChanged: popupRowChanged,
isDuplicatePopup: isDuplicatePopup,
replacementSnapshot: replacementSnapshot,
historyEntry: historyEntry,
parseSettings: parseSettings,