diff --git a/macos/Sources/Features/Update/UpdateDelegate.swift b/macos/Sources/Features/Update/UpdateDelegate.swift index c116432df..c462e180d 100644 --- a/macos/Sources/Features/Update/UpdateDelegate.swift +++ b/macos/Sources/Features/Update/UpdateDelegate.swift @@ -1,4 +1,5 @@ import Sparkle +import Cocoa class UpdaterDelegate: NSObject, SPUUpdaterDelegate { func feedURLString(for updater: SPUUpdater) -> String? { @@ -8,4 +9,12 @@ class UpdaterDelegate: NSObject, SPUUpdaterDelegate { // tip appcast URL since it is all we support. return "https://tip.files.ghostty.dev/appcast.xml" } + + func updaterWillRelaunchApplication(_ updater: SPUUpdater) { + // When the updater is relaunching the application we want to get macOS + // to invalidate and re-encode all of our restorable state so that when + // we relaunch it uses it. + NSApp.invalidateRestorableState() + for window in NSApp.windows { window.invalidateRestorableState() } + } }