From 2b2967f4ac291676713f8965da8cb4ad701a7414 Mon Sep 17 00:00:00 2001 From: Yvette Carlisle Date: Mon, 11 May 2026 12:21:01 +0800 Subject: [PATCH] {"schema":"decodex/commit/1","summary":"Check Sparkle updates on launch","authority":"manual"} --- .../RsnapNativeHostKit/NativeHostApp.swift | 7 ------- .../NativeHostSoftwareUpdater.swift | 17 +++++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/native/macos-host/Sources/RsnapNativeHostKit/NativeHostApp.swift b/native/macos-host/Sources/RsnapNativeHostKit/NativeHostApp.swift index 5c564dea..b5531a06 100644 --- a/native/macos-host/Sources/RsnapNativeHostKit/NativeHostApp.swift +++ b/native/macos-host/Sources/RsnapNativeHostKit/NativeHostApp.swift @@ -157,7 +157,6 @@ public final class NativeHostApplicationController: NSObject, NSApplicationDeleg refreshStatusMenuState() sessionController.prepareLiveFrameStreamSampler(reason: "launch") scheduleLaunchPermissionOnboardingIfNeeded() - scheduleLaunchUpdateCheckIfEnabled() DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(250)) { [weak self] in self?.sessionController.refreshShareableContentCacheIfPermitted(source: "launch") } @@ -266,12 +265,6 @@ public final class NativeHostApplicationController: NSObject, NSApplicationDeleg } } - private func scheduleLaunchUpdateCheckIfEnabled() { - Task { @MainActor [weak self] in - self?.softwareUpdater.checkForUpdatesInBackgroundOnLaunchIfEnabled() - } - } - @discardableResult private func presentPermissionRecoveryIfNeeded( source: String, diff --git a/native/macos-host/Sources/RsnapNativeHostKit/NativeHostSoftwareUpdater.swift b/native/macos-host/Sources/RsnapNativeHostKit/NativeHostSoftwareUpdater.swift index 98218ca0..d75ed8b2 100644 --- a/native/macos-host/Sources/RsnapNativeHostKit/NativeHostSoftwareUpdater.swift +++ b/native/macos-host/Sources/RsnapNativeHostKit/NativeHostSoftwareUpdater.swift @@ -64,11 +64,13 @@ final class NativeHostSoftwareUpdater { init() { if Self.hasSparkleConfiguration { - updaterController = SPUStandardUpdaterController( + let controller = SPUStandardUpdaterController( startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil) + updaterController = controller NativeHostTelemetry.lifecycleEvent("native_host.sparkle_updater_started") + requestImmediateLaunchUpdateCheckIfEnabled(using: controller.updater) } else { updaterController = nil NativeHostTelemetry.lifecycleWarning( @@ -132,16 +134,19 @@ final class NativeHostSoftwareUpdater { updaterController.checkForUpdates(sender) } - func checkForUpdatesInBackgroundOnLaunchIfEnabled() { - guard let updater = updaterController?.updater else { - return - } + private func requestImmediateLaunchUpdateCheckIfEnabled(using updater: SPUUpdater) { guard updater.automaticallyChecksForUpdates else { NativeHostTelemetry.lifecycleDebug( "native_host.sparkle_update_check_skipped", detail: "source=launch,reason=disabled") return } + guard updater.sessionInProgress == false else { + NativeHostTelemetry.lifecycleDebug( + "native_host.sparkle_update_check_skipped", + detail: "source=launch,reason=session_in_progress") + return + } updater.checkForUpdatesInBackground() NativeHostTelemetry.lifecycleEvent( "native_host.sparkle_update_check_scheduled", @@ -174,7 +179,7 @@ final class NativeHostSoftwareUpdater { guard let checkedAt else { return "Never checked." } - return "Last checked \(checkedAt.formatted(date: .abbreviated, time: .shortened))." + return "Checked \(checkedAt.formatted(date: .omitted, time: .shortened))." } private static func nonEmptyInfoValue(forKey key: String) -> String? {