Fix macOS keyboard actions targeting the wrong app (#3960)

* fix: guard macos synthetic input focus

* Tighten macOS keyboard focus safety

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Trevin Chow
2026-06-03 19:00:34 -04:00
committed by GitHub
co-authored by Orca Jinwoo-H
parent 885f3c3b25
commit 09872bfe7b
5 changed files with 166 additions and 6 deletions
@@ -0,0 +1,13 @@
public enum KeyboardInputSafety {
public enum FocusFailure: Equatable {
case targetNotFocused
case targetNotFocusedAfterRestore
}
public static func syntheticInputFocusFailure(targetWindowFocused: Bool, restoreWindowRequested: Bool) -> FocusFailure? {
guard !targetWindowFocused else {
return nil
}
return restoreWindowRequested ? .targetNotFocusedAfterRestore : .targetNotFocused
}
}