Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

fix: window app crash on startup when update is pending (#14451)

Eva Hd69ddc1edc4c
diff --git a/app/cmd/app/app.go b/app/cmd/app/app.go
index 724c81619..e83fe47c9 100644
--- a/app/cmd/app/app.go
+++ b/app/cmd/app/app.go
@@ -296,8 +296,15 @@ func main() {
// Check for pending updates on startup (show tray notification if update is ready)
if updater.IsUpdatePending() {
- slog.Debug("update pending on startup, showing tray notification")
- UpdateAvailable("")
+ // On Windows, the tray is initialized in osRun(). Calling UpdateAvailable
+ // before that would dereference a nil tray callback.
+ // TODO: refactor so the update check runs after platform init on all platforms.
+ if runtime.GOOS == "windows" {
+ slog.Debug("update pending on startup, deferring tray notification until tray initialization")
+ } else {
+ slog.Debug("update pending on startup, showing tray notification")
+ UpdateAvailable("")
+ }
}
hasCompletedFirstRun, err := st.HasCompletedFirstRun()
diff --git a/app/cmd/app/app_windows.go b/app/cmd/app/app_windows.go
index 9caeb178a..3e2196dd7 100644
--- a/app/cmd/app/app_windows.go
+++ b/app/cmd/app/app_windows.go
@@ -154,6 +154,10 @@ func handleURLSchemeRequest(urlScheme string) {
}
func UpdateAvailable(ver string) error {
+ if app.t == nil {
+ slog.Debug("tray not yet initialized, skipping update notification")
+ return nil
+ }
return app.t.UpdateAvailable(ver)
}
@@ -165,6 +169,14 @@ func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) {
log.Fatalf("Failed to start: %s", err)
}
+ // Check for pending updates now that the tray is initialized.
+ // The platform-independent check in app.go fires before osRun,
+ // when app.t is still nil, so we must re-check here.
+ if updater.IsUpdatePending() {
+ slog.Debug("update pending on startup, showing tray notification")
+ UpdateAvailable("")
+ }
+
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)