Repository navigation
Add a macOS menubar-only variant of whatRust - #28
Conversation
karem505
left a comment
There was a problem hiding this comment.
Thanks for this, @janbridley. A menu bar mode suits a lightweight client, and the stealth approach (alpha 0, click-through, kept ordered in so WebKit doesn't suspend the page) is a clever answer to WhatsApp dropping its socket. I've reviewed it against current master (v0.6.6). There are a few behaviour problems to fix first, and a rebase is needed.
Blocking
-
Two live sessions on the same account in popup mode. With
menubar_popupon andmenubar_onlyoff, the first tray click createswa-menubar. It loads web.whatsapp.com into the same data store as the first account's window (apply_isolationwith that account, and the default store fordefault). It then stays alive forever, stealthed. So two WhatsApp Web instances share one session's storage. WhatsApp Web normally reacts to that with "WhatsApp is open in another window → Use here", and one of the two instances goes dead. Did you test with the main window and the popup both loaded? Even if it does work, every message would then be notified twice:Recentde-duplicates per window label, sowa-defaultandwa-menubarboth raise a toast. I think the popup should reuse the account's webview rather than run a second one. Alternatively, popup mode could be allowed only when the account window isn't loaded, as in menubar-only mode. -
menubar_popupdefaults totrue.Settingsis#[serde(default)], so on upgrade every existing macOS user's tray click silently switches from "raise the window" to the popup. That also triggers (1). Please default it tofalseso it's opt-in. -
Unconditional
NSProcessInfoactivity.beginActivityWithOptions(UserInitiatedAllowingIdleSystemSleep)is held for the process lifetime on every macOS install, in every mode. That disables App Nap for all users, which costs battery. Please scope it to menu-bar-only mode, where the window is never truly visible. If it's needed in the normal window mode too, that deserves its own PR with evidence that the socket drops without it. -
Unread attribution. The popup mirrors
accounts.first(), butset_unreadattributeswa-menubar's count toActiveAccount. With several accounts, the popup's unread count lands on whichever account was last focused. Both should use the same account; storing the mirrored account id at creation and using it inset_unreadfixes this.
Needs updating for current master
The branch is based on 866e33b, and several things it touches have changed since:
- Links. Account windows now use
on_new_windowwithroute_new_window(#30): web, mailto and tel links go to the OS, andwa.me/invite links stay in-app. They also handlewhatsapp://deep links vialinks.rs(#23). The popup's builder only has the oldon_navigation, so links clicked in the popup won't open. Please build the popup through the same helper as account windows, or share the handler. - User agent. On macOS, account windows now use
user_agent(), which reports the system's Safari version so WhatsApp offers calls (#15). The popup hard-codesCHROME_UA. - Downloads and media.
enable_webview_mediaand the download handler (#21) changed. Again, reusing the account-window construction path avoids drift. set_unreadnow takes asettledflag and drives the unread fallback (notify::unread_increased). The attribution change needs to slot into that.- Settings UI was redesigned in #21 (GNOME-style grouped rows). The two checkboxes need porting to the new markup.
- ACL.
wa-menubardoes match themain-remotecapability (wa-*), so IPC works. A test inipc_acl_tests.rsasserting that would be good.
Smaller points
- Multi-account.
menubar_onlydestroys every account window and reaches only the first account: other accounts get no notifications, and the tray'sacct:items all open the same popup. Either restrict menubar-only mode to a single account, or say so clearly next to the setting. - Toggle on, then off.
settings::applyreopens account windows withstart_minimizedas the hidden flag. Turning menu-bar-only off from the popup could therefore leave you with no visible window. Showing the active account would be safer. - macOS check in Settings.
.mac-onlyrelies on a UA regex in the settings window. A smallplatformfield fromget_settings(ornavigator.platform) is less brittle.
Testing
The core macOS behaviour can't be covered by CI here. What would help most is a short screen recording or a note covering: the popup and main window both loaded at once (item 1), menu-bar-only mode surviving an hour in the background with notifications still arriving, and lock/unlock while the popup is open.
Generated by Claude Code



This pull request adds support for a menubar popup window on macOS, mirroring the main pane window but anchored to the menu bar icon. I've also added support to make the menu bar the only pane, so users can decide whether they want the desktop app, the menubar app, or both. Please let me know if this seems suitable for adoption in the main repo, or if you'd like any changes!