1 +#
Notification System Redesign 3 +**Status:** design approved in dialogue 2026-06-27, pending written review
5 +**Goal:** Replace the debug-label notification card with a real, metadata-aware notification system across three distinct surfaces (widget, popup, toast), rendering app icons and images that the service already captures but currently discards.
9 +Current notification card (PopoutHost `NotificationGroup`, ~1236-1575) shows developer scaffolding, not a usable UI:
11 +- App icon is a first-letter monogram (`appName.slice(0,1)` → "n"); real `appIcon`/`image` are captured in `normalize()` but never rendered.
12 +- Debug meta line `count · urgency · expandCollapseState` ("1 · normal · collapsed").
13 +- Cryptic expand pill `count + (expanded?"^":"v")` ("1v").
14 +- Action buttons are static rectangles with no hover/press feedback.
15 +- Body is single-line elided — multi-line bodies get truncated.
16 +- No transient toast: notifications are invisible until the panel is opened.
17 +- Drag-to-dismiss rig (~150 lines, dual MouseAreas, `pointerTrace`, `dragNotification` IPC) is awkward on an x230 with no touchscreen.
18 +- `Notifications.qml` carries telemetry/descriptor blobs nothing renders (`notificationPanelContract`, `pointerTrace`, `dragDismissContract`, `scrollableListChrome`, role-helper soup).
20 +The key enabler: `appIcon` and `image` are **already serialized into the notification JSON**. This is mostly a render-layer change plus service cleanup, not a service rewrite.
22 +##
Architecture: three surfaces, separate concerns 24 +| Surface | Renders | Mode | Status |
26 +| **Widget** (bar chip) | trigger + unread badge / active dot | no card | exists (active-dot work done) |
27 +| **Popup** (panel / notification center) | `NotificationCard` | **full** (detail) | exists, redesign |
28 +| **Toast** (transient on arrival) | `NotificationCard` | **compact** (single line) | **new** |
30 +Real-life flow: notification arrives → **toast** flashes top-screen, auto-fades → if missed, **widget** shows a dot → click widget → **popup** shows full history.
32 +###
NotificationCard component 34 +One component, `property bool compact`. The metadata→visual logic (urgency color, icon resolution, relative time) lives in one place; full and compact are genuinely different layouts selected by the flag. Popup instantiates full cards; toast instantiates compact cards.
36 +**Full mode layout:**
38 +┌──────────────────────────────────────────────┐
39 +│▌ [icon] appName time × │ accent bar = urgency · IconImage 36 · app dim · relative time · × on hover
41 +│ Body wraps two to three lines then │ wrapMode, then elide
44 +│ │ [thumb] │ │ image thumbnail when present
46 +│ [ Action ] [ Copy ] │ Flow of buttons, hover lightens / press darkens
47 +└──────────────────────────────────────────────┘
50 +**Compact mode layout (toast):**
52 +┌──────────────────────────────────────────────┐
53 +│▌ [icon] Summary │ accent bar = urgency · IconImage 20 · summary only
54 +└──────────────────────────────────────────────┘
57 +##
Metadata → mode rendering matrix 59 +Every field `notify-send`/mako can set, mapped deliberately. Source of truth: Quickshell `Notification` properties (`appName`, `appIcon`, `image`, `summary`, `body`, `urgency`, `actions`, `expireTimeout`, `transient`, `resident`, `hints`).
61 +| Metadata | Full mode (popup) | Compact mode (toast) |
63 +| **summary** | bold, 1 line | the single line (primary text) |
64 +| **body** | wraps 2–3 lines, then elide | hidden |
65 +| **appName** | dim, header | dropped |
66 +| **appIcon** (icon name) | 36px `IconImage` | 20px `IconImage` |
67 +| **image** (avatar/screenshot) | thumbnail block under body | dropped |
68 +| **urgency: low** | no accent bar, dim | subtle accent, short timeout |
69 +| **urgency: normal** | accent bar + border | accent, default timeout |
70 +| **urgency: critical** | red bar + border, highlighted | red, **no auto-dismiss**, **bypasses DND** |
71 +| **expireTimeout** | ignored — history persists | drives auto-dismiss timer; `0` or critical = sticky |
72 +| **actions** | button row + Copy | none — click = default action / opens popup |
73 +| **transient** | **not** added to history | toast only, never persists |
74 +| **resident** | stays open after action invoked | n/a |
75 +| **hints.value** (progress %) | progress bar | thin bar — **future / out of scope** (overlaps OSD) |
77 +**Core principle:** full mode = complete record (opened deliberately). compact mode = glanceable interrupt (summary + icon + urgency color). Urgency is the one field that changes *behavior*, not just looks.
81 +New transient `PanelWindow`, top-screen, `WlrLayer.Overlay`, `keyboardFocus: None`, modelled on the existing OSD overlay (shell.qml:121). Renders a vertical stack of compact `NotificationCard`s for currently-active toasts.
85 +- **Arrives** → becomes an active toast and stacks top-screen, **unless** DND is on (critical overrides DND) **or** the notification is transient-suppressed by DND.
86 +- **Auto-dismiss** after `expireTimeout` (or a default when `-1`). `expireTimeout == 0` → sticky. **Critical → sticky regardless** (manual dismissal only).
87 +- **Leaves** on: timeout elapsed, click, or `dismissToasts()`.
88 +- Dismissing a toast removes it from the toast surface only; it remains in popup history (unless `transient`, which is never added to history).
92 +- DND (`dnd`) suppresses normal/low toasts.
93 +- Critical toasts render even during DND (**DND bypass**) and never auto-dismiss (**sticky**).
97 +Drop drag-to-dismiss entirely. Replace with:
99 +- **× per card** (full mode) — fades in on hover, top-right. Calls `closeNotification(id)`.
100 +- **Clear all** — popup header, right side. Hidden/greyed when 0 notifications. Calls `discardAllNotifications()` (exists).
101 +- **Super+Esc** → `dismissToasts()` — clears all visible toasts without touching history.
105 +The panel currently renders a bare card stack (PopoutHost:550) with no header. Add a thin header row:
108 +│ Notifications · 3 [DND] Clear all │
111 +- Left: title + active count.
112 +- Right: **DND toggle** (`toggleDnd()`, exists — near-free real-life feature) + **Clear all**.
113 +- Below: card stack, or centered empty state ("No notifications") when count is 0, matching the media/tray empty-state pattern.
115 +##
IPC contract changes (`stateJson` is the contract — additive only) 117 +Keep `stateJson()` and every field the renderer consumes. Add:
119 +- `dismissToasts()` → hide all visible toasts, keep history. **Bound to Super+Esc.**
120 +- Existing, retained: `closeNotification`/`runAction(id,"close")`, `discardAllNotifications()`, `toggleDnd()`, `toggleGroup(appName)`.
121 +- Service must track `activeToasts` (ids currently shown as toasts) separately from history, and expose them in `stateJson()` so the toast window can render them.
123 +##
Deletions (standing /goal: less code) 125 +Remove from `Notifications.qml` (no renderer consumes them — verify with grep before cutting):
127 +- `notificationPanelContract()`, `dragDismissContract`, `scrollableListChrome()`
128 +- `pointerTrace`, `recordPointerEvent()`
129 +- `dragNotification()` and the drag MouseArea rig in PopoutHost
130 +- role-helper soup (`activeRole`/`attentionRole`/`borderRole`/`fillRole`/`widgetState`) — collapse to what the card actually needs
131 +- `maskedHorizontalActionRail` edge-fade masking (PopoutHost 1465-1525) → plain wrapping `Flow`
135 +Add to `niri/cfg/keybinds.kdl`:
137 +Mod+Escape ... { spawn ... "qs" "ipc" "-c" "nuguland" "call" "notifications" "dismissToasts" }
139 +Note: `Mod+ESCAPE` is currently `toggle-keyboard-shortcuts-inhibit` (the emergency-escape bind). Reconcile — either rebind dismiss elsewhere or move the inhibit toggle. **Decision needed at plan time.**
143 +- `Notifications.qml` — `activeToasts` tracking, `dismissToasts()`, DND/critical/transient lifecycle logic, delete telemetry.
144 +- `PopoutHost.qml` — new `NotificationCard` component (full/compact), popup header, delete drag rig + edge-fade masking, `IconImage`/`Image` rendering.
145 +- `shell.qml` — new toast `PanelWindow` (top-screen overlay) rendering compact cards.
146 +- `niri/cfg/keybinds.kdl` — Super+Esc → `dismissToasts`.
150 +Real test cases available (unlike earlier media/tray gaps):
152 +- `notify-send -i firefox "Test" "Body text"` — icon + body.
153 +- `notify-send -u critical "Alert" "Sticky"` — critical sticky + DND bypass.
154 +- Screenshot notification (image thumbnail).
155 +- `appIcon` is an icon **name** → must use `IconImage` (Quickshell.Widgets) for theme lookup, **not** plain `Image`. `image` is a path/url → plain `Image`. Confirm `image` survives the JSON-string round-trip and actually paints (screenshot before claiming success).
159 +- Inline reply (Quickshell `inlineReplySupported` currently false).
160 +- `hints.value` progress bars (overlaps OSD).