From 06c6f4eb8ca0c49086968c4bb693121d3b658b84 Mon Sep 17 00:00:00 2001 From: dtoro Date: Tue, 14 Jul 2026 00:34:01 +0200 Subject: [PATCH] Fix window close: use RegisterHook to hide instead of destroy RegisterHook + e.Cancel() prevents Wails from destroying the WebView when the window is closed. The app now hides to the system tray. Left- click on the tray icon correctly restores the window. --- cmd/desktop/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/desktop/main.go b/cmd/desktop/main.go index 45aee89..0353539 100644 --- a/cmd/desktop/main.go +++ b/cmd/desktop/main.go @@ -23,6 +23,7 @@ import ( "time" "github.com/wailsapp/wails/v3/pkg/application" + "github.com/wailsapp/wails/v3/pkg/events" "github.com/zalando/go-keyring" ) @@ -760,6 +761,12 @@ func main() { } else { window.Center() } + + window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) { + window.Hide() + e.Cancel() + }) + window.Show() systemTray.AttachWindow(window)