Skip to content

Fix Windows notifications and multi-account startup - #26

Open
matheuscardosoj wants to merge 1 commit into
karem505:masterfrom
matheuscardosoj:fix/windows-notification-acl
Open

Fix Windows notifications and multi-account startup#26
matheuscardosoj wants to merge 1 commit into
karem505:masterfrom
matheuscardosoj:fix/windows-notification-acl

Conversation

@matheuscardosoj

Copy link
Copy Markdown

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

  • Add explicit Tauri permissions for the WhatsApp bridge, Settings, and lock windows; assign them to their matching capabilities.
  • Surface bridge IPC failures to the local diagnostic log without message contents and cover notification/unread routing with Node tests.
  • Serialize account mutations and create account/Settings/lock WebViews on a blocking worker to avoid the WebView2 deadlock.
  • Persist a validated default account and open it first at startup while the other account windows remain connected in the background.
  • Make disabled autostart saves idempotent and define option foreground/background colors for both system themes.

Validation

  • cargo clippy --all-targets -- -D warnings
  • cargo test --quiet (78 tests)
  • node --test src-tauri/resources/notifications.test.mjs (4 tests)
  • tauri build --bundles nsis --ci
  • Manual Windows 11 / WebView2 validation from the NSIS installer: notification sender registration, startup default account, Settings save with autostart off, and native select colors in dark and light themes.

Related to #3.

@matheuscardosoj
matheuscardosoj marked this pull request as ready for review September 5, 2026 15:10
Copilot AI lite review requested due to automatic review settings September 5, 2026 15:10

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

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.

Comment thread src-tauri/src/aumid.rs
#[cfg(windows)]
{
use tauri::Manager;
let config = app.config();
Comment thread src-tauri/src/commands.rs
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),
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.

2 participants