From 4dcbf9b45f343bb4dc82bcaf14fb121b5619c97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 16 Feb 2026 17:36:34 +0100 Subject: [PATCH 1/4] refactor: stabilize iOS app/session and daemon startup flows --- README.md | 17 +- .../RunnerTests.swift | 10 +- skills/agent-device/SKILL.md | 17 +- skills/agent-device/references/permissions.md | 9 +- .../references/session-management.md | 1 + src/__tests__/cli-close.test.ts | 139 +++++ src/cli.ts | 47 +- src/core/__tests__/capabilities.test.ts | 3 +- src/core/capabilities.ts | 2 +- src/daemon-client.ts | 131 ++++- src/daemon/__tests__/app-state.test.ts | 138 ----- src/daemon/__tests__/device-ready.test.ts | 52 ++ src/daemon/app-state.ts | 65 --- src/daemon/device-ready.ts | 152 +++++- src/daemon/handlers/__tests__/session.test.ts | 294 +++++++++++ src/daemon/handlers/session.ts | 267 ++++++---- src/daemon/session-store.ts | 2 - src/platforms/android/__tests__/index.test.ts | 116 ++++- src/platforms/android/index.ts | 118 +++-- src/platforms/ios/__tests__/index.test.ts | 40 +- .../ios/__tests__/runner-client.test.ts | 42 ++ src/platforms/ios/apps.ts | 309 ++++++++++++ src/platforms/ios/config.ts | 34 ++ src/platforms/ios/devicectl.ts | 131 +++++ src/platforms/ios/devices.ts | 21 +- src/platforms/ios/index.ts | 475 +----------------- src/platforms/ios/runner-client.ts | 87 +++- src/platforms/ios/simulator.ts | 164 ++++++ src/utils/__tests__/args.test.ts | 22 +- src/utils/__tests__/daemon-client.test.ts | 25 +- src/utils/args.ts | 7 +- src/utils/command-schema.ts | 19 +- test/integration/ios.test.ts | 10 + website/docs/docs/commands.md | 19 +- website/docs/docs/installation.md | 7 +- website/docs/docs/introduction.md | 5 +- website/docs/docs/sessions.md | 1 + 37 files changed, 2112 insertions(+), 886 deletions(-) create mode 100644 src/__tests__/cli-close.test.ts delete mode 100644 src/daemon/__tests__/app-state.test.ts create mode 100644 src/daemon/__tests__/device-ready.test.ts delete mode 100644 src/daemon/app-state.ts create mode 100644 src/platforms/ios/apps.ts create mode 100644 src/platforms/ios/config.ts create mode 100644 src/platforms/ios/devicectl.ts create mode 100644 src/platforms/ios/simulator.ts diff --git a/README.md b/README.md index 93474e687..0c4b0b027 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The project is in early development and considered experimental. Pull requests a ## Features - Platforms: iOS (simulator + physical device core automation) and Android (emulator + device). - Core commands: `open`, `back`, `home`, `app-switcher`, `press`, `long-press`, `focus`, `type`, `fill`, `scroll`, `scrollintoview`, `wait`, `alert`, `screenshot`, `close`, `reinstall`. -- Inspection commands: `snapshot` (accessibility tree). +- Inspection commands: `snapshot` (accessibility tree), `appstate`, `apps`, `devices`. - Device tooling: `adb` (Android), `simctl`/`devicectl` (iOS via Xcode). - Minimal dependencies; TypeScript executed directly on Node 22+ (no build step). @@ -148,6 +148,7 @@ Sessions: - `--save-script` accepts an optional path: `--save-script ./workflows/my-flow.ad`. - For ambiguous bare values, use an explicit form: `--save-script=workflow.ad` or a path-like value such as `./workflow.ad`. - Deterministic replay is `.ad`-based; use `replay --update` (`-u`) to update selector drift and rewrite the replay file in place. +- On iOS, `appstate` is session-scoped and requires an active session on the target device. Navigation helpers: - `boot --platform ios|android` ensures the target is ready without launching an app. @@ -217,8 +218,10 @@ Settings helpers: Note: iOS supports these only on simulators. iOS wifi/airplane toggles status bar indicators, not actual network state. Airplane off clears status bar overrides. App state: -- `appstate` shows the foreground app/activity (Android). On iOS it uses the current session app when available, otherwise it resolves via XCTest snapshot. -- `apps --metadata` returns app list with minimal metadata. +- `appstate` shows the foreground app/activity (Android). +- On iOS, `appstate` returns the currently tracked session app (`source: session`) and requires an active session on the selected device. +- `apps` supports Android, iOS simulators, and iOS devices. +- `apps` includes default/system apps by default (use `--user-installed` to filter). ## Debug @@ -227,6 +230,7 @@ App state: - The trace log includes snapshot logs and XCTest runner logs for the session. - Built-in retries cover transient runner connection failures and Android UI dumps. - For snapshot issues (missing elements), compare with `--raw` flag for unaltered output and scope with `-s "