iOS 1.0 RC 1: battery and heat work, version label, web player redraw tweaks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-11-06 08:31:00 -08:00
1 parent 0fc35b13e8
commit c0e33b5e3e
18 files changed
+143 -36

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import Foundation
/// Whether anyone is looking at the app: the phone UI in the foreground, or CarPlay connected.
/// Work that only feeds a screen (stemd polling, a shallow output buffer for snappy faders)
/// checks this, so a locked phone playing music does as little as it can.
enum AppActivity {
private static let lock = UnfairLock()
nonisolated(unsafe) private static var phone = true
nonisolated(unsafe) private static var car = false
nonisolated(unsafe) private static var waiters: [CheckedContinuation<Void, Never>] = []
static var isActive: Bool { lock.with { phone || car } }
static func setPhone(_ on: Bool) { update { phone = on } }
static func setCar(_ on: Bool) { update { car = on } }
private static func update(_ change: () -> Void) {
let ready = lock.with { () -> [CheckedContinuation<Void, Never>] in
change()
guard phone || car else { return [] }
defer { waiters = [] }
return waiters
}
ready.forEach { $0.resume() }
}
/// Returns once the app is active, at once if it already is.
static func untilActive() async {
await withCheckedContinuation { (c: CheckedContinuation<Void, Never>) in
let now = lock.with { () -> Bool in
if phone || car { return true }
waiters.append(c)
return false
}
if now { c.resume() }
}
}
}