Skip to content

fix(desktop): stop treating the Windows notification shim's startup "… - #1

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

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

Conversation

@bernhardkaindl

Copy link
Copy Markdown

…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

Summary

Related issue

Testing

…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The first Windows alert after each launch can still be dropped while permission repair races with delivery.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Works around the Windows Tauri notification shim bug described in block#2445.

Changes:

  • Detects Windows without matching Darwin.
  • Normalizes the shim’s false startup "denied" state to "default".
  • Adds regression coverage for Windows and unaffected platforms.
File summaries
File Description
desktop/src/shared/lib/platform.ts Adds Windows platform detection.
desktop/src/features/notifications/lib/desktop.ts Repairs the false permission state.
desktop/src/features/notifications/lib/desktopWindowsPermission.test.mjs Tests permission normalization.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +178 to +179
if (isWindowsShimDeniedPlaceholder()) {
return "default";
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."

3 participants