fix(windows): let Quit actually exit and enforce a single tray instance - #1226
Open
iamtoruk wants to merge 1 commit into
Open
fix(windows): let Quit actually exit and enforce a single tray instance#1226iamtoruk wants to merge 1 commit into
iamtoruk wants to merge 1 commit into
Conversation
Quit CodeBurn in the tray menu called app.exit(0), but ExitRequested was unconditionally prevented in the run loop, so the process never actually exited. Only prevent exit when code is None (the popover window closing on its own), letting an explicit app.exit(..) through. Launching the menubar app twice left two processes running, each registering its own flame + spend-badge tray icon pair, so the notification area showed four icons for one app. Add tauri-plugin-single-instance, registered first in the builder chain, so a second launch just refocuses the running instance's popover.
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.
Bugs, as observed on a Windows 11 VM
1. Quit does nothing. Right-click the tray icon > Quit CodeBurn and the app just keeps running. The Tauri run loop's
RunEvent::ExitRequestedhandler unconditionally calledapi.prevent_exit(), which also swallowed the explicitapp.exit(0)fired by the tray "quit" menu item andcommands::quit_app. In Tauri 2,ExitRequestedcarriescode: Option<i32>:Nonewhen the last window closes on its own,Some(_)for an explicitapp.exit(..). Fixed by only preventing exit whencode.is_none(), so the popover window closing still keeps the app resident in the tray, but Quit actually quits.2. Launching twice gives four tray icons. Each running instance registers two tray icons by design (the flame logo plus a spend badge icon next to it). Launching the app a second time (e.g. double-clicking the shortcut again) starts a second process instead of reusing the first, so the notification area ends up with two flame icons and two badge icons for what looks like one app. Fixed by adding
tauri-plugin-single-instance, registered first in the builder chain per its docs; a second launch now just calls the existingshow_popoverto bring the running instance's popover forward instead of spawning a duplicate process.Changes
windows/src-tauri/src/lib.rs: guardExitRequestedoncode.is_none(); registertauri_plugin_single_instance::initas the first plugin, focusing the popover on relaunch.windows/src-tauri/Cargo.toml: addtauri-plugin-single-instance = "2"(resolves to 2.4.4 against the pinned tauri 2.10.3).windows/src-tauri/Cargo.lock: minimal lockfile addition for the new dependency (17 lines).Test plan
cargo checkpasses on macOS host (compiles the non-Linux tray code path)