repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(notifications): resolve final whole-feature review findings

925938e69880601029f0552e6fae9d8648328b55

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Whole-feature review (26dff62..302f7c3) surfaced eight findings; fix the
two Important and three Minor here. #6/#7/#8 deferred (see commit body).

#1 (Important) Popup went stale-until-reopen after any interaction.
PopoutHost NotificationGroup.state is a binding over stateJson(); the
mutators (runAction/toggleGroup/toggleDnd/clearAll) imperatively
reassigned it, which destroys the binding in QML, so externally-arriving
notifications stopped appearing in the open popup. Mutators now call the
service for side-effects only and discard the return; stateJson() reads
reactive props so the binding re-evaluates on its own.

#2 (Important) nativeNotifications grew unbounded for the process life.
closeNotification now deletes its map entry (groups() skips closed rows
before liveRow(), so no stale read), and discardAllNotifications clears
the whole map. Verified: trackedNativeCount tracks the active set (3->3)
and drops to 0 on Clear all.

#3 (Minor) Full-mode card column reserved 92px of non-column width but
the Row consumes 102 (two 10px spacings, not one), overrunning the x by
10px. Fix the constant: -46 -> -56.

#4 (Minor) discardAllNotifications now also clears the toast stores, so a
sticky critical toast doesn't linger after "Clear all".

#5 (Minor) acceptNativeNotification only retains the native object when
history or a toast will reference it; a DND-suppressed transient
references neither and previously leaked an entry forever.

Deferred (review: "can follow"): #6 toast Timers restart on list rebuild
under a notification stream (UX quirk); #7 read is never set (mark-read
on open is a feature add); #8 relTime is not re-evaluated on a timer.

Verified: notificationsSelfTest green, journal warning-clean through a
mutator + normal/critical notifications with the popup open.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Changed files (3)

+34 / −12 text lines

Diff layout

quickshell/nuguland/NotificationCard.qml

Modified

+1 / −1 text lines

9090 // size off the card's own (externally-set) width, NOT parent.width:
9191 // cardBody is a Row whose width derives from content, so reading it
9292 // here collapses the column to 0 (a binding loop). 22 = left+right margins.
93 width: card.width - 22 - (card.compact ? 30 : 46) - closeCol.width
93 width: card.width - 22 - (card.compact ? 30 : 56) - closeCol.width
9494 spacing: card.compact ? 0 : 3
9696 Row {

quickshell/nuguland/Notifications.qml

Modified

+24 / −7 text lines

185185 notification.tracked = true;
186186 const id = String(notification.id);
187 const map = Object.assign({
188 }, nativeNotifications);
189 map[id] = notification;
190 nativeNotifications = map;
191187 const row = normalize({
192188 "id": id,
193189 "nativeId": id,
202198 "transient": notification.transient,
203199 "actions": notification.actions || []
204200 });
201 const eligible = toastEligible(row, dnd);
202 // only retain the live native object if something will render it:
203 // history (non-transient) or an active toast. A transient that DND
204 // suppresses references neither — storing it would leak forever.
205 if (!row.transient || eligible) {
206 const map = Object.assign({}, nativeNotifications);
207 map[id] = notification;
208 nativeNotifications = map;
209 }
205210 if (!row.transient)
206211 ingest(row);
207 if (toastEligible(row, dnd)) {
212 if (eligible) {
208213 const map = Object.assign({}, toastById);
209214 map[row.id] = row;
210215 toastById = map;
318323 const byApp = ({
319324 });
320325 for (let raw = 0; raw < notifications.length; raw++) {
321 const n = liveRow(notifications[raw]);
322 if (n.closed)
326 if (notifications[raw].closed)
323327 continue;
329 const n = liveRow(notifications[raw]);
325331 if (!byApp[n.appName])
326332 byApp[n.appName] = {
327333 "appName": n.appName,
416422 const tmap = Object.assign({}, toastById);
417423 delete tmap[String(row.id)];
418424 toastById = tmap;
426 // native object is dismissed; drop it so the map doesn't grow for the
427 // life of the process (groups() skips closed rows before liveRow()).
428 const nmap = Object.assign({}, nativeNotifications);
429 delete nmap[String(row.nativeId || row.id)];
430 nativeNotifications = nmap;
419431 }
421433 function runAction(notificationId, actionId) {
495507 function discardAllNotifications() {
496508 notifications = [];
497509 unreadCount = 0;
510 // "Clear all" means everything: drop showing toasts (incl. sticky
511 // criticals) and release every tracked native object.
512 activeToasts = [];
513 toastById = ({});
514 nativeNotifications = ({});
498515 lastAction = {
499516 "kind": "discardAll",
500517 "route": "Notifications.qml"

quickshell/nuguland/PopoutHost.qml

Modified

+9 / −4 text lines

12411241 property var state: notificationService ? Util.parseJson(notificationService.stateJson(), {"groups": [], "dnd": false, "activeCount": 0}) : ({"groups": [], "dnd": false, "activeCount": 0})
12421242 readonly property var groups: state.groups || []
1244 // mutators trigger side-effects only; never assign to `state` — that
1245 // would destroy the binding above and freeze the open popup, so
1246 // externally-arriving notifications would stop appearing until reopen.
1247 // stateJson() reads reactive props (notifications/dnd/expandedGroups/…)
1248 // so the binding re-evaluates on its own after every mutation.
12441249 function runAction(id, actionId) {
12451250 if (notificationService)
1246 state = Util.parseJson(notificationService.runAction(id, actionId), state);
1251 notificationService.runAction(id, actionId);
12481253 function toggleGroup(appName) {
12491254 if (notificationService)
1250 state = Util.parseJson(notificationService.toggleGroup(appName), state);
1255 notificationService.toggleGroup(appName);
12521257 function toggleDnd() {
12531258 if (notificationService)
1254 state = Util.parseJson(notificationService.toggleDnd(), state);
1259 notificationService.toggleDnd();
12561261 function clearAll() {
12571262 if (notificationService)
1258 state = Util.parseJson(notificationService.discardAllNotifications(), state);
1263 notificationService.discardAllNotifications();
12611266 spacing: 8