Skip to content

fix(gui): one tray Exit question at a time during a run - #85

Open
Rovey wants to merge 1 commit into
mainfrom
fix/one-exit-question
Open

Rovey wants to merge 1 commit into
mainfrom
fix/one-exit-question

Conversation

@Rovey

@Rovey Rovey commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Part of #82: the first fix, only one Exit question at a time. The other items of #82 (Quiet across the restart as administrator, the "Stopping…" state, a real Windows sign-in after the update) are not touched, so this PR does not close the issue.

The problem

During an optimize run, the tray's Exit asks "An optimize run is in progress. Stop it and exit?". That question is a modal MessageBoxW, and a modal message box keeps messages flowing. A click on the tray icon therefore still reached tray_menu, the menu opened again, and choosing Exit there opened a second question on top of the first. The app exited only once both were answered (seen in check 108, D).

The change

One file, src/app/gui/main_gui.cpp (+18/−6):

  • App gets bool exit_question, true while that question is open.
  • case kMenuExit: sets it before MessageBoxW and clears it right after. What the question says, and what Yes and No do, are unchanged.
  • tray_menu returns at the start while exit_question is set. It brings the open question forward with SetForegroundWindow(GetLastActivePopup(g.hwnd)) instead of building a menu, so a second question cannot be asked.

Of the options in #82 (Exit disabled, ignored, or the existing question brought forward) this takes the last: a click on the tray icon still does something visible.

Tests

  • Build: cmake --workflow --preset ci (Release, /W4 /WX), with no warnings.
  • core_tests: 501 test cases, 11735 assertions, all passed.
  • app_tests: passed.
  • No automated test was added. The behaviour lives entirely in the Win32 tray and message-box handling of main_gui.cpp, and the test executables have no seam there without UI automation.

Manual validation still needed

This has not been checked by hand with a real Windows tray. Steps:

  1. Start an optimize run (a short one is enough; it only has to be running).
  2. Right-click the tray icon and choose Exit. The question appears.
  3. While it is open, right-click the tray icon again. Expected: the same question comes to the front and no menu opens.
  4. Answer No: the run goes on, and a right-click opens the menu again as before.
  5. Repeat steps 2–3 and answer Yes: the run stops, the card goes back to stock or to the saved tune, and the app exits after that single answer.

🤖 Generated with Claude Code

The question "An optimize run is in progress. Stop it and exit?" is a
modal MessageBox, which keeps messages flowing: the tray menu still
opened, and its Exit asked a second question on top of the first. The app
then exited only once both were answered (#82, seen in check 108 D).

While the question is open, a click on the tray icon now brings it
forward instead of opening the menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant