Tests never show real desktop notifications (#874) #878

Closed
charles wants to merge 0 commits from fix-874-tests-must-not-notify into textchat
Owner

Closes #874

Cause. Runtime::new (apps/fluxer/src/runtime.rs) defaulted to notifier: Box::new(system_notifier). Every runtime test and acceptance test builds its runtime with Runtime::new and, apart from the two daily-use tests that inject a FakeNotifier, never replaced it, so each devserver run that produced an Effect::Notify (e.g. the textchat fixture's "Got a minute? The release notes need a second pair of eyes.") went to the real org.freedesktop.Notifications on the session the gate ran in. Before #756 the Linux notifier panicked on the first notification, which hid this.

Fix (the issue's four points).

  1. Silent by default. Runtime::new now uses fluxer_platform::SilentNotifier (new: shows nothing, always Ok) unless with_notifier is called. The client's main passes fluxer_platform::system_notifier explicitly (one line). This covers every test rig, since all of them go through Runtime::new. Only these lines change in runtime.rs: the default, the with_notifier doc, an import, and one test at the end of mod tests.
  2. Off switch. system_notifier returns a SilentNotifier on every OS when FLUXER_NO_DESKTOP_NOTIFICATIONS is set to anything other than empty or 0 (fluxer_platform::{NO_DESKTOP_NOTIFICATIONS_ENV, desktop_notifications_disabled}). cargo xtask ci sets it in cargo_command, which every cargo step it runs (clippy, tests, vendored, screenshot and livekit tests, deny) goes through. notify_session_bus removes the variable for its child, because that child talks only to a private dbus-daemon with a fake server. The by-hand toast_click_round_trip skips when the variable is set.
  3. Audit of the other side effects tests could have on the live session:
    • Audio output: devserver runtimes use NullHost (devserver::voice_backend). Non-devserver runtimes use VoiceBackend::system(config.audio_null), but every apps/fluxer test sets devserver or injects paced_null. The real-device tests (FLUXER_AUDIO_DEVICE_TESTS, FLUXER_CAPTURE_TESTS with pw-play) only run when opted in. cpal's listing_devices_never_panics lists devices and plays nothing. No change needed.
    • xdg-open / explorer: Effect::OpenUrl falls back to the system opener when the Desktop has no LinkOpener, and update RevealDownload / OpenInstallLocation start xdg-open / explorer. No runtime test reaches these today: the only OpenUrl test (textchat_acceptance) injects FakeBrowser, and the update reveal/open tests are fluxer-ui tests that only assert the effect. This is a latent risk and is left unchanged here to keep the PR small (suggested follow-up).
    • Clipboard, window focus/raise, file dialogs: Desktop::new() has no services, so these effects are dropped. Only main wires ArboardClipboard, RfdDialogs, window_clipboard and window_commands. No change needed.
    • Tray, global shortcuts: not on textchat (they are being built on shell). They should follow the same pattern: no-op by default in Runtime::new, with the real one given by main.
    • Status API: the devserver binds port 0, and the API is disabled until settings enable it. No change needed.
  4. Tests that prove it:
    • crates/fluxer-platform/tests/notify_switch.rs runs child processes on a dead D-Bus address. With the switch set (1, yes), system_backends_made() must be 0 before anything is shown and notify must succeed. Without it (unset, 0, empty), the system notifier is made (Linux only), which shows the check is not vacuous.
    • apps/fluxer/src/runtime.rs the_default_notifier_is_silent: invoking Runtime::new's default factory does not call system_notifier (system_notifier_calls() is unchanged). I checked that it fails, even with the switch set, when the default is put back to system_notifier ("Runtime::new asked for the system's notifier").
    • xtask cargo_steps_turn_desktop_notifications_off.

Verification. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed locally ("==> xtask ci: all steps passed"), run under dbus-run-session, so no test could reach the real session bus. Goldens are unchanged.

Note for shell: main.rs must keep .with_notifier(fluxer_platform::system_notifier) on the Runtime::new chain. Without it the real client shows no notifications.

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

Closes #874 **Cause.** `Runtime::new` (apps/fluxer/src/runtime.rs) defaulted to `notifier: Box::new(system_notifier)`. Every runtime test and acceptance test builds its runtime with `Runtime::new` and, apart from the two daily-use tests that inject a `FakeNotifier`, never replaced it, so each devserver run that produced an `Effect::Notify` (e.g. the textchat fixture's "Got a minute? The release notes need a second pair of eyes.") went to the real `org.freedesktop.Notifications` on the session the gate ran in. Before #756 the Linux notifier panicked on the first notification, which hid this. **Fix (the issue's four points).** 1. **Silent by default.** `Runtime::new` now uses `fluxer_platform::SilentNotifier` (new: shows nothing, always `Ok`) unless `with_notifier` is called. The client's `main` passes `fluxer_platform::system_notifier` explicitly (one line). This covers every test rig, since all of them go through `Runtime::new`. Only these lines change in `runtime.rs`: the default, the `with_notifier` doc, an import, and one test at the end of `mod tests`. 2. **Off switch.** `system_notifier` returns a `SilentNotifier` on every OS when `FLUXER_NO_DESKTOP_NOTIFICATIONS` is set to anything other than empty or `0` (`fluxer_platform::{NO_DESKTOP_NOTIFICATIONS_ENV, desktop_notifications_disabled}`). `cargo xtask ci` sets it in `cargo_command`, which every cargo step it runs (clippy, tests, vendored, screenshot and livekit tests, deny) goes through. `notify_session_bus` removes the variable for its child, because that child talks only to a private `dbus-daemon` with a fake server. The by-hand `toast_click_round_trip` skips when the variable is set. 3. **Audit of the other side effects tests could have on the live session:** - *Audio output:* devserver runtimes use `NullHost` (`devserver::voice_backend`). Non-devserver runtimes use `VoiceBackend::system(config.audio_null)`, but every apps/fluxer test sets `devserver` or injects `paced_null`. The real-device tests (`FLUXER_AUDIO_DEVICE_TESTS`, `FLUXER_CAPTURE_TESTS` with `pw-play`) only run when opted in. `cpal`'s `listing_devices_never_panics` lists devices and plays nothing. No change needed. - *xdg-open / explorer:* `Effect::OpenUrl` falls back to the system opener when the `Desktop` has no `LinkOpener`, and update `RevealDownload` / `OpenInstallLocation` start `xdg-open` / `explorer`. No runtime test reaches these today: the only `OpenUrl` test (textchat_acceptance) injects `FakeBrowser`, and the update reveal/open tests are fluxer-ui tests that only assert the effect. This is a latent risk and is left unchanged here to keep the PR small (suggested follow-up). - *Clipboard, window focus/raise, file dialogs:* `Desktop::new()` has no services, so these effects are dropped. Only `main` wires `ArboardClipboard`, `RfdDialogs`, `window_clipboard` and `window_commands`. No change needed. - *Tray, global shortcuts:* not on `textchat` (they are being built on `shell`). They should follow the same pattern: no-op by default in `Runtime::new`, with the real one given by `main`. - *Status API:* the devserver binds port 0, and the API is disabled until settings enable it. No change needed. 4. **Tests that prove it:** - `crates/fluxer-platform/tests/notify_switch.rs` runs child processes on a dead D-Bus address. With the switch set (`1`, `yes`), `system_backends_made()` must be 0 before anything is shown and `notify` must succeed. Without it (unset, `0`, empty), the system notifier is made (Linux only), which shows the check is not vacuous. - `apps/fluxer/src/runtime.rs` `the_default_notifier_is_silent`: invoking `Runtime::new`'s default factory does not call `system_notifier` (`system_notifier_calls()` is unchanged). I checked that it fails, even with the switch set, when the default is put back to `system_notifier` ("Runtime::new asked for the system's notifier"). - `xtask` `cargo_steps_turn_desktop_notifications_off`. **Verification.** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed locally ("==> xtask ci: all steps passed"), run under `dbus-run-session`, so no test could reach the real session bus. Goldens are unchanged. **Note for `shell`:** `main.rs` must keep `.with_notifier(fluxer_platform::system_notifier)` on the `Runtime::new` chain. Without it the real client shows no notifications. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Runtime::new defaulted to fluxer_platform::system_notifier, so every test
and devserver run that did not inject a fake notifier showed real
notifications (the textchat fixture's "Got a minute? ...") on the desktop
it ran on.

- Runtime::new now uses fluxer_platform::SilentNotifier unless a notifier
  is passed with with_notifier; the client's main passes system_notifier.
- system_notifier honours FLUXER_NO_DESKTOP_NOTIFICATIONS (anything but
  empty or 0) on every OS and returns a SilentNotifier; cargo xtask ci
  sets it on every cargo step it runs.
- notify_session_bus clears the switch for its child (private bus, fake
  server); the manual toast_click_round_trip skips when it is set.
- Tests: notify_switch (child processes: the system notifier is never
  made with the switch set, and is made without it), runtime
  the_default_notifier_is_silent, xtask cargo_steps_turn_desktop_notifications_off.

Refs #874

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Merged into textchat by hand (the merge API returns 405); the commits are in the branch.

Merged into `textchat` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-18 07:43:54 +00:00
charles referenced this pull request from a commit 2026-11-18 07:45:41 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.