fix: arm held Command on activation and animate number overlays

This commit is contained in:
2026-10-13 22:31:32 +02:00
parent 77f62b8d41
commit 006c7e7dd0
5 changed files with 268 additions and 77 deletions
@@ -3,13 +3,20 @@ import Foundation
/// Monotonic timestamps are supplied by the window; tests never wait on a real clock.
public struct CommandNumberShortcuts: Sendable {
private var heldSince: TimeInterval?
private var cancelledUntilRelease = false
public private(set) var isVisible = false
public var isHolding: Bool { heldSince != nil }
public init() {}
/// Returns true only when a fresh, eligible Command-only hold begins.
/// Samples an existing hold too, including when results first become eligible.
public mutating func update(commandOnly: Bool, eligible: Bool, at time: TimeInterval) -> Bool {
guard commandOnly && eligible else { reset(); return false }
guard commandOnly else { reset(); return false }
guard eligible && !cancelledUntilRelease else {
heldSince = nil
isVisible = false
return false
}
guard heldSince == nil else { return false }
heldSince = time
return true
@@ -27,8 +34,15 @@ public struct CommandNumberShortcuts: Sendable {
return Int(digit - 49)
}
/// An action cancels this hold; modifier sampling must not restart it.
public mutating func cancel() {
reset()
cancelledUntilRelease = true
}
public mutating func reset() {
heldSince = nil
isVisible = false
cancelledUntilRelease = false
}
}