fix(desktop): stop treating the Windows notification shim's startup "… - #1
Open
bernhardkaindl wants to merge 1 commit into
Open
bernhardkaindl wants to merge 1 commit into
bernhardkaindl wants to merge 1 commit into
Conversation
…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>
There was a problem hiding this comment.
🟡 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…denied" as final
On Windows, tauri-plugin-notification's init script replaces
window.Notificationwith 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 stampspermission = "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 callrequestPermission(), 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