fix(mac): keep overlay on token mismatch
parent
b73a7e07d2
commit
2116f19106
|
|
@ -262,7 +262,7 @@ final class VoiceWakeOverlayController: ObservableObject {
|
||||||
switch Self.evaluateToken(active: self.activeToken, incoming: token) {
|
switch Self.evaluateToken(active: self.activeToken, incoming: token) {
|
||||||
case .accept:
|
case .accept:
|
||||||
return true
|
return true
|
||||||
case .dismiss:
|
case .dropMismatch:
|
||||||
self.logger.log(
|
self.logger.log(
|
||||||
level: .info,
|
level: .info,
|
||||||
"""
|
"""
|
||||||
|
|
@ -270,19 +270,18 @@ final class VoiceWakeOverlayController: ObservableObject {
|
||||||
active=\(self.activeToken?.uuidString ?? "nil", privacy: .public) \
|
active=\(self.activeToken?.uuidString ?? "nil", privacy: .public) \
|
||||||
got=\(token?.uuidString ?? "nil", privacy: .public)
|
got=\(token?.uuidString ?? "nil", privacy: .public)
|
||||||
""")
|
""")
|
||||||
self.dismiss(reason: .explicit, outcome: .empty)
|
|
||||||
return false
|
return false
|
||||||
case .drop:
|
case .dropNoActive:
|
||||||
self.logger.log(level: .info, "overlay drop \(context, privacy: .public) no_active")
|
self.logger.log(level: .info, "overlay drop \(context, privacy: .public) no_active")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GuardOutcome { case accept, dismiss, drop }
|
enum GuardOutcome { case accept, dropMismatch, dropNoActive }
|
||||||
|
|
||||||
nonisolated static func evaluateToken(active: UUID?, incoming: UUID?) -> GuardOutcome {
|
nonisolated static func evaluateToken(active: UUID?, incoming: UUID?) -> GuardOutcome {
|
||||||
guard let active else { return .drop }
|
guard let active else { return .dropNoActive }
|
||||||
if let incoming, incoming != active { return .dismiss }
|
if let incoming, incoming != active { return .dropMismatch }
|
||||||
return .accept
|
return .accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import Testing
|
||||||
@Suite struct VoiceWakeOverlayTests {
|
@Suite struct VoiceWakeOverlayTests {
|
||||||
@Test func guardTokenDropsWhenNoActive() {
|
@Test func guardTokenDropsWhenNoActive() {
|
||||||
let outcome = VoiceWakeOverlayController.evaluateToken(active: nil, incoming: UUID())
|
let outcome = VoiceWakeOverlayController.evaluateToken(active: nil, incoming: UUID())
|
||||||
#expect(outcome == .drop)
|
#expect(outcome == .dropNoActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func guardTokenAcceptsMatching() {
|
@Test func guardTokenAcceptsMatching() {
|
||||||
|
|
@ -14,8 +14,8 @@ import Testing
|
||||||
#expect(outcome == .accept)
|
#expect(outcome == .accept)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func guardTokenDismissesMismatch() {
|
@Test func guardTokenDropsMismatchWithoutDismissing() {
|
||||||
let outcome = VoiceWakeOverlayController.evaluateToken(active: UUID(), incoming: UUID())
|
let outcome = VoiceWakeOverlayController.evaluateToken(active: UUID(), incoming: UUID())
|
||||||
#expect(outcome == .dismiss)
|
#expect(outcome == .dropMismatch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue