agent-device 0.21.30 → 0.21.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.30.apk → agent-device-android-ime-helper-0.21.31.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.31.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.30.manifest.json → agent-device-android-ime-helper-0.21.31.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.31.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.31.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.30.manifest.json → agent-device-android-snapshot-helper-0.21.31.manifest.json} +7 -7
  7. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/BackgroundInteraction.swift +20 -6
  8. package/apple/snapshot-bridge/README.md +16 -3
  9. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +33 -1
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +110 -8
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +20 -0
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +4 -4
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +1 -1
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +30 -4
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +14 -4
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +81 -41
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +40 -6
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +5 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +74 -10
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +33 -4
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +2 -2
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +23 -2
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +158 -6
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +165 -70
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryConfirmation.swift +2 -3
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +49 -27
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +17 -9
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +30 -28
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +87 -87
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +4 -3
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +13 -0
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +45 -0
  33. package/dist/src/absence-observation-errors.js +1 -1
  34. package/dist/src/adapter.js +1 -1
  35. package/dist/src/adb-executor.js +1 -1
  36. package/dist/src/adb-failure.js +2 -2
  37. package/dist/src/agent-browser-lifecycle.js +1 -1
  38. package/dist/src/agent-browser-process-record.js +1 -1
  39. package/dist/src/agent-browser-provider.js +1 -1
  40. package/dist/src/agent-browser-tool.js +1 -1
  41. package/dist/src/agent-device-client.js +1 -1
  42. package/dist/src/alert-tree-driver.js +1 -1
  43. package/dist/src/alert.js +1 -1
  44. package/dist/src/alert2.js +1 -1
  45. package/dist/src/android.js +1 -1
  46. package/dist/src/app-backend.js +1 -1
  47. package/dist/src/app-launch.js +1 -1
  48. package/dist/src/app-lifecycle.js +4 -4
  49. package/dist/src/app-log-runtime2.js +3 -3
  50. package/dist/src/app-log-session-resource.js +1 -1
  51. package/dist/src/app-resolution-facade.js +1 -1
  52. package/dist/src/app-resolution.js +2 -2
  53. package/dist/src/apple-runner-platform.js +1 -1
  54. package/dist/src/application-lifecycle-interaction.js +1 -1
  55. package/dist/src/artifact-tracking.js +1 -1
  56. package/dist/src/automation-helper-artifact.js +1 -1
  57. package/dist/src/automation-helper.js +1 -1
  58. package/dist/src/back-mode.js +1 -1
  59. package/dist/src/boot-diagnostics.js +1 -1
  60. package/dist/src/browser-launch.js +1 -1
  61. package/dist/src/cli-config.js +1 -1
  62. package/dist/src/cli-help.js +35 -29
  63. package/dist/src/cli-runner.js +1 -1
  64. package/dist/src/cli.js +3 -3
  65. package/dist/src/client-metro-companion.js +1 -1
  66. package/dist/src/client-metro.js +1 -1
  67. package/dist/src/client-types.d.ts +3 -3
  68. package/dist/src/cloud-artifacts.d.ts +5 -4
  69. package/dist/src/code-signature-cache.js +1 -1
  70. package/dist/src/command-metadata.js +10 -10
  71. package/dist/src/command-tools.js +2 -2
  72. package/dist/src/command.js +1 -1
  73. package/dist/src/composed-inventory-gateways.js +1 -1
  74. package/dist/src/connection-runtime.js +1 -1
  75. package/dist/src/connection.js +5 -5
  76. package/dist/src/contracts.js +1 -1
  77. package/dist/src/daemon-client-ensure.js +1 -1
  78. package/dist/src/daemon-client-lease-beat.js +1 -1
  79. package/dist/src/daemon-client-lifecycle.js +1 -1
  80. package/dist/src/daemon-client-liveness-probe.js +1 -1
  81. package/dist/src/daemon-client.js +1 -1
  82. package/dist/src/daemon-command-registry.js +1 -1
  83. package/dist/src/daemon-composition.js +1 -1
  84. package/dist/src/daemon-policy-file.js +1 -1
  85. package/dist/src/daemon-registration-owner.js +3 -3
  86. package/dist/src/daemon-resolution.js +1 -1
  87. package/dist/src/daemon-startup-diagnostics.js +1 -1
  88. package/dist/src/debug-symbols-facade.js +3 -3
  89. package/dist/src/device-claim-recovery.js +1 -1
  90. package/dist/src/device-claims.js +1 -1
  91. package/dist/src/device-inventory-context.js +1 -1
  92. package/dist/src/device-readiness-runtime.js +1 -1
  93. package/dist/src/device-selection-resolver.js +1 -1
  94. package/dist/src/device.js +1 -1
  95. package/dist/src/devicectl.js +1 -1
  96. package/dist/src/diagnostics.js +1 -1
  97. package/dist/src/display-inventory.js +1 -1
  98. package/dist/src/doctor-facade.js +1 -1
  99. package/dist/src/durable-capture-resource.js +1 -1
  100. package/dist/src/durable-resource.js +1 -1
  101. package/dist/src/engine-eval-script.js +1 -1
  102. package/dist/src/error.js +1 -1
  103. package/dist/src/explicit-session-resolution.js +1 -1
  104. package/dist/src/expo-dev-client-launch.js +1 -1
  105. package/dist/src/file.js +1 -1
  106. package/dist/src/find.js +1 -1
  107. package/dist/src/finders.js +1 -1
  108. package/dist/src/gesture-admission.js +1 -1
  109. package/dist/src/gesture-plan.js +1 -1
  110. package/dist/src/gesture-runtime.js +1 -1
  111. package/dist/src/hdc.js +1 -1
  112. package/dist/src/helper.js +2 -2
  113. package/dist/src/host.js +1 -1
  114. package/dist/src/host2.js +1 -1
  115. package/dist/src/host3.js +1 -1
  116. package/dist/src/host4.js +1 -1
  117. package/dist/src/host5.js +1 -0
  118. package/dist/src/human-control.js +1 -1
  119. package/dist/src/ime-rebind.js +1 -1
  120. package/dist/src/ime-state.js +1 -1
  121. package/dist/src/index.js +1 -1
  122. package/dist/src/input-actions.js +1 -1
  123. package/dist/src/input-actions2.js +1 -1
  124. package/dist/src/install-source-network-transport.js +1 -1
  125. package/dist/src/install-source2.js +1 -1
  126. package/dist/src/interaction-positionals.js +1 -1
  127. package/dist/src/interaction.js +1 -1
  128. package/dist/src/interaction2.js +1 -1
  129. package/dist/src/interactor-operation-catalog.js +1 -1
  130. package/dist/src/interactor.js +5 -5
  131. package/dist/src/interactor2.js +1 -1
  132. package/dist/src/interactor3.js +1 -1
  133. package/dist/src/interactor4.js +1 -1
  134. package/dist/src/interactor5.js +1 -1
  135. package/dist/src/interactors.js +1 -1
  136. package/dist/src/internal/bin.js +1 -1
  137. package/dist/src/internal/daemon.js +1 -1
  138. package/dist/src/internal/png-worker.js +1 -1
  139. package/dist/src/inventory.js +1 -1
  140. package/dist/src/inventory2.js +1 -1
  141. package/dist/src/inventory6.js +1 -1
  142. package/dist/src/ios-node-interpretation.js +1 -1
  143. package/dist/src/ios-settings.js +1 -1
  144. package/dist/src/ios-snapshot-acquisition.js +1 -1
  145. package/dist/src/ios-snapshot-engine.js +1 -1
  146. package/dist/src/ios-snapshot-runtime.js +1 -1
  147. package/dist/src/keyboard-occlusion.js +1 -1
  148. package/dist/src/keyed-lock.js +1 -1
  149. package/dist/src/launch-confirmation.js +1 -1
  150. package/dist/src/launch-services-registration.js +4 -4
  151. package/dist/src/lease.js +1 -1
  152. package/dist/src/legacy.js +1 -1
  153. package/dist/src/limrun-runtime-dependencies.js +1 -1
  154. package/dist/src/local-interactor-operation-set.js +1 -1
  155. package/dist/src/mechanics.js +12 -12
  156. package/dist/src/mobile-snapshot-semantics.js +1 -1
  157. package/dist/src/observability.js +1 -1
  158. package/dist/src/output-path.js +1 -1
  159. package/dist/src/parameterized-recorded-fill.js +1 -1
  160. package/dist/src/perf-facade.js +1 -1
  161. package/dist/src/perf-runtime-operation-builder.js +1 -1
  162. package/dist/src/perf-target.js +1 -1
  163. package/dist/src/physical-device-control.js +1 -1
  164. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  165. package/dist/src/platform-runtime-claim-recovery.js +1 -1
  166. package/dist/src/platform-runtime-daemon-services.js +1 -1
  167. package/dist/src/platform-runtime-host.js +1 -1
  168. package/dist/src/platform-runtime-open-target.js +1 -1
  169. package/dist/src/platform-runtime-operation-host.js +5 -5
  170. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  171. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  172. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  173. package/dist/src/platform-runtime-unavailable.js +1 -1
  174. package/dist/src/platform-runtime.js +1 -1
  175. package/dist/src/platform-runtime2.js +1 -1
  176. package/dist/src/png-resize.js +1 -1
  177. package/dist/src/png-worker-client.js +1 -1
  178. package/dist/src/process-exit.js +1 -1
  179. package/dist/src/provider-device-runtime.d.ts +28 -0
  180. package/dist/src/provider-plugin-catalog.js +2 -0
  181. package/dist/src/provider-plugin.d.ts +1 -1
  182. package/dist/src/provider-webdriver.js +1 -1
  183. package/dist/src/proxy.js +1 -1
  184. package/dist/src/react-native-overlay2.js +1 -1
  185. package/dist/src/react-native.js +1 -1
  186. package/dist/src/react-profile-command.js +1 -1
  187. package/dist/src/record-runtime.js +1 -1
  188. package/dist/src/record-trace.js +1 -1
  189. package/dist/src/recording-scope.js +1 -1
  190. package/dist/src/recording.js +1 -1
  191. package/dist/src/registry.js +1 -1
  192. package/dist/src/remote-config-core.js +1 -1
  193. package/dist/src/replay-backend-host.js +1 -1
  194. package/dist/src/replay-divergence.js +1 -1
  195. package/dist/src/replay-maestro-backend.js +3 -3
  196. package/dist/src/replay-script-selection.js +1 -1
  197. package/dist/src/replay2.js +1 -1
  198. package/dist/src/request-runtime-binding.js +1 -1
  199. package/dist/src/request.js +1 -1
  200. package/dist/src/result-serialization.js +1 -1
  201. package/dist/src/retry.js +1 -1
  202. package/dist/src/runner-cache-retention.js +1 -1
  203. package/dist/src/runner-client.js +1 -1
  204. package/dist/src/runner-dev-tools-security.js +1 -1
  205. package/dist/src/runner-device-readiness.js +1 -1
  206. package/dist/src/runner-device-set.js +1 -1
  207. package/dist/src/runner-error-classification.js +2 -2
  208. package/dist/src/runner-exchange.js +1 -1
  209. package/dist/src/runner-lease.js +1 -1
  210. package/dist/src/runner-operations-facade.js +1 -1
  211. package/dist/src/runner-retention.js +1 -1
  212. package/dist/src/runner-selector-query.js +1 -1
  213. package/dist/src/runner-start-budget.js +1 -1
  214. package/dist/src/runner-startup-transport.js +1 -1
  215. package/dist/src/runner-toolchain-probe.js +1 -1
  216. package/dist/src/runner.js +2 -2
  217. package/dist/src/runtime-admission.js +1 -1
  218. package/dist/src/runtime-deployment.js +1 -1
  219. package/dist/src/runtime-factory.js +1 -1
  220. package/dist/src/runtime-session.js +1 -1
  221. package/dist/src/runtime.js +4 -4
  222. package/dist/src/runtime10.js +2 -2
  223. package/dist/src/runtime2.js +1 -1
  224. package/dist/src/runtime3.js +5 -5
  225. package/dist/src/runtime4.js +1 -1
  226. package/dist/src/runtime5.js +1 -1
  227. package/dist/src/runtime6.js +1 -1
  228. package/dist/src/runtime7.js +1 -1
  229. package/dist/src/runtime8.js +1 -1
  230. package/dist/src/runtime9.js +2 -2
  231. package/dist/src/screen-recording-transport.js +1 -1
  232. package/dist/src/screenshot-density.js +1 -1
  233. package/dist/src/screenshot-runtime.js +1 -1
  234. package/dist/src/screenshot3.js +1 -1
  235. package/dist/src/sdk-batch-runner.js +2 -2
  236. package/dist/src/sdk-batch.js +2 -2
  237. package/dist/src/sdk-contracts.d.ts +9 -0
  238. package/dist/src/sdk-contracts.js +2 -2
  239. package/dist/src/sdk-device.js +1 -1
  240. package/dist/src/sdk-finders.js +1 -1
  241. package/dist/src/sdk-io.js +5 -5
  242. package/dist/src/sdk-remote-config.js +1 -1
  243. package/dist/src/sdk-selectors.js +1 -1
  244. package/dist/src/selection.js +0 -0
  245. package/dist/src/selector-pipeline-policy.js +1 -1
  246. package/dist/src/selector-runtime.js +1 -1
  247. package/dist/src/selectors.js +1 -1
  248. package/dist/src/server-startup.js +1 -1
  249. package/dist/src/session-paths.js +1 -1
  250. package/dist/src/session-replay-vars.js +1 -1
  251. package/dist/src/session-runtime.js +1 -1
  252. package/dist/src/session-store.js +3 -3
  253. package/dist/src/session.js +1 -1
  254. package/dist/src/session2.js +5 -5
  255. package/dist/src/settings-bluetooth.js +1 -1
  256. package/dist/src/settings.js +1 -1
  257. package/dist/src/settings2.js +1 -1
  258. package/dist/src/settle-observation-capture.js +1 -1
  259. package/dist/src/simctl-settings.js +1 -1
  260. package/dist/src/simctl.js +1 -1
  261. package/dist/src/simulator-boot.js +1 -1
  262. package/dist/src/simulator-state.js +1 -1
  263. package/dist/src/simulator.js +1 -1
  264. package/dist/src/snapshot-chrome.js +1 -1
  265. package/dist/src/snapshot-desktop-projection.js +1 -1
  266. package/dist/src/snapshot-helper-install.js +6 -6
  267. package/dist/src/snapshot-node-lookup.js +1 -1
  268. package/dist/src/snapshot-occlusion.js +1 -1
  269. package/dist/src/snapshot-runtime-binding.js +1 -1
  270. package/dist/src/snapshot-runtime-capture-input.js +1 -1
  271. package/dist/src/snapshot-runtime.js +1 -1
  272. package/dist/src/snapshot-state.js +1 -1
  273. package/dist/src/snapshot.js +1 -1
  274. package/dist/src/snapshot3.js +1 -1
  275. package/dist/src/src.js +1 -1
  276. package/dist/src/src3.js +1 -1
  277. package/dist/src/src4.js +1 -1
  278. package/dist/src/store.js +1 -1
  279. package/dist/src/tap-keyboard-occlusion.js +1 -1
  280. package/dist/src/target-evidence-tree.js +1 -1
  281. package/dist/src/target-evidence.js +1 -1
  282. package/dist/src/telephony-runtime.js +1 -1
  283. package/dist/src/text-entry-focus.js +1 -1
  284. package/dist/src/tool-provider.js +3 -3
  285. package/dist/src/tool-provider2.js +1 -1
  286. package/dist/src/tool-provider3.js +1 -1
  287. package/dist/src/toolchain-probe.js +1 -1
  288. package/dist/src/touch-reference-frame.js +1 -1
  289. package/dist/src/touch-runtime.js +1 -1
  290. package/dist/src/touch-runtime2.js +1 -1
  291. package/dist/src/tree.js +1 -1
  292. package/dist/src/tv-remote-runtime.js +1 -1
  293. package/dist/src/tv-remote.js +2 -2
  294. package/dist/src/type-text-runtime.js +1 -1
  295. package/dist/src/update-check.js +1 -1
  296. package/dist/src/vega-executable.js +1 -1
  297. package/dist/src/video.js +1 -1
  298. package/dist/src/webdriver-source.js +1 -1
  299. package/package.json +7 -6
  300. package/server.json +2 -2
  301. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.30.apk.sha256 +0 -1
  302. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.30.apk +0 -0
  303. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.30.apk.sha256 +0 -1
  304. package/dist/src/physical-device-apps.js +0 -1
@@ -58,18 +58,25 @@ extension RunnerTests {
58
58
  _ = pressTvRemote(.menu)
59
59
  return .performed
60
60
  #else
61
+ let rejectedQueriesBefore = navigationRejectedQueryCount()
61
62
  let buttons = app.navigationBars.buttons.allElementsBoundByIndex
62
63
  if let back = buttons.first(where: { $0.isHittable }) {
64
+
65
+
63
66
  back.tap()
64
67
  return .performed
65
68
  }
66
- if isSnapshotXCTestChannelPenalized(bundleId: mainOwned.bundleId) {
69
+ if navigationRejectedQueryCount() != rejectedQueriesBefore
70
+ || isSnapshotXCTestChannelPenalized(bundleId: mainOwned.bundleId)
71
+ {
67
72
  NSLog("AGENT_DEVICE_RUNNER_IN_APP_BACK_SKIPPED_XCTEST_ENUMERATION bundle=%@", mainOwned.bundleId ?? "")
68
- } else if let back = topNavigationBackElement(app: app) {
69
- tapElementCenter(app: app, element: back)
70
- return .performed
73
+ } else if let frame = topNavigationBackFrame(app: app) {
74
+ return tapResolvedNavigationBackControl(app: app, frame: frame)
71
75
  }
72
- return tapTopLeadingNavigationFallback(app: app)
76
+ return tapTopLeadingNavigationFallback(
77
+ app: app,
78
+ windowQueryRejected: navigationRejectedQueryCount() != rejectedQueriesBefore
79
+ )
73
80
  #endif
74
81
  }
75
82
 
@@ -84,32 +91,48 @@ extension RunnerTests {
84
91
  #endif
85
92
  }
86
93
 
87
- private func topNavigationBackElement(app: XCUIApplication) -> XCUIElement? {
94
+ @MainActor
95
+ private func tapResolvedNavigationBackControl(app: XCUIApplication, frame: CGRect) -> InAppBackOutcome {
96
+ guard SnapshotGeometry.isPositiveFinite(frame) else { return .unavailable }
97
+ let context = synthesizedCoordinateContext(
98
+ app: app,
99
+ policy: synthesizedGesturePolicy(.coordinateTap)
100
+ )
101
+ switch performSynthesizedGesture(app, kind: .coordinateTap, context: context, synthesize: {
102
+ synthesizedTapAt(app: app, x: frame.midX, y: frame.midY, context: context)
103
+ }) {
104
+ case .performed:
105
+ return .performed
106
+ case .refused:
107
+ return .unavailable
108
+ case .xctestFallback:
109
+ let fallback = performGesture(app) {
110
+ tapAt(app: app, x: frame.midX, y: frame.midY)
111
+ }
112
+ if case .performed = fallback.outcome { return .performed }
113
+ return .unavailable
114
+ }
115
+ }
116
+
117
+ private func topNavigationBackFrame(app: XCUIApplication) -> CGRect? {
88
118
  #if os(iOS)
89
- let frame = onScreenWindowFrame(app: app)
119
+ let window = onScreenWindowFrame(app: app)
90
120
  let candidates = app.buttons.matching(Self.navigationBackPredicate()).allElementsBoundByIndex.compactMap {
91
- element -> (XCUIElement, Int)? in
121
+ element -> (frame: CGRect, rank: Int)? in
92
122
  guard element.exists, element.isHittable else { return nil }
93
- guard Self.isTopNavigationBackCandidateFrame(
94
- element.frame,
95
- in: frame,
96
- identifier: element.identifier
97
- ) else { return nil }
98
- guard let rank = Self.navigationBackControlRank(
99
- label: element.label,
100
- identifier: element.identifier
101
- ) else {
102
- return nil
103
- }
104
- return (element, rank)
123
+ let frame = element.frame
124
+ let identifier = element.identifier
125
+ guard Self.isTopNavigationBackCandidateFrame(frame, in: window, identifier: identifier)
126
+ else { return nil }
127
+ guard let rank = Self.navigationBackControlRank(label: element.label, identifier: identifier)
128
+ else { return nil }
129
+ return (frame, rank)
105
130
  }
106
131
  return candidates.sorted { lhs, rhs in
107
- if lhs.1 != rhs.1 { return lhs.1 < rhs.1 }
108
- let leftFrame = lhs.0.frame
109
- let rightFrame = rhs.0.frame
110
- if leftFrame.minY != rightFrame.minY { return leftFrame.minY < rightFrame.minY }
111
- return leftFrame.minX < rightFrame.minX
112
- }.first?.0
132
+ if lhs.rank != rhs.rank { return lhs.rank < rhs.rank }
133
+ if lhs.frame.minY != rhs.frame.minY { return lhs.frame.minY < rhs.frame.minY }
134
+ return lhs.frame.minX < rhs.frame.minX
135
+ }.first?.frame
113
136
  #else
114
137
  return nil
115
138
  #endif
@@ -163,27 +186,30 @@ extension RunnerTests {
163
186
 
164
187
  let xOffset = min(max(frame.width * 0.08, 28), 44)
165
188
 
166
- let yOffset = min(max(frame.height * 0.155, 56), 132)
189
+
190
+ let yOffset = min(max(frame.height * 0.1, 56), 96)
167
191
  return CGPoint(x: frame.minX + xOffset, y: frame.minY + yOffset)
168
192
  }
169
193
 
170
194
  @MainActor
171
- private func tapTopLeadingNavigationFallback(app: XCUIApplication) -> InAppBackOutcome {
195
+ private func tapTopLeadingNavigationFallback(
196
+ app: XCUIApplication,
197
+ windowQueryRejected: Bool
198
+ ) -> InAppBackOutcome {
172
199
  #if os(iOS)
173
- let frame = onScreenWindowFrame(app: app)
174
- guard let point = Self.topLeadingNavigationFallbackPoint(in: frame) else {
200
+ guard let context = synthesizedCoordinateContext(
201
+ app: app,
202
+ policy: synthesizedGesturePolicy(.coordinateTap),
203
+ windowQueryRejected: windowQueryRejected
204
+ ), let point = Self.topLeadingNavigationFallbackPoint(in: context.referenceFrame) else {
175
205
  return .unavailable
176
206
  }
177
- let before = captureNavigationFallbackVisualState(app: app)
178
- let context = synthesizedCoordinateContext(
179
- app: app,
180
- policy: synthesizedGesturePolicy(.coordinateTap)
181
- )?.withReferenceFrame(frame)
207
+ let before = captureNavigationFallbackVisualState(app: app, context: context)
182
208
  switch performSynthesizedGesture(app, kind: .coordinateTap, context: context, synthesize: {
183
209
  synthesizedTapAt(app: app, x: point.x, y: point.y, context: context)
184
210
  }) {
185
211
  case .performed:
186
- return verifyNavigationFallbackOutcome(app: app, before: before)
212
+ return verifyNavigationFallbackOutcome(app: app, before: before, context: context)
187
213
  case .refused:
188
214
  return .unavailable
189
215
  case .xctestFallback:
@@ -191,17 +217,30 @@ extension RunnerTests {
191
217
  tapAt(app: app, x: point.x, y: point.y)
192
218
  }
193
219
  if case .performed = fallback.outcome {
194
- return verifyNavigationFallbackOutcome(app: app, before: before)
220
+ return verifyNavigationFallbackOutcome(app: app, before: before, context: context)
195
221
  }
196
222
  }
197
223
  #endif
198
224
  return .unavailable
199
225
  }
200
226
 
201
- private func captureNavigationFallbackVisualState(app: XCUIApplication) -> NavigationVisualSample {
227
+ private func navigationRejectedQueryCount() -> Int {
228
+ suppressedIssueLock.lock()
229
+ defer { suppressedIssueLock.unlock() }
230
+ return suppressedAxSnapshotIssueCount
231
+ }
232
+
233
+ private func captureNavigationFallbackVisualState(
234
+ app: XCUIApplication,
235
+ context: SynthesizedCoordinateContext
236
+ ) -> NavigationVisualSample {
202
237
  #if os(iOS)
203
238
  return Self.navigationFallbackSample(
204
- resolvingApp: { self.captureResolvedAppScreen(app: app) },
239
+ resolvingApp: {
240
+ context.resolvedWindow == nil
241
+ ? self.captureSoleAppScreen()
242
+ : self.captureResolvedAppScreen(app: app)
243
+ },
205
244
  systemSurface: { self.captureResolvedAppScreen(app: self.springboard) },
206
245
  encoding: { runnerPngData(for: $0.image) }
207
246
  )
@@ -256,10 +295,11 @@ extension RunnerTests {
256
295
 
257
296
  private func verifyNavigationFallbackOutcome(
258
297
  app: XCUIApplication,
259
- before: NavigationVisualSample
298
+ before: NavigationVisualSample,
299
+ context: SynthesizedCoordinateContext
260
300
  ) -> InAppBackOutcome {
261
301
  sleepFor(Self.navigationFallbackVerificationDelay)
262
- let after = captureNavigationFallbackVisualState(app: app)
302
+ let after = captureNavigationFallbackVisualState(app: app, context: context)
263
303
  let observation = Self.navigationVisualObservation(before: before.data, after: after.data)
264
304
 
265
305
 
@@ -35,14 +35,16 @@ extension RunnerTests {
35
35
  }
36
36
  }
37
37
 
38
+ let synthesizedContext = synthesizedSequenceCoordinateContext(steps: steps, app: activeApp)
39
+
40
+
38
41
 
39
42
  let firstStep = steps[0]
40
43
  let firstFrame = (firstStep.x != nil && firstStep.y != nil)
41
- ? resolvedTouchVisualizationFrame(app: activeApp, x: firstStep.x!, y: firstStep.y!)
44
+ ? synthesizedContext.map { touchVisualizationFrame(x: firstStep.x!, y: firstStep.y!, context: $0) }
45
+ ?? resolvedTouchVisualizationFrame(app: activeApp, x: firstStep.x!, y: firstStep.y!)
42
46
  : nil
43
47
 
44
- let synthesizedContext = synthesizedSequenceCoordinateContext(steps: steps, app: activeApp)
45
-
46
48
  let execution = assembleSequenceExecution(steps: steps) { _, step in
47
49
  performSequenceStep(step, activeApp: activeApp, synthesizedContext: synthesizedContext)
48
50
  }
@@ -145,9 +147,17 @@ extension RunnerTests {
145
147
  ) -> SequenceStepOutcome {
146
148
  let x = step.x ?? 0
147
149
  let y = step.y ?? 0
150
+ let longPressDurationMs = min(max(step.durationMs ?? 800, 16), 10000)
148
151
  if let policyKind = synthesizedPolicyKind(forSequenceStep: step) {
149
152
  switch performSynthesizedGesture(activeApp, kind: policyKind, context: synthesizedContext, synthesize: {
150
- synthesizedTapAt(app: activeApp, x: x, y: y, context: synthesizedContext)
153
+ synthesizedSequenceStep(
154
+ policyKind,
155
+ app: activeApp,
156
+ x: x,
157
+ y: y,
158
+ longPressDurationMs: longPressDurationMs,
159
+ context: synthesizedContext
160
+ )
151
161
  }) {
152
162
  case .performed(let timing):
153
163
  return finishedSequenceStep(step, timing: timing, outcome: .performed)
@@ -167,8 +177,7 @@ extension RunnerTests {
167
177
 
168
178
  return doubleTapAt(app: activeApp, x: x, y: y)
169
179
  case "longPress":
170
- let duration = min(max(step.durationMs ?? 800, 16), 10000) / 1000.0
171
- return longPressAt(app: activeApp, x: x, y: y, duration: duration)
180
+ return longPressAt(app: activeApp, x: x, y: y, duration: longPressDurationMs / 1000.0)
172
181
  default:
173
182
  return tapAt(app: activeApp, x: x, y: y)
174
183
  }
@@ -176,6 +185,31 @@ extension RunnerTests {
176
185
  return finishedSequenceStep(step, timing: timing, outcome: outcome)
177
186
  }
178
187
 
188
+ @MainActor
189
+ private func synthesizedSequenceStep(
190
+ _ policyKind: SynthesizedGesturePolicyKind,
191
+ app: XCUIApplication,
192
+ x: Double,
193
+ y: Double,
194
+ longPressDurationMs: Double,
195
+ context: SynthesizedCoordinateContext?
196
+ ) -> RunnerInteractionOutcome? {
197
+ switch policyKind {
198
+ #if os(iOS)
199
+ case .coordinateLongPress:
200
+ return synthesizedLongPressAt(
201
+ app: app,
202
+ x: x,
203
+ y: y,
204
+ durationMs: longPressDurationMs,
205
+ context: context
206
+ )
207
+ #endif
208
+ default:
209
+ return synthesizedTapAt(app: app, x: x, y: y, context: context)
210
+ }
211
+ }
212
+
179
213
  private func finishedSequenceStep(
180
214
  _ step: SequenceStep,
181
215
  timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double),
@@ -514,6 +514,11 @@ extension RunnerTests {
514
514
  }
515
515
 
516
516
 
517
+ func snapshotHasKeyboardFocus(_ snapshot: XCUIElementSnapshot) -> Bool {
518
+ return kvcBool(snapshot as! NSObject, forKey: "hasKeyboardFocus")
519
+ }
520
+
521
+
517
522
 
518
523
 
519
524
 
@@ -51,6 +51,45 @@ enum SnapshotXCTestChannelPlanState: Equatable {
51
51
 
52
52
 
53
53
 
54
+ struct SnapshotXCTestChannelPenalty: Equatable {
55
+ static let duration: TimeInterval = 120
56
+ static let recoveryProbeInterval: TimeInterval = 30
57
+
58
+ private(set) var bundleId: String?
59
+ private(set) var until = Date.distantPast
60
+ private(set) var probeDueAt = Date.distantFuture
61
+
62
+
63
+ func isActive(for bundleId: String?, at now: Date) -> Bool {
64
+ guard now < until else { return false }
65
+ guard let penalized = self.bundleId else { return true }
66
+ return penalized == bundleId
67
+ }
68
+
69
+ func isProbeDue(for bundleId: String?, at now: Date) -> Bool {
70
+ isActive(for: bundleId, at: now) && now >= probeDueAt
71
+ }
72
+
73
+ mutating func arm(bundleId: String?, at now: Date) {
74
+ self.bundleId = bundleId
75
+ until = now.addingTimeInterval(Self.duration)
76
+ probeDueAt = now.addingTimeInterval(Self.recoveryProbeInterval)
77
+ }
78
+
79
+
80
+ mutating func claimProbe(at now: Date) {
81
+ probeDueAt = now.addingTimeInterval(Self.recoveryProbeInterval)
82
+ }
83
+
84
+ mutating func clear() {
85
+ self = SnapshotXCTestChannelPenalty()
86
+ }
87
+ }
88
+
89
+
90
+
91
+
92
+
54
93
 
55
94
  enum SnapshotTierOutcome: Equatable {
56
95
  case completed
@@ -64,6 +103,12 @@ struct EffectiveSnapshotCapturePlan {
64
103
 
65
104
 
66
105
  let preferredBackend: SnapshotBackendKind?
106
+
107
+
108
+ var leadsWithXCTestRecoveryProbe: Bool {
109
+ xCTestChannelState == .deferredToIndependentBackend
110
+ && plan.first?.usesXCTestAccessibilityChannel == true
111
+ }
67
112
  }
68
113
 
69
114
 
@@ -144,8 +189,7 @@ extension RunnerTests {
144
189
 
145
190
  func penalizeSnapshotXCTestChannel(bundleId: String?, reason: String) {
146
191
  snapshotXCTestChannelPenaltyLock.lock()
147
- snapshotXCTestChannelPenaltyBundleId = bundleId
148
- snapshotXCTestChannelPenaltyUntil = Date().addingTimeInterval(snapshotXCTestChannelPenaltyDuration)
192
+ snapshotXCTestChannelPenalty.arm(bundleId: bundleId, at: Date())
149
193
  snapshotXCTestChannelPenaltyLock.unlock()
150
194
  NSLog(
151
195
  "AGENT_DEVICE_RUNNER_SNAPSHOT_XCTEST_CHANNEL_PENALIZED bundle=%@ reason=%@",
@@ -156,9 +200,8 @@ extension RunnerTests {
156
200
 
157
201
  func clearSnapshotXCTestChannelPenalty(reason: String) {
158
202
  snapshotXCTestChannelPenaltyLock.lock()
159
- let hadActivePenalty = Date() < snapshotXCTestChannelPenaltyUntil
160
- snapshotXCTestChannelPenaltyBundleId = nil
161
- snapshotXCTestChannelPenaltyUntil = Date.distantPast
203
+ let hadActivePenalty = Date() < snapshotXCTestChannelPenalty.until
204
+ snapshotXCTestChannelPenalty.clear()
162
205
  snapshotXCTestChannelPenaltyLock.unlock()
163
206
  if hadActivePenalty {
164
207
  NSLog("AGENT_DEVICE_RUNNER_SNAPSHOT_XCTEST_CHANNEL_PENALTY_CLEARED reason=%@", reason)
@@ -168,10 +211,20 @@ extension RunnerTests {
168
211
  func isSnapshotXCTestChannelPenalized(bundleId: String?) -> Bool {
169
212
  snapshotXCTestChannelPenaltyLock.lock()
170
213
  defer { snapshotXCTestChannelPenaltyLock.unlock() }
171
- guard Date() < snapshotXCTestChannelPenaltyUntil else { return false }
214
+ return snapshotXCTestChannelPenalty.isActive(for: bundleId, at: Date())
215
+ }
172
216
 
173
- guard let penalized = snapshotXCTestChannelPenaltyBundleId else { return true }
174
- return penalized == bundleId
217
+ func isSnapshotXCTestRecoveryProbeDue(bundleId: String?) -> Bool {
218
+ snapshotXCTestChannelPenaltyLock.lock()
219
+ defer { snapshotXCTestChannelPenaltyLock.unlock() }
220
+ return snapshotXCTestChannelPenalty.isProbeDue(for: bundleId, at: Date())
221
+ }
222
+
223
+ func claimSnapshotXCTestRecoveryProbe(bundleId: String?) {
224
+ snapshotXCTestChannelPenaltyLock.lock()
225
+ snapshotXCTestChannelPenalty.claimProbe(at: Date())
226
+ snapshotXCTestChannelPenaltyLock.unlock()
227
+ NSLog("AGENT_DEVICE_RUNNER_SNAPSHOT_XCTEST_RECOVERY_PROBE bundle=%@", bundleId ?? "")
175
228
  }
176
229
 
177
230
 
@@ -246,9 +299,11 @@ extension RunnerTests {
246
299
 
247
300
 
248
301
 
302
+
249
303
  static func effectiveSnapshotCapturePlan(
250
304
  _ plan: [SnapshotBackendKind],
251
305
  xCTestChannelPenalized: Bool,
306
+ xCTestRecoveryProbeDue: Bool = false,
252
307
  availableBackends: Set<SnapshotBackendKind> = Set(SnapshotBackendKind.allCases),
253
308
  preferredBackend: String? = nil
254
309
  ) -> EffectiveSnapshotCapturePlan {
@@ -280,8 +335,10 @@ extension RunnerTests {
280
335
 
281
336
 
282
337
 
338
+
339
+ let boundedTree = availablePlan.filter { $0 == .recursiveTree }
283
340
  return EffectiveSnapshotCapturePlan(
284
- plan: recoveryPlan + availablePlan.filter { $0 == .recursiveTree },
341
+ plan: xCTestRecoveryProbeDue ? boundedTree + recoveryPlan : recoveryPlan + boundedTree,
285
342
  xCTestChannelState: .deferredToIndependentBackend,
286
343
  treeCaptureSliceBudgetOverride: Self.penalizedXCTestProbeTreeSliceBudget,
287
344
  preferredBackend: nil
@@ -324,8 +381,10 @@ extension RunnerTests {
324
381
 
325
382
  var xCTestChannelPenalized = false
326
383
  var xCTestChannelPenalizedByBreaker = false
384
+ var xCTestRecoveryProbeDue = false
327
385
  #if os(iOS)
328
386
  xCTestChannelPenalizedByBreaker = isSnapshotXCTestChannelPenalized(bundleId: target.bundleId)
387
+ xCTestRecoveryProbeDue = isSnapshotXCTestRecoveryProbeDue(bundleId: target.bundleId)
329
388
  xCTestChannelPenalized = Self.snapshotXCTestChannelTreatedAsPenalized(
330
389
  penalized: xCTestChannelPenalizedByBreaker,
331
390
  preferredBackend: options.preferredBackend
@@ -334,6 +393,7 @@ extension RunnerTests {
334
393
  let effective = Self.effectiveSnapshotCapturePlan(
335
394
  plan,
336
395
  xCTestChannelPenalized: xCTestChannelPenalized,
396
+ xCTestRecoveryProbeDue: xCTestRecoveryProbeDue,
337
397
  availableBackends: Set(SnapshotBackendKind.allCases.filter(\.isAvailableOnCurrentPlatform)),
338
398
  preferredBackend: options.preferredBackend
339
399
  )
@@ -374,6 +434,9 @@ extension RunnerTests {
374
434
  }
375
435
  continue
376
436
  }
437
+ if kind == effectivePlan.first && effective.leadsWithXCTestRecoveryProbe {
438
+ claimSnapshotXCTestRecoveryProbe(bundleId: target.bundleId)
439
+ }
377
440
  if kind.usesXCTestAccessibilityChannel { xCTestTierRan = true }
378
441
  let attempt = try captureWithBackend(
379
442
  kind,
@@ -386,7 +449,8 @@ extension RunnerTests {
386
449
  kind,
387
450
  attempt: attempt,
388
451
  bundleId: target.bundleId,
389
- penaltySuppressed: suppressXCTestPenalty
452
+ penaltySuppressed: suppressXCTestPenalty,
453
+ channelState: effective.xCTestChannelState
390
454
  )
391
455
  if case let .failed(failure, phase: _) = attempt.outcome {
392
456
  if Self.isAxSnapshotFailure(failure) { axFailure = failure }
@@ -119,9 +119,10 @@ extension RunnerTests {
119
119
  static func snapshotXCTestPenaltyReason(
120
120
  kind: SnapshotBackendKind,
121
121
  attempt: SnapshotBackendAttempt,
122
- slowThresholdMs: Double
122
+ slowThresholdMs: Double,
123
+ channelState: SnapshotXCTestChannelPlanState = .normal
123
124
  ) -> String? {
124
- guard kind.usesXCTestAccessibilityChannel else { return nil }
125
+ guard channelState == .normal, kind.usesXCTestAccessibilityChannel else { return nil }
125
126
  if case let .failed(failure, phase: .acquisition) = attempt.outcome,
126
127
  failure.code == Self.xCTestSnapshotTimeoutCode
127
128
  {
@@ -134,18 +135,46 @@ extension RunnerTests {
134
135
  return "slow_\(kind.rawValue)_capture_\(Int(attempt.timing.acquisitionMs))ms"
135
136
  }
136
137
 
138
+
139
+ static func snapshotXCTestRecoveryProbeSucceeded(
140
+ kind: SnapshotBackendKind,
141
+ attempt: SnapshotBackendAttempt,
142
+ channelState: SnapshotXCTestChannelPlanState
143
+ ) -> Bool {
144
+ guard channelState != .normal,
145
+ kind == .recursiveTree,
146
+ attempt.timing.acquisitionMs <= Self.penalizedXCTestProbeTreeSliceBudget * 1_000,
147
+ case let .captured(capture) = attempt.outcome
148
+ else { return false }
149
+ return Self.snapshotTierRejectionReason(
150
+ outcome: attempt.tierOutcome,
151
+ kind: kind,
152
+ payload: capture.qualityPayload ?? capture.payload
153
+ ) == nil
154
+ }
155
+
137
156
  func recordXCTestSnapshotBackendAttemptIfNeeded(
138
157
  _ kind: SnapshotBackendKind,
139
158
  attempt: SnapshotBackendAttempt,
140
159
  bundleId: String?,
141
- penaltySuppressed: Bool
160
+ penaltySuppressed: Bool,
161
+ channelState: SnapshotXCTestChannelPlanState
142
162
  ) {
143
163
  guard !penaltySuppressed else { return }
164
+ if Self.snapshotXCTestRecoveryProbeSucceeded(
165
+ kind: kind,
166
+ attempt: attempt,
167
+ channelState: channelState
168
+ ) {
169
+ clearSnapshotXCTestChannelPenalty(reason: "healthy_tree_recovery_probe")
170
+ return
171
+ }
144
172
  guard
145
173
  let reason = Self.snapshotXCTestPenaltyReason(
146
174
  kind: kind,
147
175
  attempt: attempt,
148
- slowThresholdMs: snapshotXCTestSlowCaptureThreshold * 1_000
176
+ slowThresholdMs: snapshotXCTestSlowCaptureThreshold * 1_000,
177
+ channelState: channelState
149
178
  )
150
179
  else { return }
151
180
  penalizeSnapshotXCTestChannel(
@@ -138,7 +138,7 @@ extension RunnerTests {
138
138
  observe: () -> TextValueRead,
139
139
  waitForNextObservation: () -> Void
140
140
  ) {
141
- let field = resolveTextEntryElement(app: app, target: target)
141
+ let field = resolveTextEntryInput(app: app, target: target)?.attributes
142
142
  let placeholder = field?.placeholderValue
143
143
  let waitStartedAt = Date()
144
144
  return (
@@ -146,7 +146,7 @@ extension RunnerTests {
146
146
  fieldIsUnreadable: textValueRead(for: field) == .unreadable,
147
147
  observe: {
148
148
  let observed = self.textValueRead(
149
- for: self.resolveTextEntryElement(app: app, target: target),
149
+ for: self.resolveTextEntryInput(app: app, target: target)?.attributes,
150
150
  treatingPlaceholderAsEmpty: true
151
151
  )
152
152
  var observedText: String?
@@ -45,6 +45,7 @@ enum SynthesizedFallbackPolicy: String, Equatable, Hashable {
45
45
 
46
46
  enum SynthesizedGesturePolicyKind: String, Equatable, Hashable {
47
47
  case coordinateTap
48
+ case coordinateLongPress
48
49
  case scroll
49
50
  case synthesizedDrag
50
51
  }
@@ -58,7 +59,9 @@ struct SynthesizedCoordinateContext {
58
59
  let referenceFrame: CGRect
59
60
 
60
61
 
61
- let resolvedWindow: XCUIElement
62
+
63
+
64
+ let resolvedWindow: XCUIElement?
62
65
  let keyboardPolicy: SynthesizedKeyboardPolicy
63
66
  let accessibilityHealth: RunnerAccessibilityHealth
64
67
 
@@ -83,6 +86,14 @@ func synthesizedGesturePolicy(_ kind: SynthesizedGesturePolicyKind) -> Synthesiz
83
86
  keyboardPolicy: .never,
84
87
  fallbackPolicy: .xctestCoordinateAllowed
85
88
  )
89
+ case .coordinateLongPress:
90
+
91
+
92
+
93
+ return SynthesizedGesturePolicy(
94
+ keyboardPolicy: .never,
95
+ fallbackPolicy: .xctestCoordinateWhenAccessibilityAvailable
96
+ )
86
97
  case .scroll:
87
98
 
88
99
 
@@ -107,8 +118,18 @@ func shouldProbeCoordinateTapTextInput(xCTestChannelPenalized: Bool) -> Bool {
107
118
  }
108
119
 
109
120
 
121
+
110
122
  func synthesizedPolicyKind(forSequenceStep step: SequenceStep) -> SynthesizedGesturePolicyKind? {
111
- step.synthesized == true && step.kind == "tap" ? .coordinateTap : nil
123
+ switch step.kind {
124
+ case "tap":
125
+ return step.synthesized == true ? .coordinateTap : nil
126
+ #if os(iOS)
127
+ case "longPress":
128
+ return .coordinateLongPress
129
+ #endif
130
+ default:
131
+ return nil
132
+ }
112
133
  }
113
134
 
114
135