[client] Exit GUI immediately on Windows session end

Wails v3 runs the full app teardown synchronously inside WM_ENDSESSION,
overrunning the 5s end-session budget and triggering the "app is
preventing shutdown" screen with a forced kill. Intercept
WM_QUERYENDSESSION/WM_ENDSESSION and exit at once instead, and suppress
error dialogs, toasts, and the hide-on-close hooks once shutdown or a
tray quit has begun.
This commit is contained in:
Zoltán Papp
2026-07-24 10:39:12 +02:00
parent 46568f7af8
commit 8d9c8b7799
7 changed files with 76 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package services
import "sync/atomic"
var shuttingDown atomic.Bool
func BeginShutdown() {
shuttingDown.Store(true)
}
func AbortShutdown() {
shuttingDown.Store(false)
}
func ShuttingDown() bool {
return shuttingDown.Load()
}
+6
View File
@@ -154,6 +154,9 @@ func NewWindowManager(app *application.App, mainWindow *application.WebviewWindo
})
// Hide (not destroy) on close to keep React state; reset to General for a flash-free reopen.
s.settings.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
if ShuttingDown() {
return
}
e.Cancel()
s.app.Event.Emit(EventSettingsOpen, "general")
s.settings.Hide()
@@ -393,6 +396,9 @@ func (s *WindowManager) CloseWelcome() {
// OpenError shows the custom error dialog; title/message are pre-localised and ride in the
// start URL. A second error replaces the open one via SetURL. Singleton, destroyed on close.
func (s *WindowManager) OpenError(title, message string) {
if ShuttingDown() {
return
}
s.mu.Lock()
defer s.mu.Unlock()
startURL := errorDialogURL(title, message)