Skip to content

fix(desktop): stop treating the Windows notification shim's startup "denied" as final - #7275

Open
Jakub-tupy wants to merge 1 commit into
block:mainfrom
Jakub-tupy:fix/windows-notification-permission
Open

Jakub-tupy wants to merge 1 commit into
block:mainfrom
Jakub-tupy:fix/windows-notification-permission

Conversation

@Jakub-tupy

Copy link
Copy Markdown

Summary

On Windows, desktop notifications could never be enabled: the Notifications settings card always showed "Desktop notifications are blocked. Enable them in your system settings.", the toggle snapped back off, and Buzz never appeared under Windows Settings → Notifications.

Root cause is in the window.Notification shim that tauri-plugin-notification (2.3.3, unchanged in 2.4.0) injects at startup. On Windows only, its isPermissionGranted() takes a shortcut that compares the shim's own freshly-initialised "default" against "granted" instead of asking the backend — always false — and stamps permission = "denied" on every launch. Buzz trusted that value, so requestPermission() was never called (the hooks only request from "default"), no toast was ever sent, and Windows never registered the app. Reinstalling cannot help because the value is recomputed on each start.

The desktop backend grants unconditionally on every platform, so a shim "denied" carries no information on Windows. This PR reports it as "default" there. The existing auto-request in use-feed-desktop-notifications (and the settings toggle) then call requestPermission(), which the shim answers by writing the backend's real "granted" into its cached state. Linux/macOS and non-Tauri browsers are untouched — a real "denied" stays authoritative.

Changes:

  • shared/lib/platform.ts: add isWindowsPlatform() (anchored ^win so "Darwin" never matches).
  • notifications/lib/desktop.ts: getDesktopNotificationPermissionState() treats a Windows shim "denied" as "default", with the reasoning documented inline.
  • notifications/lib/desktopWindowsPermission.test.mjs: regression test bound to the production seam — the Windows case fails without the guard; Linux and browser (non-Tauri) cases pin that "denied" stays "denied" there.

Related issue

Fixes #2445 (same diagnosis, reporter offered a PR but none was opened).

Testing

  • desktop unit tests for features/notifications/** and shared/lib/*: 422 passed. Removing the guard makes the new Windows test fail (verified).
  • tsc --noEmit clean, Biome clean, check:px-text clean.
  • Manual repro of the bug on Windows 11 with Buzz 0.5.20 (unsigned alpha): no Chromium content-setting for notifications exists in the WebView2 profile, no notifications entry in permission_actions, and Buzz is absent from Windows' per-app notification list — consistent with the shim never asking the OS. Not yet verified end-to-end with a rebuilt Windows binary; happy to do so if a maintainer can point me at the Windows build recipe used for the alpha installers.

…denied" as final

On Windows, tauri-plugin-notification's init script replaces
`window.Notification` with a shim and then decides the initial permission by
comparing its own freshly initialised "default" against "granted" instead of
asking the backend. The comparison is always false, so every launch stamps
`permission = "denied"` without any OS decision behind it. Buzz trusted that
value: the settings card showed "Desktop notifications are blocked. Enable them
in your system settings.", `requestPermission()` was never called (the hooks
only request from "default"), no toast was ever sent, and Windows never listed
the app under Settings > Notifications. Reinstalling cannot help because the
value is recomputed on each start.

The desktop backend grants unconditionally on every platform, so a shim
"denied" carries no information on Windows. Report it as "default" there: the
existing auto-request in `use-feed-desktop-notifications` (and the settings
toggle) then call `requestPermission()`, which the shim answers by writing the
backend's real "granted" into its cached state. Linux/macOS and non-Tauri
browsers are untouched — a real "denied" stays authoritative.

Adds `isWindowsPlatform()` (anchored so "Darwin" never matches) and a
regression test against the production seam; the Windows case fails without
the guard.

Fixes block#2445

Signed-off-by: Jakub Tupý <melltupy@gmail.com>
@Jakub-tupy
Jakub-tupy requested a review from a team as a code owner September 3, 2026 11:38
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is c6ca9d94d94230a315257a87beb8dc116fec56cc...8478e7d673938e5ec0244f28fb54a77219f1a178.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 8478e7d673938e5ec0244f28fb54a77219f1a178 to authorize a new review.
Any previous review applies only to its recorded range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: desktop notifications can never be enabled — "Desktop notifications are blocked. Enable them in your system settings."

1 participant