feat(ios): machines panel and app icon badge

Settings gains a Machines screen: health, CLI version, capability and
binary skew, rename, and the supervised runner restart the web banner
exposes. Skew derivation lives in HapiProtocol so it is testable
without a hub.

The icon badge counts unread sessions on the active hub, with a
notification-settings toggle that clears it immediately. The Japanese
app-language option is dropped (no shipped catalog).

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-12-05 12:10:17 +08:00
co-authored by HAPI
parent 0d8abb7e2c
commit c7c2a660b8
13 changed files with 813 additions and 8 deletions
@@ -22,6 +22,13 @@ extension APIClient {
)
}
/// `POST /api/machines/:id/restart-runner` — supervised hosts only. The
/// hub asks the running runner to stop; the supervisor brings it back
/// with the newly installed CLI.
public func restartMachineRunner(id: String) async throws -> MachineRestartResponse {
try await request(.post, "/api/machines/\(encodePathComponent(id))/restart-runner")
}
/// `POST /api/machines/:id/spawn`. The response is discriminated on
/// `type`, not HTTP status — a failed spawn is still HTTP 200 with
/// `.error`.
@@ -48,7 +48,6 @@ public enum AppLanguage: String, CaseIterable, Sendable {
case english = "en"
case simplifiedChinese = "zh-Hans"
case russian = "ru"
case japanese = "ja"
/// Unknown/corrupt/absent stored values degrade to ``system``.
public init(storageKey: String?) {
@@ -66,7 +65,6 @@ public enum AppLanguage: String, CaseIterable, Sendable {
case .english: return "English"
case .simplifiedChinese: return "简体中文"
case .russian: return "Русский"
case .japanese: return "日本語"
}
}
}
@@ -113,3 +111,24 @@ public final class LanguagePrefs {
defaults.set(language.storageKey, forKey: Self.languageKey)
}
}
/// App icon badge preference (web `useAppBadgePreference` twin). Defaults to
/// on; the system permission still decides whether the badge is painted.
@MainActor @Observable
public final class AppBadgePrefs {
public static let enabledKey = "settings.appIconBadge"
public private(set) var enabled: Bool
private let defaults: UserDefaults
public init(defaults: UserDefaults = .standard) {
self.defaults = defaults
self.enabled = defaults.object(forKey: Self.enabledKey) as? Bool ?? true
}
public func setEnabled(_ enabled: Bool) {
self.enabled = enabled
defaults.set(enabled, forKey: Self.enabledKey)
}
}