Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion shell/plugins/notifications/Markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ function slug(text) {
}

// The group key, rebuilt from a row's fields: per site for a browser,
// otherwise per app.
// otherwise per app. An unnamed sender is no app, so each of its toasts stands
// alone: first login's keybindings, git and update toasts are three, not a deck.
function regroup(row) {
var app = String(row.app || "")
var source = String(row.source || "")
if (app === "omarchy-action" || app === "notify-send") return "toast:" + String(row.key || "")
Comment thread
dhh marked this conversation as resolved.
Resolved
if (isBrowser(app) && source && source !== app && hostname(source)) return "web:" + hostname(source)
return "app:" + slug(app)
}
1 change: 1 addition & 0 deletions shell/plugins/notifications/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ Item {
// entry deliberately creates a separate card.
if (!replay) continue
row.key = nextKey()
row.groupKey = Markup.regroup(row)
}
if (!reserveLive(row.key)) break
showRow(row)
Expand Down
12 changes: 8 additions & 4 deletions test/shell.d/notifications/logic.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ for (let i = 0; i < 1000; i++) {
// A restored row cannot claim a site either unless it came from a browser.
assert.equal(Store.restored({ key: 'r', app: 'Chat', source: 'bank.example' }).groupKey, 'app:chat')
assert.equal(Store.restored({ key: 'r', app: 'Chromium', source: 'app.slack.com' }).groupKey, 'web:app.slack.com')
// An unnamed sender's toasts each stand alone rather than stacking.
for (const app of ['omarchy-action', 'notify-send'])
assert.notEqual(Store.restored({ key: 'a', app }).groupKey, Store.restored({ key: 'b', app }).groupKey, app)
}

{ // `-i name` is an icon name, not a picture; only the strict charset is kept.
Expand Down Expand Up @@ -353,7 +356,7 @@ function newCapacityScope() {
displayNames: ['fixture-display'], focusedDisplayName: 'fixture-display',
Quickshell: { screens: [] }, Hyprland: { monitorFor: screen => screen.monitor },
lowDuration: 5000, normalDuration: 8000, maxDuration: 30000,
Security: S, Delivery, Store,
Security: S, Delivery, Store, Markup: M,
NotificationUrgency: { Critical: 2, Normal: 1, Low: 0 },
Qt: { callLater: f => later.push(f),
md5: value => require('node:crypto').createHash('md5').update(value).digest('hex') },
Expand Down Expand Up @@ -744,12 +747,13 @@ for (const replay of [false, true]) { // Replay and startup restore share held r

{ // Repeated replay creates distinct cards; restore cannot overwrite an admitted key.
const s = newCapacityScope()
s.restoreRows([{ key: 'same', summary: 'Original' }], true)
s.restoreRows([{ key: 'same', summary: 'Replay' }], true)
s.restoreRows([{ key: 'same', summary: 'Stale startup' }], false)
s.restoreRows([{ key: 'same', app: 'notify-send', summary: 'Original' }], true)
s.restoreRows([{ key: 'same', app: 'notify-send', summary: 'Replay' }], true)
s.restoreRows([{ key: 'same', app: 'notify-send', summary: 'Stale startup' }], false)
s.drainCallLater()
assert.deepEqual(summaries(s.toasts.rows), ['Replay', 'Original'])
assert.equal(new Set(s.toasts.rows.map(r => r.key)).size, 2)
assert.equal(new Set(s.toasts.rows.map(r => r.groupKey)).size, 2, 'the replayed card is its own deck')
}

{ // Clearing pending rows cancels their callbacks even if replay reuses the exact key.
Expand Down
Loading