mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
* fix(computer-use): observe minimized, hidden and other-Space windows on macOS without a restore macOS only enumerated on-screen windows and dropped minimized AX windows, so an app whose window was minimized, hidden or on another Space (any full-screen app) could not be observed, and agents fell back to --restore-window, which activated every window of the app and switched the user's Space. Enumerate every window, keep the off-screen ones accessibility can still read (other-Space windows by remote token, closed windows dropped by their Space membership), and report their real minimized and off-screen state. Background pointer and key input on such a window refuses before sending anything. --restore-window now raises only the target window, once per request, and delivery is measured from whether the target became frontmost. * fix(computer-use): pin the restored window and prefer visible windows by default * fix(computer-use): keep window-index cache keys and stale-element checks across a restore * fix(computer-use): restore only this app's resolved window and refuse a closed target before raising * docs(computer-use): say macOS reads minimized, hidden and other-Space windows
26 lines
1.6 KiB
Swift
26 lines
1.6 KiB
Swift
import CoreGraphics
|
|
import XCTest
|
|
@testable import OrcaComputerUseMacOSCore
|
|
|
|
final class ForegroundDeliveryTests: XCTestCase {
|
|
private func observation(_ frontmost: Bool, _ focusedWindowID: CGWindowID? = nil) -> ForegroundDelivery.Observation {
|
|
ForegroundDelivery.Observation(frontmost: frontmost, focusedWindowID: focusedWindowID)
|
|
}
|
|
|
|
func testBackgroundActionThatActivatesTheAppReportsForeground() {
|
|
XCTAssertTrue(ForegroundDelivery.tookForeground(before: observation(false), after: observation(true, 7), targetWindowID: 7, restoreRequested: false))
|
|
XCTAssertFalse(ForegroundDelivery.tookForeground(before: observation(false), after: observation(false), targetWindowID: 7, restoreRequested: false))
|
|
}
|
|
|
|
func testActiveAppCountsOnlyWhenTheTargetWindowBecameKey() {
|
|
XCTAssertTrue(ForegroundDelivery.tookForeground(before: observation(true, 3), after: observation(true, 7), targetWindowID: 7, restoreRequested: false))
|
|
XCTAssertFalse(ForegroundDelivery.tookForeground(before: observation(true, 7), after: observation(true, 7), targetWindowID: 7, restoreRequested: false))
|
|
XCTAssertFalse(ForegroundDelivery.tookForeground(before: observation(true, 3), after: observation(true, 3), targetWindowID: 7, restoreRequested: false))
|
|
}
|
|
|
|
func testRestoreReportsWhatHappenedNotWhatWasAsked() {
|
|
XCTAssertTrue(ForegroundDelivery.tookForeground(before: observation(true, 7), after: observation(true, 7), targetWindowID: 7, restoreRequested: true))
|
|
XCTAssertFalse(ForegroundDelivery.tookForeground(before: observation(false), after: observation(false), targetWindowID: 7, restoreRequested: true))
|
|
}
|
|
}
|