Skip to content

Don't open the running VMs question twice - #148

Merged
A21-devs merged 4 commits into
mainfrom
fix/quit-question-once
Dec 4, 2026
Merged

A21-devs merged 4 commits into
mainfrom
fix/quit-question-once

Conversation

@A21-devs

@A21-devs A21-devs commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Closes #144

The tray's Quit could open a second copy of the "VMs are still running" question on top of the one already up. Answering both ran shutDownAllAndQuit twice, so every guest got the power button twice and two Force off questions could appear.

What changed:

  • askingAboutVms flag around the question, the same shape as askingAboutWork from Ask before quitting while a profile save or disk work runs #139. askAndQuit returns early while it is set, requestQuit doesn't start a new flow, and the window's close handler leaves the question up instead of hiding to the tray.
  • Quit from the tray while a question is open now calls showWindow() instead of doing nothing, so the click points at the question waiting for an answer (it was a silent no-op before, and worse if the window was minimized).

Testing

  • npm run typecheck, npm test (153 pass), npm run build
  • npm run smoke (hidden Electron run): SMOKE OK
  • No test covers this path yet; index.ts can't be loaded without Electron. Tests for the close and quit flow #147 tracks pulling the decision logic out so it can be.

The tray's Quit opened a second copy of the "VMs are still running"
question on top of the one already up, and answering both ran
shutDownAllAndQuit twice: two balloons, two power button presses per
guest and two Force off questions. The still working question from #139
already had a flag for this; give the running VMs question the same one,
and leave it up when the window is closed while it is open.
With the guard in place, Quit from the tray did nothing at all while a
question was open, and if the window had been minimized the question was
out of sight. Show the window instead so the click points at the
question that is waiting for an answer.
@A21-devs A21-devs added bug Something isn't working ui labels Dec 4, 2026

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag itself matches askingAboutWork and does fix the double question. Two things around it that I think are real, both about the window close handler rather than the new flag:

Comment thread src/main/index.ts
@@ -81,8 +83,8 @@ function createWindow(): void {
if (quitting || !backend) return
if (backend.runner.runningNames().length === 0 && !hasWork()) return

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return runs before the new question checks below, so it decides on state that can have changed while the question was up. If the last guest powers itself off while "VMs are still running" is open (the question is asked about VMs that are running, and a guest shutting down from its own menu is normal), runningNames() is empty and hasWork() is false, so the X closes the window with the message box still attached to it, and window-all-closed quits the app. Moving the askingAboutWork || askingAboutVms check above this line keeps the window alive until the question is answered, which is what the rest of the handler now assumes.

Comment thread src/main/index.ts Outdated
// the still working question is up on this window, it gets answered there
if (askingAboutWork) return
// a question is already up on this window, it gets answered there
if (askingAboutWork || askingAboutVms) return

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Force off question in shutDownAllAndQuit (line 394) isn't covered by either flag. While it's open shuttingDown is true, so the X falls through to win.hide() two lines down and hides the window the question is attached to; the answer is then needed before the app does anything else, with nothing on screen to answer. Setting askingAboutVms around that dialog too would give it the same "leave it up" treatment this PR gives the other one.

@A21-devs

A21-devs commented Dec 4, 2026

Copy link
Copy Markdown
Owner Author

Both findings were real, fixed in 6d14b6d:

  • the askingAboutWork || askingAboutVms check now runs before the runningNames().length === 0 && !hasWork() early return, and calls preventDefault() itself, so the window survives until the question is answered no matter what the VMs did meanwhile.
  • the Force off question in shutDownAllAndQuit sets askingAboutVms for as long as it is up, so the close handler leaves it alone instead of falling through to win.hide().

Checked again after the fix: npm run typecheck, npm test, npm run build, npm run smoke (SMOKE OK).

One unrelated thing from the test runs: tests/portCheck.test.ts > isPortFree > checks tcp and udp separately failed once out of about 15 full runs here, and passed 12 times in a row on its own. Nothing to do with this change, filed separately.

Two gaps from reviewing this change:

- the close handler decided on runningNames() and hasWork() before it
  looked at the open question, so a guest powering itself off while the
  question was up let the X close the window with the message box on it,
  and window-all-closed then quit the app
- the Force off question at the end of shutDownAllAndQuit had no flag of
  its own, so closing the window hid the window it was attached to

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass over 6d14b6d. Both findings are really fixed: the close handler now checks the open question first and calls preventDefault() on that path, so the "all guests gone" early return can no longer close the window under a message box, and the Force off question sets the flag for as long as it is up, so the handler leaves it alone instead of hiding its window. One nit about what the flag now means.

Comment thread src/main/index.ts
// the still working question is open. Quit and close don't open a second one meanwhile
let askingAboutWork = false
// the running VMs question is open. Same rule: no second copy from the tray or the window
let askingAboutVms = false

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the flag now covers two questions, this one and the Force off question in shutDownAllAndQuit, so the comment reads a bit narrow. The second one also behaves slightly differently from what requestQuit promises: shuttingDown is true by then, so Quit from the tray returns on the line above instead of showing the window with the question on it. Not worth another flag, but the comment could say the flag means "a question about running VMs is open".

@A21-devs

A21-devs commented Dec 4, 2026

Copy link
Copy Markdown
Owner Author

Took the nit: the flag's comment now says it covers both questions about running VMs. No behaviour change, typecheck still clean.

@A21-devs
A21-devs merged commit c656474 into main Dec 4, 2026
1 check passed
@A21-devs
A21-devs deleted the fix/quit-question-once branch December 4, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tray Quit opens the running VMs question twice

1 participant