mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 10:27:33 +00:00
* fix(computer): report a locked screen instead of missing Accessibility Behind the lock screen (display sleep, screen saver or a manual lock) macOS reports Accessibility as untrusted. Orca read that as a missing permission, and its recovery hint led agents to open System Settings. Check the session lock first and return screen_locked; permission setup refuses while locked. * fix(computer): recheck the lock under the provider lock and at setup launch * fix(computer): read the lock fresh for setup and keep locked status reads out of the cache * refactor(computer): drop the extra lock read at setup; the status and setup helper already check it
20 lines
983 B
Swift
20 lines
983 B
Swift
import CoreGraphics
|
|
import Foundation
|
|
|
|
// Why: display sleep, the screen saver and a manual lock all put the session behind the lock screen, where macOS
|
|
// reports Accessibility as untrusted and hides app windows; without this check that reads as a missing permission.
|
|
public enum SessionLockProbe {
|
|
public static let screenIsLockedKey = "CGSSessionScreenIsLocked"
|
|
public static let lockedMessage = "The Mac's screen is locked or asleep, so Orca can't see or control windows. Wake and unlock the Mac, then retry."
|
|
|
|
/// Read fresh on every call: the lock can start or end at any moment.
|
|
public static func isLocked() -> Bool {
|
|
isLocked(session: CGSessionCopyCurrentDictionary() as? [String: Any])
|
|
}
|
|
|
|
/// No session dictionary (no window-server session) or no key is how an unlocked session reports itself.
|
|
public static func isLocked(session: [String: Any]?) -> Bool {
|
|
(session?[screenIsLockedKey] as? NSNumber)?.boolValue ?? false
|
|
}
|
|
}
|