Fix Windows notifications and multi-account startup - #26
Open
matheuscardosoj wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one likely compile-breaking issue (missing tauri::Manager import for app.config() in aumid.rs) that should be fixed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses Windows toast notification failures and several multi-account startup/locking edge cases by tightening Tauri ACL permissions, surfacing bridge IPC failures, and adjusting window-creation sequencing to avoid WebView2 deadlocks.
Changes:
- Add explicit custom command permissions/capabilities for the WhatsApp bridge, Settings, and lock windows; log bridge IPC failures without leaking message contents.
- Serialize account mutations and adjust window creation/focus flows (Settings + lock) to reduce WebView2 deadlock risk and enforce lock gating.
- Persist and expose a “default startup account” selection in Settings UI, plus small UX fixes (select option theming, idempotent autostart disable).
File summaries
| File | Description |
|---|---|
| src-tauri/src/window.rs | Gate account showing behind lock; serialize Settings window creation and improve error logging/visibility behavior. |
| src-tauri/src/settings.rs | Make autostart disable idempotent to avoid Windows “NotFound” failures when already off. |
| src-tauri/src/lock.rs | Serialize lock window creation off synchronous callbacks; avoid stale lock window if unlock races creation. |
| src-tauri/src/lib.rs | Add --settings single-instance behavior; prioritize startup account window visibility; defer some tray/settings work off setup. |
| src-tauri/src/commands.rs | Add persisted startup default selection plumbing; serialize account mutations; move account commands to async. |
| src-tauri/src/aumid.rs | Minor cleanup around Windows AUMID registration setup. |
| src-tauri/src/accounts.rs | Persist startup_account preference with validation + tests; add global mutation mutex. |
| src-tauri/resources/notifications.test.mjs | New Node tests covering notification/unread routing and IPC failure logging behavior. |
| src-tauri/resources/bridge.js | Log IPC failures (without payload), forward SW notifications, and ensure unread updates are invoked. |
| src-tauri/permissions/app.toml | Define custom command permissions for bridge/settings/lock to participate in ACL checks. |
| src-tauri/capabilities/settings.json | Grant Settings window capability the new settings-command permission. |
| src-tauri/capabilities/main-remote.json | Assign the WhatsApp remote capability to the new bridge permission set. |
| src-tauri/capabilities/lock.json | Grant lock window capability the new lock-command permission. |
| settings-ui/style.css | Force readable native <option> colors across themes; improve account row wrapping. |
| settings-ui/main.js | Add “default startup account” selector and serialize UI actions with a busy state + status messages. |
| settings-ui/index.html | Add default startup account field + live status note region for account actions. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #[cfg(windows)] | ||
| { | ||
| use tauri::Manager; | ||
| let config = app.config(); |
| open: app | ||
| .get_webview_window(&accounts::window_label(&a.id)) | ||
| .is_some(), | ||
| is_default: accounts::startup_account(&f).is_some_and(|selected| selected.id == a.id), |
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.
Problem
On Windows, the remote WhatsApp Web context could call neither whatRust's custom notification commands nor Settings commands because its capability granted only the notification plugin's default permission. The bridge swallowed the resulting ACL rejection, so audio could play while toast notifications, unread state, and the notification sender registration flow failed silently.
The multi-account flow also created WebView windows synchronously from IPC commands, which can deadlock WebView2. There was no persisted startup-account choice. In Settings, native select options could become white text on a white menu, and saving while autostart was disabled attempted to remove a non-existent launcher entry.
Changes
Validation
cargo clippy --all-targets -- -D warningscargo test --quiet(78 tests)node --test src-tauri/resources/notifications.test.mjs(4 tests)tauri build --bundles nsis --ciRelated to #3.