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
@@ -178,6 +178,15 @@ public struct Machine: Codable, Equatable, Sendable {
}
}
/// Body of `POST /api/machines/:id/restart-runner`.
public struct MachineRestartResponse: Codable, Equatable, Sendable {
public var message: String
public init(message: String) {
self.message = message
}
}
/// A flat `machine-updated` patch.
///
/// Mirrors `MachinePatchSchema` (`shared/src/schemas.ts:509-513`), zod
@@ -0,0 +1,40 @@
import Foundation
/// Ports `shared/src/runnerCapabilities.ts` for the native machine screen.
/// The hub hard-depends on these machine RPCs, so a runner missing one is
/// stale even when it still answers the heartbeat.
public enum RunnerSkew {
/// `REQUIRED_MACHINE_CAPABILITIES` values.
public static let requiredMachineCapabilities: [String] = [
"agent-availability",
"cursor-chat-store-status",
]
public static func missingRequiredCapabilities(_ advertised: [String]?) -> [String] {
let set = Set(advertised ?? [])
return requiredMachineCapabilities.filter { !set.contains($0) }
}
public static func isCapabilitySkewed(_ advertised: [String]?) -> Bool {
!missingRequiredCapabilities(advertised).isEmpty
}
/// True when the running process started from a different CLI binary or
/// mtime than the one currently installed on disk
/// (`cliBinaryUpdatedOnDisk` in the shared package).
public static func cliBinaryUpdatedOnDisk(_ metadata: MachineMetadata?) -> Bool {
guard let started = metadata?.startedCliMtimeMs,
let installed = metadata?.installedCliMtimeMs,
started.isFinite,
installed.isFinite else { return false }
return started != installed
}
/// Web banner restart gate: a newer binary is already on disk and the
/// runner is under a supervisor that can bring it back.
public static func canRestartRunner(_ machine: Machine) -> Bool {
machine.active
&& machine.metadata?.supervisedRestart == true
&& cliBinaryUpdatedOnDisk(machine.metadata)
}
}