Skip to content

Commit 3c6f96f

Browse files
jhedlundEngineerclaude
committed
fix(desktop): start without the notification-area icon if it fails
Adding the Windows tray icon used `?` during setup, so any failure (for example the notification area being unavailable at launch) stopped Buzz from starting. The error is now logged instead, and closing the window hides it only while the icon exists; without one, Close quits as before, so the window is never hidden with no way back. Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jeff Hedlund <[email protected]>
1 parent 7035311 commit 3c6f96f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎src-tauri/src/lib.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,11 @@ pub fn run() {
10271027
#[cfg(target_os = "macos")]
10281028
reshow::install(app.handle());
10291029
// Before any close hides the window: the icon is the way back.
1030+
// Without it, closing quits as before (see the close handler).
10301031
#[cfg(windows)]
1031-
tray::install(app.handle())?;
1032+
if let Err(error) = tray::install(app.handle()) {
1033+
eprintln!("Could not add Buzz to the notification area: {error}");
1034+
}
10321035
#[cfg(target_os = "macos")]
10331036
if let Some(home) = dirs::home_dir() {
10341037
if let Err(error) = legacy_cli_shortcut::remove_stale(&home.join(".local/bin")) {
@@ -1291,8 +1294,9 @@ pub fn run() {
12911294
}
12921295
}
12931296
// As on macOS; the notification-area icon reopens and quits Buzz.
1297+
// Hide only when that icon exists, or the window could not come back.
12941298
#[cfg(windows)]
1295-
if window.label() == "main" {
1299+
if window.label() == "main" && tray::installed(window.app_handle()) {
12961300
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
12971301
api.prevent_close();
12981302
if let Err(error) = window.hide() {

‎src-tauri/src/tray.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ pub(crate) fn install<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<()> {
7373
Ok(())
7474
}
7575

76+
/// Whether Buzz's icon is in the notification area, so a closed window can
77+
/// come back.
78+
pub(crate) fn installed<R: Runtime>(app: &AppHandle<R>) -> bool {
79+
app.tray_by_id(TRAY_ID).is_some()
80+
}
81+
7682
#[cfg(test)]
7783
mod tests {
7884
use super::*;
@@ -88,6 +94,16 @@ mod tests {
8894
}
8995
}
9096

97+
#[test]
98+
fn installed_only_after_install() {
99+
let app = tauri::test::mock_builder()
100+
.build(crate::app_context())
101+
.expect("mock app");
102+
assert!(!installed(app.handle()));
103+
install(app.handle()).expect("tray icon");
104+
assert!(installed(app.handle()));
105+
}
106+
91107
#[test]
92108
fn menu_items_open_and_quit() {
93109
assert_eq!(command(OPEN_ID), Some(TrayCommand::Open));

0 commit comments

Comments
 (0)