4 Commits

Author SHA1 Message Date
08db74f397 chore: release 26.1.9 2026-04-19 23:04:09 +02:00
9be8d41c94 fix: reduce idle interval indicator work 2026-04-19 23:02:51 +02:00
d978c51fbd chore: release 26.1.8 2026-04-19 22:50:18 +02:00
b8f80932ed fix: serialize ping state updates 2026-04-19 22:48:41 +02:00
7 changed files with 109 additions and 50 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## 26.1.9
- Reduced idle CPU usage and energy impact by changing the interval indicator from a permanent 60 FPS timer to a 1-second update cadence.
- Reset the interval indicator cleanly when the refresh interval changes or when the indicator is hidden.
## 26.1.8
- Fixed a crash in `PingService` caused by concurrent mutation of shared ping state from multiple async ping tasks.
- Moved ping state tracking and reboot suppression windows into an actor so ping success/failure handling is serialized safely.
## 26.1.7
- Added remote reboot support for hosts running KeyHelp API 2.14 or newer.
- Added a dedicated `APIv2_14` client and mapped 2.14+ hosts to it instead of treating them as API 2.13.

View File

@@ -2,18 +2,15 @@ import Foundation
import UserNotifications
enum PingService {
private static var previousPingStates: [String: Bool] = [:]
private static var suppressedUntil: [String: Date] = [:]
private static let stateStore = PingStateStore()
static func suppressChecks(for hostname: String, duration: TimeInterval) {
suppressedUntil[hostname] = Date().addingTimeInterval(duration)
static func suppressChecks(for hostname: String, duration: TimeInterval) async {
await stateStore.suppressChecks(for: hostname, duration: duration)
}
static func ping(hostname: String, apiKey: String, notificationsEnabled: Bool = true) async -> Bool {
if let suppressedUntil = suppressedUntil[hostname], suppressedUntil > Date() {
if await stateStore.shouldSkipPing(for: hostname) {
return false
} else {
suppressedUntil.removeValue(forKey: hostname)
}
guard let url = URL(string: "https://\(hostname)/api/v2/ping") else {
@@ -29,38 +26,32 @@ enum PingService {
do {
let (data, response) = try await URLSession.shared.data(for: request)
if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode != 200 {
handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
await handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
return false
}
if let result = try? JSONDecoder().decode([String: String].self, from: data), result["response"] == "pong" {
handlePingSuccess(for: hostname, notificationsEnabled: notificationsEnabled)
await handlePingSuccess(for: hostname, notificationsEnabled: notificationsEnabled)
return true
} else {
handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
await handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
return false
}
} catch {
handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
await handlePingFailure(for: hostname, notificationsEnabled: notificationsEnabled)
return false
}
}
private static func handlePingSuccess(for hostname: String, notificationsEnabled: Bool) {
let wasPreviouslyDown = previousPingStates[hostname] == false
previousPingStates[hostname] = true
if wasPreviouslyDown && notificationsEnabled {
sendNotification(title: "Server Online", body: "\(hostname) is now online")
private static func handlePingSuccess(for hostname: String, notificationsEnabled: Bool) async {
if let notification = await stateStore.recordSuccess(for: hostname, notificationsEnabled: notificationsEnabled) {
sendNotification(title: notification.title, body: notification.body)
}
}
private static func handlePingFailure(for hostname: String, notificationsEnabled: Bool) {
let wasPreviouslyUp = previousPingStates[hostname] != false
previousPingStates[hostname] = false
if wasPreviouslyUp && notificationsEnabled {
sendNotification(title: "Server Offline", body: "\(hostname) is offline")
private static func handlePingFailure(for hostname: String, notificationsEnabled: Bool) async {
if let notification = await stateStore.recordFailure(for: hostname, notificationsEnabled: notificationsEnabled) {
sendNotification(title: notification.title, body: notification.body)
}
}
@@ -74,3 +65,55 @@ enum PingService {
UNUserNotificationCenter.current().add(request)
}
}
private actor PingStateStore {
private var previousPingStates: [String: Bool] = [:]
private var suppressedUntil: [String: Date] = [:]
func suppressChecks(for hostname: String, duration: TimeInterval) {
suppressedUntil[hostname] = Date().addingTimeInterval(duration)
previousPingStates[hostname] = false
}
func shouldSkipPing(for hostname: String) -> Bool {
if let suppressedUntil = suppressedUntil[hostname], suppressedUntil > Date() {
return true
}
suppressedUntil.removeValue(forKey: hostname)
return false
}
func recordSuccess(for hostname: String, notificationsEnabled: Bool) -> PingNotification? {
let wasPreviouslyDown = previousPingStates[hostname] == false
previousPingStates[hostname] = true
guard wasPreviouslyDown, notificationsEnabled else {
return nil
}
return PingNotification(
title: "Server Online",
body: "\(hostname) is now online"
)
}
func recordFailure(for hostname: String, notificationsEnabled: Bool) -> PingNotification? {
let wasPreviouslyUp = previousPingStates[hostname] != false
previousPingStates[hostname] = false
guard wasPreviouslyUp, notificationsEnabled else {
return nil
}
return PingNotification(
title: "Server Offline",
body: "\(hostname) is offline"
)
}
}
private struct PingNotification {
let title: String
let body: String
}

View File

@@ -381,14 +381,14 @@ struct MainView: View {
api = try await APIFactory.detectAndCreateAPI(baseURL: baseURL, apiKey: apiKey)
}
try await api.restartServer(apiKey: apiKey)
PingService.suppressChecks(for: server.hostname, duration: 90)
await PingService.suppressChecks(for: server.hostname, duration: 90)
return ServerActionFeedback(
title: "Reboot Requested",
message: "The reboot command was sent to \(server.hostname). The host may become unavailable briefly while it restarts."
)
} catch let error as URLError where Self.isExpectedRestartDisconnect(error) {
PingService.suppressChecks(for: server.hostname, duration: 90)
await PingService.suppressChecks(for: server.hostname, duration: 90)
return ServerActionFeedback(
title: "Reboot Requested",
message: "The reboot command appears to have been accepted by \(server.hostname). The connection dropped while the host was going away, which is expected during a reboot."

View File

@@ -29,7 +29,7 @@ struct ServerDetailView: View {
@State private var progress: Double = 0
@State private var showRestartSheet = false
@State private var restartFeedback: ServerActionFeedback?
let timer = Timer.publish(every: 1.0 / 60.0, on: .main, in: .common).autoconnect()
private let indicatorTimer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View {
VStack(spacing: 0) {
@@ -85,13 +85,21 @@ struct ServerDetailView: View {
.padding()
}
}
.onReceive(timer) { _ in
.onReceive(indicatorTimer) { _ in
guard showIntervalIndicator else { return }
withAnimation(.linear(duration: 1.0 / 60.0)) {
progress += 1.0 / (Double(refreshInterval) * 60.0)
withAnimation(.linear(duration: 1)) {
progress += 1.0 / Double(refreshInterval)
if progress >= 1 { progress = 0 }
}
}
.onChange(of: refreshInterval) { _, _ in
progress = 0
}
.onChange(of: showIntervalIndicator) { _, isVisible in
if !isVisible {
progress = 0
}
}
.sheet(isPresented: $showRestartSheet) {
RestartConfirmationSheet(
hostname: server.hostname,

32
Sparkle/appcast.xml vendored
View File

@@ -2,6 +2,22 @@
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
<channel>
<title>iKeyMon</title>
<item>
<title>26.1.9</title>
<pubDate>Sun, 19 Apr 2026 23:04:07 +0200</pubDate>
<sparkle:version>181</sparkle:version>
<sparkle:shortVersionString>26.1.9</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.2</sparkle:minimumSystemVersion>
<enclosure url="https://git.24unix.net/tracer/iKeyMon/releases/download/v26.1.9/iKeyMon-26.1.9.zip" length="3109488" type="application/octet-stream" sparkle:edSignature="ZV96uUMdYC/X90H3G10FMzmZHKUEWpe1geSe/5IBJ7EOCUmx7Mz352i6VMWumFnCtDD4jHo173W9eySUX9KvDA=="/>
</item>
<item>
<title>26.1.8</title>
<pubDate>Sun, 19 Apr 2026 22:50:15 +0200</pubDate>
<sparkle:version>179</sparkle:version>
<sparkle:shortVersionString>26.1.8</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.2</sparkle:minimumSystemVersion>
<enclosure url="https://git.24unix.net/tracer/iKeyMon/releases/download/v26.1.8/iKeyMon-26.1.8.zip" length="3108005" type="application/octet-stream" sparkle:edSignature="OyoweSuRk5kusKUlqKQudZjrHkw5UPrLkix+ccpKphO1en2XdtQZa61hnA6HwcHM302jb+YlvN8n9f2Zkr9GBg=="/>
</item>
<item>
<title>26.1.7</title>
<pubDate>Sun, 19 Apr 2026 16:54:42 +0200</pubDate>
@@ -10,21 +26,5 @@
<sparkle:minimumSystemVersion>15.2</sparkle:minimumSystemVersion>
<enclosure url="https://git.24unix.net/tracer/iKeyMon/releases/download/v26.1.7/iKeyMon-26.1.7.zip" length="3106520" type="application/octet-stream" sparkle:edSignature="xuNlxCsTtVgroriFU7fphcfHxAEC8cpd6tHnHMXknJ2jvKm27ShQMqjSW2jdqNAz0a0kNtPM8HwTL+e6nvUyCQ=="/>
</item>
<item>
<title>26.1.6</title>
<pubDate>Sun, 19 Apr 2026 15:26:19 +0200</pubDate>
<sparkle:version>175</sparkle:version>
<sparkle:shortVersionString>26.1.6</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.2</sparkle:minimumSystemVersion>
<enclosure url="https://git.24unix.net/tracer/iKeyMon/releases/download/v26.1.6/iKeyMon-26.1.6.zip" length="3063130" type="application/octet-stream" sparkle:edSignature="QPy3zm31ZTXE9grlj7Ul6kEG2t0veODEBjJ/qADM8A88lLJ8V9L4WhNnD8wmM7Urh1O6eZKl1qrCLTk0oo3WBA=="/>
</item>
<item>
<title>26.1.5</title>
<pubDate>Sun, 19 Apr 2026 12:09:33 +0200</pubDate>
<sparkle:version>173</sparkle:version>
<sparkle:shortVersionString>26.1.5</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>15.2</sparkle:minimumSystemVersion>
<enclosure url="https://git.24unix.net/tracer/iKeyMon/releases/download/v26.1.5/iKeyMon-26.1.5.zip" length="3065231" type="application/octet-stream" sparkle:edSignature="HVV7iZ4eyJC1VMh2q4GUoAESZnk4HoFU00QlA9qM4X4dJAT5oBEVB55m4wuF4u9iVFAeohkB0vleLlV39mxrBA=="/>
</item>
</channel>
</rss>

View File

@@ -322,7 +322,7 @@
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 177;
CURRENT_PROJECT_VERSION = 181;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
DEVELOPMENT_TEAM = Q5486ZVAFT;
ENABLE_HARDENED_RUNTIME = YES;
@@ -337,7 +337,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 26.1.7;
MARKETING_VERSION = 26.1.9;
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -353,7 +353,7 @@
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 177;
CURRENT_PROJECT_VERSION = 181;
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
DEVELOPMENT_TEAM = Q5486ZVAFT;
ENABLE_HARDENED_RUNTIME = YES;
@@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 26.1.7;
MARKETING_VERSION = 26.1.9;
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;

View File

@@ -1,3 +1,3 @@
{
"marketing_version": "26.1.7"
"marketing_version": "26.1.9"
}