Skip to content

Unreachable paired iOS device is listed as booted and passes boot #4209

Closed

Description

@gronxb

Environment

  • agent-device 0.21.36, and main at 035c2b6ca.
  • Xcode 27.2, macOS 27.0.1.
  • A paired iPhone on iOS 27.1, unplugged with Wi-Fi off. xcrun devicectl list devices shows it as unavailable.
  • Not a regression: the devicectl inventory has always reported physical devices as booted.

Description

agent-device devices lists a paired iPhone or iPad that CoreDevice cannot reach as booted: true. agent-device boot --udid <device> then succeeds on it. The first command that fails is the app launch:

COMMAND_FAILED: Failed to launch iOS app: The device is not able to fulfill the requested usage assertion requirements. (com.apple.dt.CoreDeviceError error 4016 (0xFB0))

CoreDevice already reports the state. xcrun devicectl list devices --json-output gives the device connectionProperties.tunnelState: "unavailable". xcrun devicectl device info details gives tunnelState: "unavailable" and bootState: null.

Clients that pick devices from devices send work to the device. For example, the e2e mobile engine gives a worker slot to every booted device, so the tests on that slot fail at launch (tester-army/e2e#1528).

Required behavior

  • devices lists a CoreDevice device whose tunnelState is unavailable with booted: false. The device stays in the list.

    { "platform": "ios", "id": "00008160-…", "kind": "device", "target": "mobile", "booted": false }
  • The readiness check refuses that device. boot, and every command that checks readiness, fail before they reach the device:

    {
      "code": "COMMAND_FAILED",
      "message": "iOS device is not ready for automation",
      "details": { "kind": "not_ready", "tunnelState": "unavailable", "hint": "…connect the device…" }
    }
  • A device whose tunnelState is connected, disconnected, or absent keeps booted: true and passes readiness. CoreDevice opens a tunnel on demand, so an idle device it can reach reports disconnected.

  • Simulators and XCTest-backed devices keep their current behavior.

Completion conditions

  • ./repro.sh from the repro branch exits 0 against the fix. Both cases pass.
  • Unit tests cover unavailable and its closest negatives, in the devicectl inventory mapping and in ensureCoreDeviceReady.

Dependencies

None.

Implementation notes

  • mapDevicectlAppleDevice (packages/platform-apple/src/inventory-classification.ts) sets booted: true for every devicectl device. Its input type already declares connectionProperties.tunnelState.
  • ensureCoreDeviceReady (packages/platform-apple/src/core/physical-device-coredevice.ts) refuses connecting and lets every other tunnel state through.
  • With no selector, the implicit choice ranks simulators ahead of physical devices (appleDeviceSelectionRank). So the bug mostly affects clients that read devices themselves, and commands that name the device.
  • devicectl marks hardwareProperties, deviceProperties, and connectionProperties as deprecated and replaces them with properties. The whole mapper reads the deprecated keys, so a move to properties.connection.state is a separate change.

Reproducible Demo

Runnable repro: gronxb/agent-device-repro@ios-unavailable-device. It needs Xcode and a paired physical device that xcrun devicectl list devices shows as unavailable.

git clone -b ios-unavailable-device https://github.com/gronxb/agent-device-repro.git
cd agent-device-repro
./repro.sh            # exit 1 while any case fails

With agent-device 0.21.36:

agent-device: 0.21.36
device: 00008160-XXXXXXXXXXXXXXXX, devicectl tunnelState=unavailable

FAIL  devices lists the unreachable device with booted: false
      booted: true
FAIL  boot refuses the unreachable device as not_ready
      succeeded: booted=true

Activity

  1. changed the title [-]iOS: a paired device CoreDevice cannot reach is listed as booted and passes boot[/-] [+]Unreachable paired iOS device is listed as booted and passes boot[/+] on Nov 4, 2026
  2. added
    bug
    on Nov 4, 2026
  3. thymikee commented on Nov 4, 2026

    @thymikee
    Member

    Triage: bug; actionable without more input from you. Confirmed on main: mapDevicectlAppleDevice (inventory-classification.ts) sets booted: true for every devicectl device, and ensureCoreDeviceReady refuses only tunnelState: connecting. An agent can pick this up as specified: unavailable lists as booted: false and fails readiness as not_ready, while connected, disconnected and an absent state keep today's behavior. Thanks for the repro branch.

  4. added a commit that references this issue on Nov 4, 2026
    0a9bb73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions