agent-device 0.21.37 → 0.21.38

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 (485) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.37.apk → agent-device-android-ime-helper-0.21.38.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.38.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.37.manifest.json → agent-device-android-ime-helper-0.21.38.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.apk → agent-device-android-snapshot-helper-0.21.38.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.38.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.manifest.json → agent-device-android-snapshot-helper-0.21.38.manifest.json} +7 -7
  7. package/apple/fold-helper/Fold.m +8 -4
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerKeyboardReturnKey.swift +53 -0
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +42 -4
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +26 -18
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +42 -11
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +123 -22
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +570 -53
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +41 -0
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +7 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +17 -1
  18. package/dist/src/THIRD_PARTY_NOTICES.txt +2 -2
  19. package/dist/src/absence-observation-errors.js +1 -1
  20. package/dist/src/absence-observation.js +1 -1
  21. package/dist/src/adapter.js +1 -1
  22. package/dist/src/adb-executor.js +1 -1
  23. package/dist/src/adb-failure.js +2 -2
  24. package/dist/src/adb-transport.js +1 -1
  25. package/dist/src/agent-browser-lifecycle.js +1 -1
  26. package/dist/src/agent-browser-process-record.js +1 -1
  27. package/dist/src/agent-browser-provider.js +1 -1
  28. package/dist/src/agent-browser-tool.js +1 -1
  29. package/dist/src/ai-sdk.d.ts +1 -1
  30. package/dist/src/ai-sdk.js +1 -1
  31. package/dist/src/alert-contract.js +1 -1
  32. package/dist/src/alert-tree-driver.js +1 -1
  33. package/dist/src/alert.js +1 -1
  34. package/dist/src/android-adb.d.ts +1 -1
  35. package/dist/src/android.js +1 -1
  36. package/dist/src/android2.js +1 -1
  37. package/dist/src/app-backend.js +1 -1
  38. package/dist/src/app-catalog.js +1 -1
  39. package/dist/src/app-deployment-resolution.js +1 -1
  40. package/dist/src/app-inventory.js +1 -1
  41. package/dist/src/app-launch.js +1 -1
  42. package/dist/src/app-lifecycle.js +4 -4
  43. package/dist/src/app-lifecycle2.js +2 -2
  44. package/dist/src/app-log-files.js +1 -1
  45. package/dist/src/app-log-runtime2.js +2 -2
  46. package/dist/src/app-log-session-resource.js +1 -1
  47. package/dist/src/app-resolution.js +1 -1
  48. package/dist/src/app-state-read.js +1 -1
  49. package/dist/src/app-state-runtime.d.ts +1 -1
  50. package/dist/src/application-lifecycle-interaction.js +1 -1
  51. package/dist/src/archive.js +1 -1
  52. package/dist/src/args.js +1 -1
  53. package/dist/src/artifact-download.js +1 -1
  54. package/dist/src/artifact-tracking.js +1 -1
  55. package/dist/src/auth-session.js +1 -1
  56. package/dist/src/auth.js +1 -1
  57. package/dist/src/automation-helper-artifact.js +1 -1
  58. package/dist/src/automation-helper.js +1 -1
  59. package/dist/src/await-with-signal.js +1 -1
  60. package/dist/src/backend-snapshot-options.js +1 -1
  61. package/dist/src/boot-diagnostics.js +1 -1
  62. package/dist/src/bridge-source.js +1 -1
  63. package/dist/src/browser-launch.js +1 -1
  64. package/dist/src/browserstack-device-features.js +1 -1
  65. package/dist/src/browserstack.js +1 -1
  66. package/dist/src/cache.js +1 -1
  67. package/dist/src/capture-disclosure.js +1 -1
  68. package/dist/src/capture-lifecycle.js +1 -1
  69. package/dist/src/cli-config.js +1 -1
  70. package/dist/src/cli-help.js +19 -16
  71. package/dist/src/cli-output.js +11 -11
  72. package/dist/src/cli-runner.js +1 -1
  73. package/dist/src/cli.js +2 -2
  74. package/dist/src/click-button.js +1 -1
  75. package/dist/src/client-metro-companion.js +1 -1
  76. package/dist/src/client-metro.js +1 -1
  77. package/dist/src/client-options.js +1 -1
  78. package/dist/src/client-port.d.ts +246 -208
  79. package/dist/src/clipboard-shell-response.js +1 -1
  80. package/dist/src/cloud-artifacts.d.ts +7 -2
  81. package/dist/src/code-signature-cache.js +1 -1
  82. package/dist/src/command-schema.js +6 -4
  83. package/dist/src/command-tools.js +3 -3
  84. package/dist/src/command.js +1 -1
  85. package/dist/src/composed-inventory-gateways.js +1 -1
  86. package/dist/src/composite-resource-admission.js +1 -1
  87. package/dist/src/config.js +1 -1
  88. package/dist/src/connection-lease-transaction.js +1 -1
  89. package/dist/src/connection-metro-runtime.js +1 -1
  90. package/dist/src/connection-runtime.js +1 -1
  91. package/dist/src/connection-verification.js +1 -1
  92. package/dist/src/connection.js +3 -3
  93. package/dist/src/context.js +1 -1
  94. package/dist/src/contract.d.ts +2 -1
  95. package/dist/src/contracts.d.ts +1 -1
  96. package/dist/src/contracts.js +1 -1
  97. package/dist/src/daemon-client-attach.js +1 -1
  98. package/dist/src/daemon-client-dispatch-disclosure.js +1 -1
  99. package/dist/src/daemon-client-ensure.js +1 -1
  100. package/dist/src/daemon-client-ensuring.js +1 -1
  101. package/dist/src/daemon-client-lease-beat.js +1 -1
  102. package/dist/src/daemon-client-lifecycle.js +1 -1
  103. package/dist/src/daemon-client-liveness-probe.js +1 -1
  104. package/dist/src/daemon-client-remote-health-cache.js +1 -0
  105. package/dist/src/daemon-client-remote-health-recovery.js +1 -0
  106. package/dist/src/daemon-client-transport.js +1 -1
  107. package/dist/src/daemon-command-registry.js +1 -1
  108. package/dist/src/daemon-composition.js +1 -1
  109. package/dist/src/daemon-diagnostics-scope.js +1 -1
  110. package/dist/src/daemon-http.js +1 -1
  111. package/dist/src/daemon-launch-spec.js +1 -1
  112. package/dist/src/daemon-lifecycle-errors.js +1 -1
  113. package/dist/src/daemon-policy-file.js +1 -1
  114. package/dist/src/daemon-registration-owner.js +3 -3
  115. package/dist/src/daemon-registration.js +1 -1
  116. package/dist/src/daemon-resolution.js +1 -1
  117. package/dist/src/daemon-startup-diagnostics.js +1 -1
  118. package/dist/src/daemon-stop.js +1 -1
  119. package/dist/src/daemon.js +1 -1
  120. package/dist/src/debug-symbols-facade.js +3 -3
  121. package/dist/src/device-claim-admission.js +1 -0
  122. package/dist/src/device-claim-reconciliation.js +1 -0
  123. package/dist/src/device-claim-recovery.js +1 -1
  124. package/dist/src/device-claim-rule.js +1 -1
  125. package/dist/src/device-claims.js +1 -1
  126. package/dist/src/device-input-state.d.ts +1 -1
  127. package/dist/src/device-inventory-context.js +1 -1
  128. package/dist/src/device-selection-resolver.js +1 -1
  129. package/dist/src/device-session.js +1 -1
  130. package/dist/src/device-shell.js +1 -1
  131. package/dist/src/device.js +1 -1
  132. package/dist/src/device3.js +3 -3
  133. package/dist/src/devicectl.js +1 -1
  134. package/dist/src/diagnostics.js +1 -1
  135. package/dist/src/discovery.js +1 -1
  136. package/dist/src/dispatch-resolve.js +1 -1
  137. package/dist/src/display-inventory.js +1 -1
  138. package/dist/src/doctor-facade.js +1 -1
  139. package/dist/src/doctor2.js +1 -1
  140. package/dist/src/durable-capture-resource.js +1 -1
  141. package/dist/src/durable-capture.js +1 -1
  142. package/dist/src/durable-resource.js +1 -1
  143. package/dist/src/ended-lease.js +1 -1
  144. package/dist/src/engine-eval-script.js +1 -1
  145. package/dist/src/error.js +2 -2
  146. package/dist/src/errors.js +1 -1
  147. package/dist/src/explicit-session-resolution.js +1 -1
  148. package/dist/src/expo-dev-client-launch.js +1 -1
  149. package/dist/src/failure-output.js +1 -1
  150. package/dist/src/file.js +1 -1
  151. package/dist/src/find.js +1 -1
  152. package/dist/src/finders.js +1 -1
  153. package/dist/src/flag-registry.js +1 -1
  154. package/dist/src/focus-runtime.js +1 -1
  155. package/dist/src/fold-helper.js +1 -1
  156. package/dist/src/generic-settle.js +1 -1
  157. package/dist/src/generic.js +1 -1
  158. package/dist/src/gesture-admission.js +1 -1
  159. package/dist/src/gesture-plan-types.d.ts +1 -1
  160. package/dist/src/gesture-plan.js +1 -1
  161. package/dist/src/gesture-runtime.js +1 -1
  162. package/dist/src/hdc.js +1 -1
  163. package/dist/src/helper-artifacts.js +1 -1
  164. package/dist/src/helper.js +2 -2
  165. package/dist/src/host-file.js +1 -1
  166. package/dist/src/host.js +1 -1
  167. package/dist/src/host2.js +1 -1
  168. package/dist/src/host3.js +1 -1
  169. package/dist/src/host4.js +1 -1
  170. package/dist/src/host5.js +1 -1
  171. package/dist/src/host6.js +1 -1
  172. package/dist/src/human-control-contract.js +1 -1
  173. package/dist/src/human-control.js +1 -1
  174. package/dist/src/ime-rebind.js +1 -1
  175. package/dist/src/ime-settings-record.js +1 -1
  176. package/dist/src/ime-state.js +1 -1
  177. package/dist/src/index.d.ts +3 -3
  178. package/dist/src/index.js +1 -1
  179. package/dist/src/input-actions.js +1 -1
  180. package/dist/src/input-actions2.js +1 -1
  181. package/dist/src/install-artifact-facade.js +1 -1
  182. package/dist/src/install-source-network-transport.js +1 -1
  183. package/dist/src/install-source2.js +1 -1
  184. package/dist/src/interaction-error.js +1 -1
  185. package/dist/src/interaction-positionals.js +1 -1
  186. package/dist/src/interaction-ref-policy.js +1 -1
  187. package/dist/src/interaction2.js +1 -1
  188. package/dist/src/interactor-operation-binding.js +1 -1
  189. package/dist/src/interactor.js +5 -5
  190. package/dist/src/interactor2.js +1 -1
  191. package/dist/src/interactor3.js +1 -1
  192. package/dist/src/interactor4.js +1 -1
  193. package/dist/src/interactor5.js +1 -1
  194. package/dist/src/interactors.js +1 -1
  195. package/dist/src/internal/bin.js +1 -1
  196. package/dist/src/internal/companion-tunnel.js +1 -1
  197. package/dist/src/internal/daemon.js +1 -1
  198. package/dist/src/internal/png-worker.js +1 -1
  199. package/dist/src/internal/run-script-child.js +1 -1
  200. package/dist/src/inventory.js +1 -1
  201. package/dist/src/inventory2.js +1 -1
  202. package/dist/src/inventory3.js +1 -1
  203. package/dist/src/inventory5.js +1 -1
  204. package/dist/src/ios-node-interpretation.js +1 -1
  205. package/dist/src/ios-simulator-accessibility.js +1 -1
  206. package/dist/src/ios-snapshot-acquisition.js +1 -1
  207. package/dist/src/ios-snapshot-engine.js +1 -1
  208. package/dist/src/ios-snapshot-runtime.js +1 -1
  209. package/dist/src/launch-confirmation.js +1 -1
  210. package/dist/src/launch-services-registration.js +1 -1
  211. package/dist/src/lease-context.js +1 -1
  212. package/dist/src/lease-registry-scope.js +1 -1
  213. package/dist/src/lease-release2.js +1 -1
  214. package/dist/src/lease-scope.js +1 -1
  215. package/dist/src/lease.js +1 -1
  216. package/dist/src/leased-recording-retention.js +1 -1
  217. package/dist/src/legacy.js +1 -1
  218. package/dist/src/limrun-download-file.js +1 -1
  219. package/dist/src/limrun-ios-files.js +1 -1
  220. package/dist/src/limrun-ios-runner.js +2 -2
  221. package/dist/src/limrun-runtime-dependencies.js +1 -1
  222. package/dist/src/limrun.d.ts +1 -1
  223. package/dist/src/local-interactor-operation-set.js +1 -1
  224. package/dist/src/local-simulator-apps.js +1 -1
  225. package/dist/src/local-simulator-files.js +1 -1
  226. package/dist/src/location-coordinates.js +1 -1
  227. package/dist/src/manifest.js +1 -1
  228. package/dist/src/mechanics.js +12 -12
  229. package/dist/src/merge-flags.js +1 -1
  230. package/dist/src/metro-reload-endpoints.js +1 -1
  231. package/dist/src/metro-session-hints.js +1 -1
  232. package/dist/src/metro.d.ts +1 -1
  233. package/dist/src/mobile-snapshot-semantics.js +1 -1
  234. package/dist/src/network-traffic.js +1 -1
  235. package/dist/src/node-http.js +1 -1
  236. package/dist/src/node-touch-point.js +1 -1
  237. package/dist/src/observation.js +1 -1
  238. package/dist/src/open-script.js +1 -1
  239. package/dist/src/open-target-device-resolution.js +1 -1
  240. package/dist/src/orientation.js +1 -1
  241. package/dist/src/parameterized-recorded-fill.js +1 -1
  242. package/dist/src/perf-facade.js +1 -1
  243. package/dist/src/perf-runtime-operation-builder.js +1 -1
  244. package/dist/src/perf-runtime-plan.js +1 -1
  245. package/dist/src/perf-target.js +2 -2
  246. package/dist/src/perf.js +1 -1
  247. package/dist/src/physical-device-control.js +1 -1
  248. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  249. package/dist/src/platform-runtime-app-log-process.js +1 -1
  250. package/dist/src/platform-runtime-apple-application-tools.js +1 -1
  251. package/dist/src/platform-runtime-claim-recovery.js +1 -1
  252. package/dist/src/platform-runtime-host.js +1 -1
  253. package/dist/src/platform-runtime-open-target.js +1 -1
  254. package/dist/src/platform-runtime-operation-host.js +3 -3
  255. package/dist/src/platform-runtime-runtime-hints.js +1 -1
  256. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  257. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  258. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  259. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  260. package/dist/src/platform-runtime-shutdown-error.js +1 -1
  261. package/dist/src/platform-runtime-unavailable.js +1 -1
  262. package/dist/src/platform-runtime.js +1 -1
  263. package/dist/src/platform-runtime2.js +1 -1
  264. package/dist/src/plist.js +1 -1
  265. package/dist/src/plugins2.js +1 -1
  266. package/dist/src/png-crop-bytes.js +1 -1
  267. package/dist/src/png-resize.js +1 -1
  268. package/dist/src/png-size.js +1 -1
  269. package/dist/src/png-worker-client.js +1 -1
  270. package/dist/src/png.js +1 -1
  271. package/dist/src/post-gesture-stability.js +1 -1
  272. package/dist/src/process-executable-path.js +1 -0
  273. package/dist/src/process-exit.js +1 -1
  274. package/dist/src/provider-device-runtime.d.ts +2 -2
  275. package/dist/src/provider-limrun-credentials.js +1 -1
  276. package/dist/src/provider-plugin.d.ts +1 -1
  277. package/dist/src/provider-profile-fields.js +1 -1
  278. package/dist/src/provider-webdriver.js +1 -1
  279. package/dist/src/provider.js +1 -1
  280. package/dist/src/proxy.js +2 -2
  281. package/dist/src/react-devtools-connection.js +1 -1
  282. package/dist/src/react-devtools-inspect-command.js +1 -1
  283. package/dist/src/react-native-overlay2.js +2 -2
  284. package/dist/src/react-native.js +1 -1
  285. package/dist/src/react-profile-command.js +1 -1
  286. package/dist/src/record-runtime.js +1 -1
  287. package/dist/src/record-trace.js +1 -1
  288. package/dist/src/recording-gestures.js +1 -1
  289. package/dist/src/recording.js +1 -1
  290. package/dist/src/rect-center.js +1 -1
  291. package/dist/src/register-builtins.js +1 -1
  292. package/dist/src/registry.js +1 -1
  293. package/dist/src/remote-config-core.js +1 -1
  294. package/dist/src/remote-config-flags.js +1 -1
  295. package/dist/src/remote-connection-state.js +1 -1
  296. package/dist/src/replay-backend-host.js +1 -1
  297. package/dist/src/replay-divergence.js +1 -1
  298. package/dist/src/replay-maestro-backend.js +2 -2
  299. package/dist/src/replay.d.ts +1 -1
  300. package/dist/src/replay2.js +1 -1
  301. package/dist/src/reporting.js +1 -1
  302. package/dist/src/request-dispatch-disclosure.js +1 -1
  303. package/dist/src/request-ended-leases.js +1 -1
  304. package/dist/src/request-providers.js +1 -1
  305. package/dist/src/request-runtime-binding.js +1 -1
  306. package/dist/src/request.js +1 -1
  307. package/dist/src/result-serialization.js +2 -2
  308. package/dist/src/retry.js +1 -1
  309. package/dist/src/run-script-execution.js +6 -8
  310. package/dist/src/run-script-http.js +1 -1
  311. package/dist/src/runner-cache-metadata.js +1 -1
  312. package/dist/src/runner-cache-retention.js +1 -1
  313. package/dist/src/runner-client.js +1 -1
  314. package/dist/src/runner-contract.js +1 -1
  315. package/dist/src/runner-dev-tools-security.js +1 -1
  316. package/dist/src/runner-device-readiness.js +1 -1
  317. package/dist/src/runner-device-set.js +1 -1
  318. package/dist/src/runner-disposal.js +1 -1
  319. package/dist/src/runner-error-classification.js +2 -2
  320. package/dist/src/runner-exchange.js +1 -1
  321. package/dist/src/runner-io.js +1 -1
  322. package/dist/src/runner-launched-session.js +1 -1
  323. package/dist/src/runner-lease.js +1 -1
  324. package/dist/src/runner-lifecycle.js +1 -1
  325. package/dist/src/runner-operations-facade.js +1 -1
  326. package/dist/src/runner-panel.js +1 -1
  327. package/dist/src/runner-retention.js +1 -1
  328. package/dist/src/runner-runtime.js +1 -1
  329. package/dist/src/runner-selector-query.js +1 -1
  330. package/dist/src/runner-sequence.js +1 -1
  331. package/dist/src/runner-start-budget.js +1 -1
  332. package/dist/src/runner-startup-transport.js +1 -1
  333. package/dist/src/runner-toolchain-identity.js +1 -1
  334. package/dist/src/runtime-admission.js +1 -1
  335. package/dist/src/runtime-deployment.js +1 -1
  336. package/dist/src/runtime-factory.js +1 -1
  337. package/dist/src/runtime-session.js +1 -1
  338. package/dist/src/runtime-transport-hints.js +1 -1
  339. package/dist/src/runtime.js +2 -2
  340. package/dist/src/runtime10.js +1 -1
  341. package/dist/src/runtime11.js +1 -1
  342. package/dist/src/runtime12.js +1 -1
  343. package/dist/src/runtime13.js +2 -2
  344. package/dist/src/runtime2.js +2 -2
  345. package/dist/src/runtime4.js +3 -3
  346. package/dist/src/runtime5.js +1 -1
  347. package/dist/src/runtime6.js +1 -1
  348. package/dist/src/runtime7.js +2 -2
  349. package/dist/src/runtime8.js +1 -1
  350. package/dist/src/runtime9.js +1 -1
  351. package/dist/src/screen-recording-admission-ledger.js +1 -0
  352. package/dist/src/screen-recording-completion.js +1 -1
  353. package/dist/src/screen-recording-options.js +1 -1
  354. package/dist/src/screen-recording-resource-recovery.js +1 -1
  355. package/dist/src/screen-recording-stop-recovery.js +1 -1
  356. package/dist/src/screen-recording-transport.js +1 -1
  357. package/dist/src/screenshot-density.js +1 -1
  358. package/dist/src/screenshot-image-size.js +1 -1
  359. package/dist/src/screenshot-image.js +1 -1
  360. package/dist/src/screenshot-runtime.js +1 -1
  361. package/dist/src/screenshot-runtime2.js +1 -1
  362. package/dist/src/screenshot.js +1 -1
  363. package/dist/src/screenshot2.js +1 -1
  364. package/dist/src/screenshot4.js +1 -1
  365. package/dist/src/script-source.js +1 -1
  366. package/dist/src/script.js +1 -1
  367. package/dist/src/scroll-command.js +1 -1
  368. package/dist/src/scroll-gesture.js +1 -1
  369. package/dist/src/sdk-batch-runner.d.ts +1 -1
  370. package/dist/src/sdk-batch-runner.js +2 -2
  371. package/dist/src/sdk-batch.js +2 -2
  372. package/dist/src/sdk-contracts.d.ts +26 -2
  373. package/dist/src/sdk-contracts.js +2 -2
  374. package/dist/src/sdk-device.js +1 -1
  375. package/dist/src/sdk-finders.d.ts +1 -1
  376. package/dist/src/sdk-finders.js +1 -1
  377. package/dist/src/sdk-io.js +5 -5
  378. package/dist/src/sdk-remote-config.d.ts +1 -1
  379. package/dist/src/sdk-remote-config.js +1 -1
  380. package/dist/src/sdk-selectors.d.ts +9 -6
  381. package/dist/src/sdk-selectors.js +1 -1
  382. package/dist/src/selection.js +0 -0
  383. package/dist/src/selector-pipeline-policy.js +1 -1
  384. package/dist/src/selector-runtime.js +1 -1
  385. package/dist/src/selectors.js +1 -1
  386. package/dist/src/server-shutdown.js +1 -1
  387. package/dist/src/server-startup.js +2 -2
  388. package/dist/src/server.js +4 -4
  389. package/dist/src/session-allocation.js +1 -1
  390. package/dist/src/session-artifact-paths.js +1 -1
  391. package/dist/src/session-capture-binding.js +1 -1
  392. package/dist/src/session-device-resolution.js +1 -1
  393. package/dist/src/session-event-action.js +1 -1
  394. package/dist/src/session-open.js +1 -1
  395. package/dist/src/session-repair-tombstone.js +1 -1
  396. package/dist/src/session-replay-vars.js +1 -1
  397. package/dist/src/session-routing.js +1 -1
  398. package/dist/src/session-runtime-admission.js +1 -1
  399. package/dist/src/session-runtime.js +1 -1
  400. package/dist/src/session-script-destination.js +1 -0
  401. package/dist/src/session-selector.js +1 -1
  402. package/dist/src/session-store.js +3 -3
  403. package/dist/src/session-teardown.js +1 -1
  404. package/dist/src/session-tenant-scope.js +1 -1
  405. package/dist/src/session2.js +5 -5
  406. package/dist/src/settings-bluetooth.js +1 -1
  407. package/dist/src/settings-global-toggle.js +1 -1
  408. package/dist/src/settings.js +1 -1
  409. package/dist/src/settings2.js +1 -1
  410. package/dist/src/settle-observation-capture.js +1 -1
  411. package/dist/src/simctl-execution.js +1 -1
  412. package/dist/src/simctl-facade.js +1 -1
  413. package/dist/src/simctl.js +1 -1
  414. package/dist/src/simulator-app-budget.js +1 -1
  415. package/dist/src/simulator-boot.js +1 -1
  416. package/dist/src/simulator-facade.js +1 -1
  417. package/dist/src/simulator-state.js +1 -1
  418. package/dist/src/simulator.js +1 -1
  419. package/dist/src/snapshot-baseline.js +1 -1
  420. package/dist/src/snapshot-chrome.js +1 -1
  421. package/dist/src/snapshot-desktop-projection.js +1 -1
  422. package/dist/src/snapshot-diagnostics.js +1 -1
  423. package/dist/src/snapshot-helper-install.js +3 -3
  424. package/dist/src/snapshot-helper-session.js +1 -1
  425. package/dist/src/snapshot-lines.js +1 -1
  426. package/dist/src/snapshot-node-lookup.js +1 -1
  427. package/dist/src/snapshot-occlusion.js +1 -1
  428. package/dist/src/snapshot-private-evidence.js +1 -1
  429. package/dist/src/snapshot-runtime-binding.js +1 -1
  430. package/dist/src/snapshot-runtime-capture-input.js +1 -1
  431. package/dist/src/snapshot-runtime.js +1 -1
  432. package/dist/src/snapshot-state.js +1 -1
  433. package/dist/src/snapshot.js +1 -1
  434. package/dist/src/snapshot2.js +1 -1
  435. package/dist/src/snapshot3.js +2 -2
  436. package/dist/src/snapshot4.js +1 -1
  437. package/dist/src/source-channel.js +1 -1
  438. package/dist/src/src.js +1 -1
  439. package/dist/src/src10.js +1 -1
  440. package/dist/src/src11.js +1 -1
  441. package/dist/src/src2.js +1 -1
  442. package/dist/src/src3.js +5 -5
  443. package/dist/src/src4.js +2 -2
  444. package/dist/src/src5.js +1 -1
  445. package/dist/src/src6.js +1 -1
  446. package/dist/src/src8.js +1 -1
  447. package/dist/src/store-legacy.js +1 -1
  448. package/dist/src/store.js +1 -1
  449. package/dist/src/string-enum.js +1 -1
  450. package/dist/src/surface-snapshot.js +1 -1
  451. package/dist/src/surface-snapshot2.js +1 -1
  452. package/dist/src/sync-cache.js +1 -1
  453. package/dist/src/system-surface-foreground.js +2 -2
  454. package/dist/src/takeover.js +1 -1
  455. package/dist/src/tap-keyboard-occlusion.js +1 -1
  456. package/dist/src/target-evidence-tree.js +1 -1
  457. package/dist/src/target-evidence.js +1 -1
  458. package/dist/src/telephony-runtime.js +1 -1
  459. package/dist/src/tool-provider-facade.js +1 -1
  460. package/dist/src/tool-provider.js +3 -3
  461. package/dist/src/tool-provider2.js +1 -1
  462. package/dist/src/tool-provider3.js +1 -1
  463. package/dist/src/toolchain-probe.js +1 -1
  464. package/dist/src/touch-runtime.js +1 -1
  465. package/dist/src/touch-runtime2.js +1 -1
  466. package/dist/src/transport.js +2 -2
  467. package/dist/src/tree.js +1 -1
  468. package/dist/src/tv-remote-runtime.js +1 -1
  469. package/dist/src/tv-remote.js +1 -1
  470. package/dist/src/type-text-runtime.js +1 -1
  471. package/dist/src/unsupported-interactor.js +1 -1
  472. package/dist/src/update-check.js +1 -1
  473. package/dist/src/validation.js +1 -1
  474. package/dist/src/vars.js +1 -1
  475. package/dist/src/vega-executable.js +1 -1
  476. package/dist/src/verified-file.js +1 -1
  477. package/dist/src/video.js +2 -2
  478. package/dist/src/viewport.js +1 -1
  479. package/dist/src/web.js +1 -1
  480. package/dist/src/webdriver-source.js +1 -1
  481. package/package.json +2 -2
  482. package/server.json +2 -2
  483. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.37.apk.sha256 +0 -1
  484. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.37.apk.sha256 +0 -1
  485. package/dist/src/capture-output-ownership.js +0 -1
@@ -2,7 +2,16 @@ import AgentDeviceSnapshotPresentation
2
2
  import XCTest
3
3
 
4
4
  extension RunnerTests {
5
- static let backSwipeVerificationDelay: TimeInterval = 0.25
5
+
6
+
7
+
8
+ static let navigationBarBackButtonIdentifier = "BackButton"
9
+
10
+
11
+
12
+ static let backSwipeVerificationDelay: TimeInterval = 0.1
13
+
14
+ static let backSwipeSettleSampleInterval: TimeInterval = 0.05
6
15
 
7
16
 
8
17
 
@@ -11,14 +20,35 @@ extension RunnerTests {
11
20
  #else
12
21
  static let backGestureAllowanceMs = 400.0
13
22
  #endif
14
- static let backSwipeSettleSampleBudget = 8
23
+
24
+
25
+ static let backSwipeSettleBaseBudgetMs = 2000.0
26
+
27
+
28
+
29
+
30
+
31
+ static let backSwipeStillMarginMs = 250.0
32
+
33
+
34
+
35
+
36
+
37
+ static func backSwipeSettleBudgetMs(maxCaptureMs: Double) -> Double {
38
+ let sampleIntervalMs = backSwipeSettleSampleInterval * 1000 + maxCaptureMs
39
+ return max(
40
+ backSwipeSettleBaseBudgetMs,
41
+ maxCaptureMs + backSwipeRequiredStillMs(maxCaptureMs: maxCaptureMs) + sampleIntervalMs
42
+ )
43
+ }
44
+
15
45
 
16
46
 
17
47
 
18
48
 
19
49
 
20
50
  static func backSwipeRequiredStillMs(maxCaptureMs: Double) -> Double {
21
- backGestureAllowanceMs + backSwipeVerificationDelay * 1000 + maxCaptureMs
51
+ backGestureAllowanceMs + backSwipeStillMarginMs + maxCaptureMs
22
52
  }
23
53
 
24
54
 
@@ -68,11 +98,13 @@ extension RunnerTests {
68
98
 
69
99
 
70
100
 
101
+
102
+
71
103
  @MainActor
72
104
  func performInAppBack(app: XCUIApplication) throws -> InAppBackOutcome {
73
105
  #if os(macOS)
74
106
  guard let back = macOSNavigationBackElement(app: app) else {
75
- return .refused(ErrorPayload(message: "in-app back control is not available"))
107
+ return .refused(Self.macOSInAppBackControlRefusal)
76
108
  }
77
109
  let frame = back.frame
78
110
  if frame.isEmpty {
@@ -86,13 +118,30 @@ extension RunnerTests {
86
118
  return .performed
87
119
  #elseif os(iOS)
88
120
 
121
+
89
122
  var trace = BackSwipeTrace()
123
+ func logSwipe(_ line: String) { NSLog("AGENT_DEVICE_RUNNER_BACK_SWIPE_VERIFICATION %@", line) }
124
+ let resolved: SynthesizedCoordinateContext?
90
125
  do {
91
- let outcome = try verifiedBackSwipe(app: app, trace: &trace)
92
- NSLog("AGENT_DEVICE_RUNNER_BACK_SWIPE_VERIFICATION %@", trace.logLine(outcome: outcome))
126
+ resolved = try synthesizedCoordinateContext(app: app)
127
+ } catch {
128
+ logSwipe(trace.logLine(name: "error", code: String(describing: type(of: error))))
129
+ throw error
130
+ }
131
+ guard let context = resolved else {
132
+ let outcome = InAppBackOutcome.refused(Self.backScreenRefusal(.unresolvedWindow))
133
+ logSwipe(trace.logLine(outcome: outcome))
134
+ return outcome
135
+ }
136
+ if let pressed = try pressNavigationBarBackButton(app: app, context: context) {
137
+ return pressed
138
+ }
139
+ do {
140
+ let outcome = try verifiedBackSwipe(app: app, context: context, trace: &trace)
141
+ logSwipe(trace.logLine(outcome: outcome))
93
142
  return outcome
94
143
  } catch {
95
- NSLog("AGENT_DEVICE_RUNNER_BACK_SWIPE_VERIFICATION %@", trace.logLine(name: "error", code: String(describing: type(of: error))))
144
+ logSwipe(trace.logLine(name: "error", code: String(describing: type(of: error))))
96
145
  throw error
97
146
  }
98
147
  #else
@@ -101,8 +150,8 @@ extension RunnerTests {
101
150
  return .refused(
102
151
  ErrorPayload(
103
152
  code: RunnerWireErrorCode.backSwipeNotDispatched,
104
- message: "visionOS has no back gesture",
105
- hint: "iOS back is a left-edge swipe; visionOS has none. Press the visible back control by its ref."
153
+ message: "visionOS has no back command",
154
+ hint: "Press the visible back control by its ref."
106
155
  )
107
156
  )
108
157
  #endif
@@ -144,16 +193,479 @@ extension RunnerTests {
144
193
  }
145
194
  }
146
195
 
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
147
204
  @MainActor
148
- private func verifiedBackSwipe(app: XCUIApplication, trace: inout BackSwipeTrace) throws -> InAppBackOutcome {
149
- guard let context = try synthesizedCoordinateContext(app: app) else {
150
- return .refused(Self.backScreenRefusal(.unresolvedWindow))
205
+ private func pressNavigationBarBackButton(
206
+ app: XCUIApplication,
207
+ context: SynthesizedCoordinateContext
208
+ ) throws -> InAppBackOutcome? {
209
+ var trace = NavigationBarBackTrace()
210
+
211
+ defer {
212
+ NSLog("AGENT_DEVICE_RUNNER_BACK_NAVIGATION_BAR_BUTTON %@", trace.logLine)
213
+
214
+
215
+
151
216
  }
152
- let before: (sample: Data, stableSinceMs: Double, settled: Bool)
153
- switch settledBackVisualState(app: app, context: context, trace: &trace) {
154
- case .success(let settled): before = settled
155
- case .failure(let refusal): return .refused(Self.backScreenRefusal(refusal))
217
+ guard navigationBarBackButtonIsReadable(context: context) else { return nil }
218
+ let started = currentUptimeMs()
219
+ let lookup = stillNavigationBarBackButton(
220
+ app: app,
221
+ geometry: context.geometry,
222
+ deadlineMs: started + Self.navigationBarBackReadBudgetMs
223
+ )
224
+ trace.lookupMs = currentUptimeMs() - started
225
+ let before: NavigationBarBackState
226
+ let frame: CGRect
227
+ switch lookup {
228
+ case .still(let state, let button):
229
+ before = state
230
+ frame = button
231
+ case .notFound(let found):
232
+ trace.found = found
233
+ return nil
234
+ case .hung:
235
+ trace.found = "hung"
236
+ return .refused(Self.navigationBarBackHungLookup)
237
+ }
238
+ trace.found = "yes"
239
+
240
+
241
+
242
+ switch try performSynthesizedTapGesture(app: app, x: frame.midX, y: frame.midY, context: context) {
243
+ case .performed:
244
+ break
245
+ case .xctestFallback:
246
+ _ = try performGesture(app) { try tapAt(app: app, x: frame.midX, y: frame.midY, context: context) }
247
+ case .refused:
248
+ return nil
249
+ }
250
+ trace.pressed = true
251
+ let tapped = currentUptimeMs()
252
+ let confirmation = navigationBarBackConfirmation(
253
+ app: app,
254
+ from: before,
255
+ windowHeight: context.geometry.windowOnScreen.rect.height,
256
+ deadlineMs: tapped + Self.navigationBarBackReadBudgetMs
257
+ )
258
+ trace.confirmMs = currentUptimeMs() - tapped
259
+ trace.confirmed = confirmation.logToken
260
+ switch confirmation {
261
+ case .changed: return .performed
262
+ case .unchanged: return .unconfirmed(Self.navigationBarBackUnverified)
263
+ case .hung: return .unconfirmed(Self.navigationBarBackHungConfirmation)
264
+ }
265
+ }
266
+
267
+
268
+ struct NavigationBarBackTrace {
269
+
270
+
271
+
272
+ var found = "skipped"
273
+ var pressed = false
274
+
275
+ var confirmed: String?
276
+ var lookupMs = 0.0
277
+ var confirmMs: Double?
278
+
279
+ var logLine: String {
280
+ func ms(_ value: Double?) -> String { value.map { String(Int($0.rounded())) } ?? "-" }
281
+ return [
282
+ "found=\(found)",
283
+ "pressed=\(pressed ? "yes" : "no")",
284
+ "confirmed=\(confirmed ?? "-")",
285
+ "lookupMs=\(ms(lookupMs))",
286
+ "confirmMs=\(ms(confirmMs))",
287
+ ].joined(separator: " ")
288
+ }
289
+ }
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+ struct NavigationBarBackState: Equatable {
304
+ var barCount: Int
305
+ let backButtonLabels: [String]
306
+ let backButtonFrames: [CGRect]
307
+ var barTitles: [String] = []
308
+
309
+ var hasUnlabeledBackButton: Bool { backButtonLabels.contains(where: \.isEmpty) }
310
+
311
+ func hasSameButtons(as other: NavigationBarBackState) -> Bool {
312
+ backButtonLabels == other.backButtonLabels && backButtonFrames == other.backButtonFrames
313
+ }
314
+
315
+
316
+
317
+ var canShowAPop: Bool { !hasUnlabeledBackButton || barTitles.contains { !$0.isEmpty } }
318
+ }
319
+
320
+
321
+
322
+
323
+
324
+
325
+ static func navigationBarBackPopped(from before: NavigationBarBackState, to after: NavigationBarBackState) -> Bool {
326
+ after.barCount != before.barCount || after.backButtonLabels != before.backButtonLabels
327
+ || after.barTitles != before.barTitles
328
+ }
329
+
330
+
331
+
332
+
333
+ static let navigationBarBackReadInterval: TimeInterval = 0.05
334
+ static let navigationBarBackReadBudgetMs = 1000.0
335
+
336
+ static let navigationBarBackUnverified = ErrorPayload(
337
+ code: RunnerWireErrorCode.backSwipeUnverified,
338
+ message: "back pressed the navigation bar back button, but the navigation bar's back buttons did not change within 1 s or on one more read after it. This is an unknown outcome.",
339
+ hint: "Take a snapshot to see where the app is."
340
+ )
341
+
342
+ static let navigationBarBackHungConfirmation = ErrorPayload(
343
+ code: RunnerWireErrorCode.backSwipeUnverified,
344
+ message: "back pressed the navigation bar back button, but an XCTest query on the navigation bar hung afterwards. This is an unknown outcome.",
345
+ hint: "Take a snapshot to see where the app is."
346
+ )
347
+
348
+ static let navigationBarBackHungLookup = ErrorPayload(
349
+ code: RunnerWireErrorCode.backSwipeNotDispatched,
350
+ message: "back sent nothing: an XCTest query on the navigation bar hung before the back button or the swipe.",
351
+ hint: "Take a snapshot to check that the app responds, then retry back."
352
+ )
353
+
354
+
355
+
356
+ enum NavigationBarBackLookup {
357
+ case still(NavigationBarBackState, button: CGRect)
358
+ case notFound(String)
359
+ case hung
360
+ }
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+ @MainActor
370
+ private func stillNavigationBarBackButton(
371
+ app: XCUIApplication,
372
+ geometry: SurfaceGeometry,
373
+ deadlineMs: Double
374
+ ) -> NavigationBarBackLookup {
375
+ let windowHeight = geometry.windowOnScreen.rect.height
376
+ var previous: NavigationBarBackState?
377
+ var barsRead: (state: NavigationBarBackState, bars: [NavigationBarSnapshot])?
378
+ while true {
379
+ let sample: NavigationBarBackSample
380
+ switch readNavigationBarBack(
381
+ app: app, phase: .lookup, deadlineMs: deadlineMs, windowHeight: windowHeight, knownBars: barsRead?.bars
382
+ ) {
383
+ case .hung: return .hung
384
+ case .unreadable: return .notFound("unreadable")
385
+ case .read(let read): sample = read
386
+ }
387
+ let candidates = sample.candidates(by: sample.bars)
388
+ if candidates.isEmpty { return .notFound("no") }
389
+ let current = sample.state(of: candidates, bars: nil)
390
+ let buttonsStill = previous.map { current.hasSameButtons(as: $0) } ?? false
391
+ if sample.barsWereRead {
392
+ barsRead = (sample.state(of: candidates, bars: sample.bars), sample.bars)
393
+ } else if !buttonsStill {
394
+ barsRead = nil
395
+ }
396
+ if buttonsStill, let barsBefore = barsRead?.state {
397
+
398
+ let liveDeadlineMs = currentUptimeMs() + Self.navigationBarBackReadBudgetMs
399
+ switch liveNavigationBarBackButton(of: sample, geometry: geometry, deadlineMs: liveDeadlineMs) {
400
+ case .hung: return .hung
401
+ case .unreadable: return .notFound("unreadable")
402
+ case .read(.absent(let found)): return .notFound(found)
403
+ case .read(.found(let state, let button, let bars)):
404
+ if state == barsBefore { return .still(state, button: button) }
405
+ barsRead = (state, bars)
406
+ case .read(.moving): break
407
+ }
408
+ }
409
+ if currentUptimeMs() >= deadlineMs { return .notFound("moving") }
410
+ previous = current
411
+ sleepFor(Self.navigationBarBackReadInterval)
412
+ }
413
+ }
414
+
415
+
416
+ enum NavigationBarBackLive {
417
+ case found(NavigationBarBackState, CGRect, [NavigationBarSnapshot])
418
+ case absent(String)
419
+ case moving
420
+ }
421
+
422
+
423
+
424
+ @MainActor
425
+ private func liveNavigationBarBackButton(
426
+ of sample: NavigationBarBackSample,
427
+ geometry: SurfaceGeometry,
428
+ deadlineMs: Double
429
+ ) -> NavigationBarBackRead<NavigationBarBackLive> {
430
+ heldNavigationBarRead(.lookup) {
431
+ let bars = sample.roots.flatMap { $0.descendants(matching: .navigationBar).allElementsBoundByIndex }
432
+ guard let snapshots = barSnapshots(bars, deadlineMs: deadlineMs) else { return nil }
433
+ let candidates = sample.candidates(by: snapshots)
434
+ let hittable = candidates.filter { sample.buttons[$0].isHittable }
435
+ if hittable.isEmpty { return .absent("no") }
436
+ if hittable.count > 1 { return .absent("ambiguous") }
437
+ let button = sample.buttons[hittable[0]].frame
438
+ guard SnapshotGeometry.isPositiveFinite(button) else { return nil }
439
+ let state = sample.state(of: candidates, bars: snapshots)
440
+ if !state.canShowAPop { return .absent("unprovable") }
441
+ return Self.navigationBarBackState(state, holdsButton: button, geometry: geometry)
442
+ ? .found(state, button, snapshots) : .moving
443
+ }
444
+ }
445
+
446
+
447
+
448
+ static func navigationBarBackState(
449
+ _ state: NavigationBarBackState,
450
+ holdsButton button: CGRect,
451
+ geometry: SurfaceGeometry
452
+ ) -> Bool {
453
+ state.backButtonFrames.contains { frame in
454
+ let origin = geometry.screenPoint(from: SurfacePoint<WindowContentSpace>(frame.origin)).point
455
+ return CGRect(origin: origin, size: frame.size) == button
456
+ }
457
+ }
458
+
459
+ enum NavigationBarBackConfirmation {
460
+ case changed
461
+ case unchanged
462
+ case hung
463
+
464
+ var logToken: String {
465
+ switch self {
466
+ case .changed: return "yes"
467
+ case .unchanged: return "no"
468
+ case .hung: return "hung"
469
+ }
470
+ }
471
+ }
472
+
473
+
474
+
475
+
476
+
477
+
478
+ @MainActor
479
+ private func navigationBarBackConfirmation(
480
+ app: XCUIApplication,
481
+ from before: NavigationBarBackState,
482
+ windowHeight: CGFloat,
483
+ deadlineMs: Double
484
+ ) -> NavigationBarBackConfirmation {
485
+ while true {
486
+ let isFinalRead = currentUptimeMs() >= deadlineMs
487
+ let readDeadlineMs = isFinalRead ? Double.infinity : deadlineMs
488
+ let phase: NavigationBarBackReadPhase = isFinalRead ? .finalConfirmation : .confirmation
489
+ switch readNavigationBarBack(
490
+ app: app, phase: phase, deadlineMs: readDeadlineMs, windowHeight: windowHeight, knownBars: nil
491
+ ) {
492
+ case .read(let after)
493
+ where Self.navigationBarBackPopped(
494
+ from: before, to: after.state(of: after.candidates(by: after.bars), bars: after.bars)
495
+ ):
496
+ return .changed
497
+ case .hung: return .hung
498
+ case .read, .unreadable: break
499
+ }
500
+ if isFinalRead { return .unchanged }
501
+ sleepFor(min(Self.navigationBarBackReadInterval, max(0, deadlineMs - currentUptimeMs()) / 1000))
502
+ }
503
+ }
504
+
505
+ @MainActor
506
+ private func navigationBarBackButtonIsReadable(context: SynthesizedCoordinateContext) -> Bool {
507
+ guard !context.treeUnreadable, context.accessibilityHealth != .unavailable else { return false }
508
+ return !isSnapshotXCTestChannelPenalized(bundleId: mainOwned.bundleId)
509
+ }
510
+
511
+
512
+
513
+ enum NavigationBarBackReadPhase {
514
+ case lookup
515
+ case confirmation
516
+ case finalConfirmation
517
+ }
518
+
519
+
520
+ enum NavigationBarBackRead<Value> {
521
+ case read(Value)
522
+ case unreadable
523
+ case hung
524
+ }
525
+
526
+
527
+
528
+
529
+ @MainActor
530
+ private func heldNavigationBarRead<T>(_ phase: NavigationBarBackReadPhase, _ read: () -> T?) -> NavigationBarBackRead<T> {
531
+ var value: T?
532
+ let held = holdingRecordedIssues {
533
+ value = read()
534
+
535
+
536
+
537
+
538
+
539
+ }
540
+ let hung = held.issues.filter { Self.isHungQueryIssueDescription($0.compactDescription) }
541
+ hung.forEach { record($0) }
542
+ if !hung.isEmpty { return .hung }
543
+ guard held.issues.isEmpty, held.exceptionMessage == nil, let value else { return .unreadable }
544
+ return .read(value)
545
+ }
546
+
547
+
548
+
549
+
550
+ struct NavigationBarBackSample {
551
+ let buttons: [XCUIElement]
552
+ let labels: [String]
553
+
554
+ let frames: [CGRect]
555
+ let roots: [XCUIElement]
556
+ let bars: [NavigationBarSnapshot]
557
+ let barsWereRead: Bool
558
+ let windowHeight: CGFloat
559
+
560
+ func candidates(by bars: [NavigationBarSnapshot]) -> [Int] {
561
+ RunnerTests.backButtonCandidates(frames, barFrames: bars.map(\.frame), windowHeight: windowHeight)
562
+ }
563
+
564
+
565
+ func state(of candidates: [Int], bars: [NavigationBarSnapshot]?) -> NavigationBarBackState {
566
+ let state = NavigationBarBackState(
567
+ barCount: 0, backButtonLabels: candidates.map { labels[$0] }, backButtonFrames: candidates.map { frames[$0] })
568
+ return bars.map { RunnerTests.addingBars($0, to: state) } ?? state
156
569
  }
570
+ }
571
+
572
+
573
+
574
+
575
+
576
+ @MainActor
577
+ private func readNavigationBarBack(
578
+ app: XCUIApplication,
579
+ phase: NavigationBarBackReadPhase,
580
+ deadlineMs: Double,
581
+ windowHeight: CGFloat,
582
+ knownBars: [NavigationBarSnapshot]?
583
+ ) -> NavigationBarBackRead<NavigationBarBackSample> {
584
+ guard currentUptimeMs() < deadlineMs else { return .unreadable }
585
+ return heldNavigationBarRead(phase) {
586
+ guard let roots = try? elementSearchRoots(root: app, litDisplayID: requestLitPanel?.displayID) else { return nil }
587
+ let buttons = roots.flatMap {
588
+ $0.descendants(matching: .button).matching(identifier: Self.navigationBarBackButtonIdentifier).allElementsBoundByIndex
589
+ }
590
+ var labels: [String] = []
591
+ var frames: [CGRect] = []
592
+ for button in buttons {
593
+ guard currentUptimeMs() < deadlineMs, let snapshot = try? button.snapshot() else { return nil }
594
+ labels.append(snapshot.label)
595
+ frames.append(snapshot.frame)
596
+ }
597
+ var bars = knownBars
598
+ if bars == nil {
599
+ let elements = roots.flatMap { $0.descendants(matching: .navigationBar).allElementsBoundByIndex }
600
+ bars = barSnapshots(elements, deadlineMs: deadlineMs)
601
+ }
602
+ guard let bars else { return nil }
603
+ return NavigationBarBackSample(
604
+ buttons: buttons, labels: labels, frames: frames, roots: roots, bars: bars,
605
+ barsWereRead: knownBars == nil, windowHeight: windowHeight
606
+ )
607
+ }
608
+ }
609
+
610
+
611
+
612
+
613
+
614
+
615
+ static func backButtonBelongsToABar(_ button: CGRect, barFrames: [CGRect], windowHeight: CGFloat) -> Bool {
616
+ barFrames.contains { bar in
617
+ button.midX >= bar.minX && button.midX <= bar.maxX
618
+ && button.minY >= bar.minY && button.minY <= bar.minY + windowHeight / 3
619
+ }
620
+ }
621
+
622
+
623
+
624
+
625
+
626
+
627
+ static func backButtonCandidates(_ frames: [CGRect], barFrames: [CGRect], windowHeight: CGFloat) -> [Int] {
628
+ let inside = frames.indices.filter { index in
629
+ barFrames.contains { $0.contains(CGPoint(x: frames[index].midX, y: frames[index].midY)) }
630
+ }
631
+ if !inside.isEmpty { return inside }
632
+ return frames.indices.filter {
633
+ backButtonBelongsToABar(frames[$0], barFrames: barFrames, windowHeight: windowHeight)
634
+ }
635
+ }
636
+
637
+ struct NavigationBarSnapshot {
638
+ let frame: CGRect
639
+
640
+ let title: String
641
+ }
642
+
643
+
644
+ func barSnapshots(_ bars: [XCUIElement], deadlineMs: Double) -> [NavigationBarSnapshot]? {
645
+ var snapshots: [NavigationBarSnapshot] = []
646
+ for bar in bars {
647
+ guard currentUptimeMs() < deadlineMs, let snapshot = try? bar.snapshot() else { return nil }
648
+ snapshots.append(
649
+ NavigationBarSnapshot(frame: snapshot.frame, title: snapshot.identifier.isEmpty ? snapshot.label : snapshot.identifier))
650
+ }
651
+ return snapshots
652
+ }
653
+
654
+
655
+ static func addingBars(_ bars: [NavigationBarSnapshot], to state: NavigationBarBackState) -> NavigationBarBackState {
656
+ var state = state
657
+ state.barCount = bars.count
658
+ if state.hasUnlabeledBackButton { state.barTitles = bars.map(\.title) }
659
+ return state
660
+ }
661
+
662
+ @MainActor
663
+ private func verifiedBackSwipe(
664
+ app: XCUIApplication,
665
+ context: SynthesizedCoordinateContext,
666
+ trace: inout BackSwipeTrace
667
+ ) throws -> InAppBackOutcome {
668
+
157
669
 
158
670
  let dispatchGesture: @MainActor () throws -> TouchDispatch
159
671
  switch try prepareBackGesture(app: app, context: context) {
@@ -161,25 +673,19 @@ extension RunnerTests {
161
673
  case .notSent(let message, let hint):
162
674
  return .refused(ErrorPayload(code: RunnerWireErrorCode.backSwipeNotDispatched, message: message, hint: hint))
163
675
  }
164
-
165
- let justBefore: Data
166
- switch timedBackCapture(app: app, context: context, trace: &trace) {
167
- case .success(let sample): justBefore = sample
676
+ let before: SettledBackSample
677
+ switch settledBackVisualState(app: app, context: context, trace: &trace) {
678
+ case .success(let settled): before = settled
168
679
  case .failure(let refusal): return .refused(Self.backScreenRefusal(refusal))
169
680
  }
170
- let justBeforeMs = currentUptimeMs()
681
+ let justBeforeMs = before.sampledMs
171
682
  trace.stableMs = justBeforeMs - before.stableSinceMs
172
- let stillSettled = Self.backSwipeBaselineHolds(
173
- settled: before.settled,
174
- baseline: before.sample,
175
- justBefore: justBefore
176
- )
177
683
  let dispatch = try dispatchGesture()
178
684
  trace.gestureMs = currentUptimeMs() - justBeforeMs
179
685
  if let refusal = Self.backGestureRefusal(dispatch) {
180
686
  return refusal
181
687
  }
182
- guard stillSettled else {
688
+ guard before.settled else {
183
689
  return .unconfirmed(
184
690
  Self.backSwipeUnverified(
185
691
  because: "the app's screen was already changing on its own",
@@ -191,7 +697,7 @@ extension RunnerTests {
191
697
  let after = timedBackCapture(app: app, context: context, trace: &trace)
192
698
  let afterMs = currentUptimeMs()
193
699
  trace.justBeforeToAfterMs = afterMs - justBeforeMs
194
- let observation = Self.navigationVisualObservation(before: .success(justBefore), after: after)
700
+ let observation = Self.navigationVisualObservation(before: .success(before.sample), after: after)
195
701
  trace.changed = observation
196
702
  guard Self.backSwipeGapIsCovered(
197
703
  stableSinceMs: before.stableSinceMs,
@@ -247,38 +753,55 @@ extension RunnerTests {
247
753
  )
248
754
  }
249
755
 
756
+
757
+
758
+
759
+ static let macOSInAppBackControlRefusal = ErrorPayload(
760
+ code: RunnerWireErrorCode.inAppBackControlUnavailable,
761
+ message: "in-app back control is not available",
762
+ hint: "Press the app's visible back control by its ref."
763
+ )
764
+
250
765
  #if os(iOS)
251
766
 
252
767
 
768
+ struct SettledBackSample {
769
+ let sample: Data
770
+ let stableSinceMs: Double
771
+ let sampledMs: Double
772
+ let settled: Bool
773
+ }
774
+
775
+
776
+
253
777
 
254
778
  @MainActor
255
779
  private func settledBackVisualState(
256
780
  app: XCUIApplication,
257
781
  context: SynthesizedCoordinateContext,
258
782
  trace: inout BackSwipeTrace
259
- ) -> Result<(sample: Data, stableSinceMs: Double, settled: Bool), RunnerAppScreenCaptureFailure> {
783
+ ) -> Result<SettledBackSample, RunnerAppScreenCaptureFailure> {
784
+ let started = currentUptimeMs()
260
785
  var runStart: (sample: Data, ms: Double)?
261
- var last = Data()
262
- for index in 0..<Self.backSwipeSettleSampleBudget {
263
- if index > 0 { sleepFor(Self.backSwipeVerificationDelay) }
264
- trace.settleSamples = index + 1
786
+ while true {
787
+ if trace.settleSamples > 0 { sleepFor(Self.backSwipeSettleSampleInterval) }
788
+ trace.settleSamples += 1
789
+ let sample: Data
265
790
  switch timedBackCapture(app: app, context: context, trace: &trace) {
266
- case .failure(let refusal):
267
- return .failure(refusal)
268
- case .success(let sample):
269
- let now = currentUptimeMs()
270
- last = sample
271
- guard let start = runStart, !Self.visualSamplesDiffer(start.sample, sample) else {
272
- runStart = (sample, now)
273
- continue
274
- }
275
- if now - start.ms >= Self.backSwipeRequiredStillMs(maxCaptureMs: trace.maxCaptureMs) {
276
- trace.settled = true
277
- return .success((sample, start.ms, true))
278
- }
791
+ case .failure(let refusal): return .failure(refusal)
792
+ case .success(let captured): sample = captured
793
+ }
794
+ let now = currentUptimeMs()
795
+ let start = runStart.flatMap { Self.visualSamplesDiffer($0.sample, sample) ? nil : $0 } ?? (sample: sample, ms: now)
796
+ runStart = start
797
+ if now - start.ms >= Self.backSwipeRequiredStillMs(maxCaptureMs: trace.maxCaptureMs) {
798
+ trace.settled = true
799
+ return .success(SettledBackSample(sample: sample, stableSinceMs: start.ms, sampledMs: now, settled: true))
800
+ }
801
+ if now - started >= Self.backSwipeSettleBudgetMs(maxCaptureMs: trace.maxCaptureMs) {
802
+ return .success(SettledBackSample(sample: sample, stableSinceMs: start.ms, sampledMs: now, settled: false))
279
803
  }
280
804
  }
281
- return .success((last, runStart?.ms ?? currentUptimeMs(), false))
282
805
  }
283
806
  #endif
284
807
 
@@ -370,12 +893,6 @@ extension RunnerTests {
370
893
 
371
894
 
372
895
 
373
- static func backSwipeBaselineHolds(settled: Bool, baseline: Data, justBefore: Data) -> Bool {
374
- settled && !visualSamplesDiffer(baseline, justBefore)
375
- }
376
-
377
-
378
-
379
896
  static func backSwipeOutcome(observation: NavigationVisualObservation) -> InAppBackOutcome {
380
897
  switch observation {
381
898
  case .changed: