Repository navigation
fix(notifications): show Windows system notifications and keep their permission - #1109
Conversation
Findings
Validation
|
Findings
Validation
|
System notifications never appeared on Windows while CodeNomad was open. The setting reads "Notify when the app is focused", but delivery was skipped whenever the window was visible: an open window stays visible behind other applications, on another screen or partly covered, so notifications only arrived once it was minimized or fully hidden. The Windows side was fine: the Start menu shortcut carries CodeNomad's AppUserModelID and a toast sent under it shows. Delivery is now skipped only while the window is visible and has focus (document.hasFocus()), unless the setting is on. The setting's subtitle says "focused" in all ten languages, the Settings help explains that notifications appear whenever the window is not focused, even while it stays open on screen, and dev-docs/SETTINGS.md records the rule. A new browser test sends a real routed notification through the Notification API from a visible page: nothing while it has focus, a notification once it loses focus, and one while focused with the setting on. It fails on the previous visibility check and passes three times in a row with the fix; the UI typecheck passes.
On Windows, the Tauri app's system notifications never appeared when it ran a data profile such as dev. Tauri runs each profile under its own AppUserModelID (ai.neuralnomads.codenomad.client.scope.s<hash>) and its notifications carry that ID, but Windows shows a desktop app's notifications only under an ID it knows, and the installer's Start menu shortcut carries the stable ID alone. Windows recorded every notification (100 in the notification database of an affected machine) and displayed none. Every launch now registers the running ID under HKCU\Software\Classes\AppUserModelId\<identifier> with DisplayName CodeNomad and IconUri the bundled resources\ui-loading\pwa-192x192.png, the per-user registration Windows documents for unpackaged apps (windows_notification_identity.rs, called where the process sets its AppUserModelID). Electron always uses the stable ID, so only Tauri needs it. Settings also asked for notification permission again after every restart on Windows: the notification plugin's page script reports "denied" there until the page requests permission, though Windows never asks. The permission check now asks the native plugin command, which answers granted on desktop. Validated on the affected machine: none of the profile's notifications showed before; after registering its ID by hand as above, a notification sent under it showed in the notification centre under CodeNomad. A Windows unit test writes the key and reads back both values; the UI typecheck passes. dev-docs/DESKTOP_DATA_PROFILES.md describes the registration.
543c7cb to
0fef55f
Compare
Findings
Validation
No additional findings in the registry API use (windows-sys 0.59, NUL-terminated UTF-16 and byte lengths, key access/closure and logged errors), startup wiring, preservation of other default-ID values, permission capabilities for local/remote/Preferences windows, native desktop permission/request consistency, focus routing, or the ten-locale wording. The registry display-identity approach is consistent with Microsoft's Toolkit implementation and the minimal winrt-toast registration implementation; a COM Size note per repository rules: |
The notification identity pointed IconUri at resources\ui-loading\pwa-192x192.png, but the Tauri staging scripts copy only loading.html and assets/ into ui-loading: the file existed on the affected machine only as a leftover of an older install, carrying the previous logo, so a fresh install would register no icon. IconUri now names resources\server\public\pwa-192x192.png, the web app icon the bundled server's UI build generates from the current logo and its manifest references. The packaged-resource smoke check requires that file for every desktop build, so a missing icon fails packaging instead of silently dropping the notification icon. The smoke check passes on the installed Windows layout, and the Windows registry test still writes and reads back both values.
Findingszero findings on Evidence
Validation
|
Summary
System notifications on Windows: everything about them in one PR.
fix(windows): show system notifications from every data profile). Tauri runs each data profile, such as dev, under its own AppUserModelID (…client.scope.s<hash>), and its notifications carry that ID; Windows shows a desktop app's notifications only under an ID it knows, and the installer's Start menu shortcut carries the stable ID alone. Windows recorded every notification (100 on the affected machine) and displayed none. Every launch now registers the running ID underHKCU\Software\Classes\AppUserModelId\<identifier>(DisplayNameCodeNomad,IconUrithe bundled web app iconresources\server\public\pwa-192x192.png, which the packaged-resource smoke check requires;windows_notification_identity.rs). Electron always uses the stable ID.fix(notifications): hold system notifications back only while focused). With Notify when the app is focused off (the default), an open window stays visible behind other applications or on another screen, so nothing was sent unless CodeNomad was minimized. Delivery is now skipped only while the window is visible and focused (document.hasFocus()). The setting's subtitle and the Settings help say focused in all ten languages;dev-docs/SETTINGS.mdrecords the rule.Out of scope by decision: several CodeNomad windows open on the same project may each send the event's notification (as they already do when the setting is on), and focus inside a browser preview counts as leaving the page.
Validation
cargo test --bins -- windows_notification_identity(writes the key, reads back both values).tests/browser/system-notification-focus.test.ts: real routed notification from a visible page; nothing while focused, one once focus is lost, one while focused with the setting on; red on the previous visibility check.npm run typecheck --workspace @codenomad/ui,npm run test:help.