Daily use 27: fluxer-platform notification identity, click raise, idle probe (#516) #545

Closed
charles wants to merge 0 commits from dailyuse-27-platform-notification-idle into dailyuse
Owner

What

fluxer-platform notification identity, click reporting, icons and the idle probe (spec §3.11, §9, §17 Q4, Q6).

  • Notifier::notify_with_icon(&Notification, Option<&NotificationIcon>) with a default that calls notify (the runtime's test fake keeps compiling). NotificationIcon::from_png (avatar PNG 128 from the media proxy) and from_rgba (pixels as the image cache decodes them, encoded to PNG). The icon stays outside fluxer_core::Notification, whose icon: Option<Url> field Task 11a adds; Task 28 fetches the URL and passes the bytes here.
  • Linux (notify/linux.rs): hints desktop-entry = APP_ID (flaxative, the basename of packaging/linux/flaxative.desktop, which already has X-GNOME-UsesNotifications=true, so no packaging change), category = im (was im.received), urgency = normal, the default action "Open", and the avatar as image-data. This matches the original's desk/main/NotificationsIpc.ts:284-300. freedesktop_notification() builds the notification without a bus.
  • Windows (notify/windows.rs): toasts through tauri-winrt-notification under WINDOWS_APP_USER_MODEL_ID. The avatar is the circular app logo, written once by IconFiles to %TEMP%\flaxative-notification-icons, with at most 64 files kept. The toast has no sound, as before. If WinRT refuses our AUMID, the toast is shown again under PowerShell's id. windows_toast() describes the toast on every OS.
  • Clicks: OnClick gets the clicked Notification, which carries (channel_id, message_id). On Windows it is called straight from the toast's activation callback.
  • idle::system_idle() -> Option<Duration>: on Windows, GetLastInputInfo against GetTickCount. On Linux, org.gnome.Mutter.IdleMonitor.GetIdletime, then org.freedesktop.ScreenSaver.GetSessionIdleTime, then None. Each D-Bus call times out after 2 s. system_idle_on_bus(address) exists for tests.
  • Velopack shortcut AUMID (recorded in the README): the shortcut is velopack.Flaxative, because xtask packs no shortcutAumid. The process and the toasts use Forked.Flaxative, so toasts under the installer may be dropped. Follow-up: #544.

Tests

  • tests/notify_identity.rs: linux_hints_include_desktop_entry, linux_icon_attached, linux_icon_from_rgba_attached, linux_undecodable_icon_is_left_out, windows_toast_uses_aumid, rgba_icon_needs_the_pixels_it_claims, icon_files_are_written_once_per_image, icon_files_are_bounded, notify_with_icon_falls_back_to_notify, and toast_click_round_trip (needs FLUXER_DESKTOP_TESTS=1).
  • tests/idle.rs: idle_none_without_bus_is_ok and idle_probe_reports_a_duration (needs FLUXER_DESKTOP_TESTS=1).
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green locally.
  • Ran with FLUXER_DESKTOP_TESTS=1: idle_probe_reports_a_duration on KDE Plasma 6 Wayland. It passed, but this session has no idle API (GetSessionIdleTime answers "not supported", and the Mutter monitor is missing), so the probe returns None here and Task 28's window-input fallback is what applies. Not run: toast_click_round_trip, which needs someone to click.
  • The Windows code could not be built here: ring needs the Windows SDK. Instead I put notify/ and idle.rs in a scratch crate and ran cargo clippy --target x86_64-pc-windows-msvc -D warnings on it, which passed. The Windows runner is the real check.

Deviations

  • windows_toast_uses_aumid checks the WindowsToast description, not the toast XML: tauri-winrt-notification builds the XML privately. It is not cfg(windows), so it runs on every OS.
  • On Windows, tauri-winrt-notification is now a direct dependency instead of going through notify-rust, because notify-rust can only place an image inline and cannot set an app logo. It is the same version already in the graph (0.8.1).
  • Linux sends the icon as image-data, like the original, rather than as a file path. This turns on notify-rust's images_no_default_features feature; no new crate.
  • Outside the Files list: the root Cargo.toml gets workspace entries for zbus 6 (already in the graph through notify-rust) and tauri-winrt-notification, plus the windows features Win32_UI_Input_KeyboardAndMouse and Win32_System_SystemInformation. Cargo.lock is updated to match. cargo deny is green.
  • Not done: activating the app from the Action Center after it has quit, which would need a COM toast activator CLSID.

Closes #516
Refs #54, #55

🤖 Generated with Claude Code

## What `fluxer-platform` notification identity, click reporting, icons and the idle probe (spec §3.11, §9, §17 Q4, Q6). - **`Notifier::notify_with_icon(&Notification, Option<&NotificationIcon>)`** with a default that calls `notify` (the runtime's test fake keeps compiling). `NotificationIcon::from_png` (avatar PNG 128 from the media proxy) and `from_rgba` (pixels as the image cache decodes them, encoded to PNG). The icon stays outside `fluxer_core::Notification`, whose `icon: Option<Url>` field Task 11a adds; Task 28 fetches the URL and passes the bytes here. - **Linux** (`notify/linux.rs`): hints `desktop-entry` = `APP_ID` (`flaxative`, the basename of `packaging/linux/flaxative.desktop`, which already has `X-GNOME-UsesNotifications=true`, so no packaging change), `category` = `im` (was `im.received`), `urgency` = normal, the `default` action "Open", and the avatar as `image-data`. This matches the original's `desk/main/NotificationsIpc.ts:284-300`. `freedesktop_notification()` builds the notification without a bus. - **Windows** (`notify/windows.rs`): toasts through `tauri-winrt-notification` under `WINDOWS_APP_USER_MODEL_ID`. The avatar is the circular app logo, written once by `IconFiles` to `%TEMP%\flaxative-notification-icons`, with at most 64 files kept. The toast has no sound, as before. If WinRT refuses our AUMID, the toast is shown again under PowerShell's id. `windows_toast()` describes the toast on every OS. - **Clicks**: `OnClick` gets the clicked `Notification`, which carries `(channel_id, message_id)`. On Windows it is called straight from the toast's activation callback. - **`idle::system_idle() -> Option<Duration>`**: on Windows, `GetLastInputInfo` against `GetTickCount`. On Linux, `org.gnome.Mutter.IdleMonitor.GetIdletime`, then `org.freedesktop.ScreenSaver.GetSessionIdleTime`, then `None`. Each D-Bus call times out after 2 s. `system_idle_on_bus(address)` exists for tests. - **Velopack shortcut AUMID** (recorded in the README): the shortcut is `velopack.Flaxative`, because xtask packs no `shortcutAumid`. The process and the toasts use `Forked.Flaxative`, so toasts under the installer may be dropped. Follow-up: #544. ## Tests - `tests/notify_identity.rs`: `linux_hints_include_desktop_entry`, `linux_icon_attached`, `linux_icon_from_rgba_attached`, `linux_undecodable_icon_is_left_out`, `windows_toast_uses_aumid`, `rgba_icon_needs_the_pixels_it_claims`, `icon_files_are_written_once_per_image`, `icon_files_are_bounded`, `notify_with_icon_falls_back_to_notify`, and `toast_click_round_trip` (needs `FLUXER_DESKTOP_TESTS=1`). - `tests/idle.rs`: `idle_none_without_bus_is_ok` and `idle_probe_reports_a_duration` (needs `FLUXER_DESKTOP_TESTS=1`). - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is green locally. - Ran with `FLUXER_DESKTOP_TESTS=1`: `idle_probe_reports_a_duration` on KDE Plasma 6 Wayland. It passed, but this session has no idle API (`GetSessionIdleTime` answers "not supported", and the Mutter monitor is missing), so the probe returns `None` here and Task 28's window-input fallback is what applies. **Not run:** `toast_click_round_trip`, which needs someone to click. - The Windows code could not be built here: ring needs the Windows SDK. Instead I put `notify/` and `idle.rs` in a scratch crate and ran `cargo clippy --target x86_64-pc-windows-msvc -D warnings` on it, which passed. The Windows runner is the real check. ## Deviations - `windows_toast_uses_aumid` checks the `WindowsToast` description, not the toast XML: `tauri-winrt-notification` builds the XML privately. It is not `cfg(windows)`, so it runs on every OS. - On Windows, `tauri-winrt-notification` is now a direct dependency instead of going through `notify-rust`, because `notify-rust` can only place an image inline and cannot set an app logo. It is the same version already in the graph (0.8.1). - Linux sends the icon as `image-data`, like the original, rather than as a file path. This turns on `notify-rust`'s `images_no_default_features` feature; no new crate. - Outside the Files list: the root `Cargo.toml` gets workspace entries for `zbus` 6 (already in the graph through `notify-rust`) and `tauri-winrt-notification`, plus the `windows` features `Win32_UI_Input_KeyboardAndMouse` and `Win32_System_SystemInformation`. `Cargo.lock` is updated to match. `cargo deny` is green. - Not done: activating the app from the Action Center after it has quit, which would need a COM toast activator CLSID. Closes #516 Refs #54, #55 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Failing tests for Daily use 27: the freedesktop notification carries the
desktop-entry, category im, urgency normal hints and the avatar as
image-data; the Windows toast is raised under the client's
AppUserModelID; icon files are written once and bounded; the idle probe
answers None without a session bus. The real-desktop tests
(toast_click_round_trip, idle_probe_reports_a_duration) run only with
FLUXER_DESKTOP_TESTS=1.

Refs #516

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Notifications carry Flaxative's identity (spec §3.11, §17 Q6). Linux:
hints desktop-entry = APP_ID, category im, urgency normal, the default
action and the author's avatar as image-data, as the original sends them
(desk/main/NotificationsIpc.ts:284-300). Windows: toasts through
tauri-winrt-notification under WINDOWS_APP_USER_MODEL_ID with the avatar
as a circular app logo (IconFiles writes it once), falling back to
PowerShell's id when the system refuses ours; the click callback calls
OnClick with the notification (channel_id, message_id). Notifier gains
notify_with_icon with a default that calls notify.

idle::system_idle(): GetLastInputInfo on Windows; on Linux
org.gnome.Mutter.IdleMonitor.GetIdletime, then
org.freedesktop.ScreenSaver.GetSessionIdleTime, else None (spec §17 Q4).
README records the Velopack shortcut's AUMID (velopack.Flaxative unless
vpk packs a custom one).

Refs #516

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

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

Independent review: Daily use 27 (diff f2de7cd..dailyuse-27-platform-notification-idle)

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a clean review worktree: all steps passed (exit 0). It ran linux_hints_include_desktop_entry, linux_icon_attached, windows_toast_uses_aumid and idle_none_without_bus_is_ok; the desktop-only tests are skipped without FLUXER_DESKTOP_TESTS=1. The Windows code was not compiled here, so the Windows runner is the real check for it.

What I checked

  • Tests: every test the plan names exists. The Linux test asserts desktop-entry = APP_ID (flaxative), category = im, urgency = Normal, the actions ["default","Open"] and the presence or absence of image-data. The idle test asserts None on a missing bus and on a bad address, within 5 s.
  • Interfaces: idle::system_idle() -> Option<Duration> is there, with Windows GetLastInputInfo and on Linux Mutter GetIdletime and then ScreenSaver.GetSessionIdleTime, as the plan says. The click passes the Notification, whose channel_id and message_id reach OnClick. X-GNOME-UsesNotifications=true is already in packaging/linux/flaxative.desktop, and APP_ID matches its basename. The icon goes through Notifier::notify_with_icon(&Notification, Option<&NotificationIcon>); that fits Task 28's "fetched (PNG 128) and passed to the notifier".
  • Invariants: no fluxer-core or fluxer-ui changes. Bad icon bytes cannot panic: the PNG decode is limited (4096 px, 64 MiB), from_rgba checks the length, and a bad icon is just left out. No secrets. The new dependencies are versions already in the graph, and cargo deny is green.
  • Parity, against the fork:
    • fluxer_desktop/src/main/NotificationsIpc.ts:290-300: urgency: 'normal', category: 'im', desktopEntry, default action. These match.
    • MainI18n.ts:110: 'desktop.notifications.open': 'Open'. This matches.
    • NotificationsIpc.ts:175-183: the click is passed back for the restore/show/focus that Task 28 does. This matches.
    • DesktopIdentity.ts: the original's ids are app.fluxer.FluxerDesktop and Fluxer.Fluxer; this branch uses Flaxative's own, per spec §17 Q6. This matches.

Findings

  1. minor (Windows risk, plausible): toasts are now raised under Forked.Flaxative. The PowerShell fallback only fires when Show() returns an error, but Windows often accepts a toast for an AUMID that no shortcut carries and then drops it without an error. That applies to the portable exe, and to the installed app as long as the Velopack shortcut is velopack.Flaxative (#544). Notifications that used to show under PowerShell could vanish on Windows. Recommend checking on Windows hardware, and fixing #544 or falling back to PowerShell's id when no shortcut with our AUMID exists, before Task 28 ships. It is already tracked as #544, so it does not block this PR.
  2. minor (parity): the original also sends suppressSound: true and transient: false (NotificationsIpc.ts:294-295). The Linux build sends neither, so the server's default sound plays. The spec §3.11 list does not require these. The README line "sent as the original sends them" slightly overstates the match.
  3. minor (merge note): Task 11a adds Notification.icon: Option<Url>. The struct literal in tests/notify_identity.rs::notification() will then need icon: None. It is a mechanical fix for whichever branch lands second.
  4. minor (plan deviation, accepted): windows_toast_uses_aumid runs on every OS and checks a WindowsToast description, not the toast XML. That show() actually uses spec.app_id is only checked by reading the code.
  5. nit: idle::system_idle opens a new D-Bus connection on every call. With one call every 15 s this is fine.

Verdict: approve. No blocking findings and local CI is green; the Windows runner still has to pass.

## Independent review: Daily use 27 (diff f2de7cd..dailyuse-27-platform-notification-idle) **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a clean review worktree: **all steps passed** (exit 0). It ran `linux_hints_include_desktop_entry`, `linux_icon_attached`, `windows_toast_uses_aumid` and `idle_none_without_bus_is_ok`; the desktop-only tests are skipped without `FLUXER_DESKTOP_TESTS=1`. The Windows code was not compiled here, so the Windows runner is the real check for it. **What I checked** - Tests: every test the plan names exists. The Linux test asserts `desktop-entry = APP_ID` (`flaxative`), `category = im`, `urgency = Normal`, the actions `["default","Open"]` and the presence or absence of `image-data`. The idle test asserts `None` on a missing bus and on a bad address, within 5 s. - Interfaces: `idle::system_idle() -> Option<Duration>` is there, with Windows `GetLastInputInfo` and on Linux Mutter `GetIdletime` and then `ScreenSaver.GetSessionIdleTime`, as the plan says. The click passes the `Notification`, whose `channel_id` and `message_id` reach `OnClick`. `X-GNOME-UsesNotifications=true` is already in `packaging/linux/flaxative.desktop`, and `APP_ID` matches its basename. The icon goes through `Notifier::notify_with_icon(&Notification, Option<&NotificationIcon>)`; that fits Task 28's "fetched (PNG 128) and passed to the notifier". - Invariants: no `fluxer-core` or `fluxer-ui` changes. Bad icon bytes cannot panic: the PNG decode is limited (4096 px, 64 MiB), `from_rgba` checks the length, and a bad icon is just left out. No secrets. The new dependencies are versions already in the graph, and `cargo deny` is green. - Parity, against the fork: - `fluxer_desktop/src/main/NotificationsIpc.ts:290-300`: `urgency: 'normal'`, `category: 'im'`, `desktopEntry`, default action. These match. - `MainI18n.ts:110`: `'desktop.notifications.open': 'Open'`. This matches. - `NotificationsIpc.ts:175-183`: the click is passed back for the restore/show/focus that Task 28 does. This matches. - `DesktopIdentity.ts`: the original's ids are `app.fluxer.FluxerDesktop` and `Fluxer.Fluxer`; this branch uses Flaxative's own, per spec §17 Q6. This matches. **Findings** 1. **minor (Windows risk, plausible):** toasts are now raised under `Forked.Flaxative`. The PowerShell fallback only fires when `Show()` returns an error, but Windows often accepts a toast for an AUMID that no shortcut carries and then drops it without an error. That applies to the portable exe, and to the installed app as long as the Velopack shortcut is `velopack.Flaxative` (#544). Notifications that used to show under PowerShell could vanish on Windows. Recommend checking on Windows hardware, and fixing #544 or falling back to PowerShell's id when no shortcut with our AUMID exists, before Task 28 ships. It is already tracked as #544, so it does not block this PR. 2. **minor (parity):** the original also sends `suppressSound: true` and `transient: false` (`NotificationsIpc.ts:294-295`). The Linux build sends neither, so the server's default sound plays. The spec §3.11 list does not require these. The README line "sent as the original sends them" slightly overstates the match. 3. **minor (merge note):** Task 11a adds `Notification.icon: Option<Url>`. The struct literal in `tests/notify_identity.rs::notification()` will then need `icon: None`. It is a mechanical fix for whichever branch lands second. 4. **minor (plan deviation, accepted):** `windows_toast_uses_aumid` runs on every OS and checks a `WindowsToast` description, not the toast XML. That `show()` actually uses `spec.app_id` is only checked by reading the code. 5. **nit:** `idle::system_idle` opens a new D-Bus connection on every call. With one call every 15 s this is fine. **Verdict: approve.** No blocking findings and local CI is green; the Windows runner still has to pass.
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:04:14 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.