forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProactiveAssistantsPlugin+ScreenCaptureHealth.swift
More file actions
63 lines (59 loc) · 1.89 KB
/
Copy pathProactiveAssistantsPlugin+ScreenCaptureHealth.swift
File metadata and controls
63 lines (59 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Foundation
extension ProactiveAssistantsPlugin {
func setScreenCaptureHealth(_ health: ScreenCaptureHealth) {
guard health != screenCaptureHealth else { return }
let previous = screenCaptureHealth
updateScreenCaptureHealthState(health)
switch (previous, health) {
case (.active, .temporarilyUnavailable):
DesktopDiagnosticsManager.shared.recordFallback(
area: "screen_capture",
from: "screen_capture",
to: "capture_paused",
reason: "capability_mismatch",
outcome: .degraded,
extra: [
"failure_class": "screen_capture_target_unavailable",
"recovery_action": "wait_for_captureable_target",
"recovery_result": "degraded",
]
)
case (.active, .recovering), (.temporarilyUnavailable, .recovering):
DesktopDiagnosticsManager.shared.recordFallback(
area: "screen_capture",
from: "screen_capture",
to: "recovery_poll",
reason: "other",
outcome: .degraded,
extra: [
"failure_class": "screen_capture_engine_failure",
"recovery_action": "retry_capture",
"recovery_result": "degraded",
]
)
case (.temporarilyUnavailable, .active), (.recovering, .active):
DesktopDiagnosticsManager.shared.recordFallback(
area: "screen_capture",
from: "capture_paused",
to: "screen_capture",
reason: "capability_mismatch",
outcome: .recovered,
extra: [
"failure_class": "screen_capture_recovered",
"recovery_action": "resume_capture",
"recovery_result": "recovered",
]
)
default:
break
}
NotificationCenter.default.post(
name: .assistantMonitoringStateDidChange,
object: nil,
userInfo: [
"isMonitoring": isMonitoring,
"screenCaptureHealth": health.rawValue,
]
)
}
}