Skip to content

fix(apple-runner): use the CoreDevice tunnel when usbmux lists a phone only by Wi-Fi sync - #5120

Merged
thymikee merged 2 commits into
mainfrom
t3/route-coredevice-network-commands
Nov 30, 2026
Merged

thymikee merged 2 commits into
mainfrom
t3/route-coredevice-network-commands

Conversation

@thymikee

@thymikee thymikee commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #4107. A CoreDevice-paired phone can appear in usbmuxd as a Network entry when Finder Wi-Fi sync is enabled. Main dials that entry even when the runner rejects the connection. Treat a Network-only match as unattached for CoreDevice phones so the existing tunnel route takes over. Cabled phones still prefer USB. Devices without CoreDevice can still use their Network entry.

Before / after

For a CoreDevice phone with Wi-Fi sync enabled and no USB cable, base dials the Network entry. Head skips that dial and uses the CoreDevice tunnel. A second user on an iPhone XR restored tap and fill by disabling Wi-Fi sync and unplugging USB.

Validation

  • At 912762c822, the focused usbmux suite passed 12/12. The new CoreDevice case failed on base 2d29b6d6e3 because it dialed the Network entry. A paired test confirms that devices without CoreDevice still dial it.
  • The worker also reported 996 Apple runner tests passing at 912762c822, plus repo guards, CLI help tests, lint, typecheck and XCTest selection.
  • At 3993f4e96d, all 24 help first-screen checks and 12 usbmux tests passed. GitHub validates this head.
  • AlexGodard’s iPhone 17 Pro field report confirmed wireless tap completion with Wi-Fi sync on using a hand-patched 0.21.33. On the PR head, tap and type completion over the tunnel and the same phone’s cabled USB control still need verification.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.73 MB 6.73 MB +803 B
Package (unpacked) 6.73 MB 6.73 MB +803 B
Package (download) 2.05 MB 2.05 MB +256 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.8 ms 19.6 ms -2.2 ms
CLI --help 46.3 ms 43.6 ms -2.7 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/apple-runner/src/__tests__/runner-usbmux.test.ts">

<violation number="1" location="packages/apple-runner/src/__tests__/runner-usbmux.test.ts:307">
P3: This test's title says it covers a tunnel fallback, but `xctestPhone` has no CoreDevice tunnel. Use `coreDevicePhone` here so the fixture matches the title, or rename the test to describe the xctest behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread website/docs/docs/commands.md Resolved
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 3993f4e, the code review found no code defect that must be fixed, but this device-facing route change has no run on a physical iPhone yet. Live evidence is required before merge.

The new route applies when Wi-Fi sync is on and usbmux lists the phone only as a Network entry. The control runs in #4107 had Wi-Fi sync off, so usbmuxd listed nothing. That leaves the goal of #4107, working taps and typing on a Wi-Fi iPhone with sync on, inferred and not observed. Please run this commit on a physical CoreDevice iPhone and report the device, iOS version, commands and exit codes. First, with Wi-Fi sync on and the cable unplugged, show that usbmuxd lists only the Network entry and that devicectl reports connected. Then run open, snapshot -i, press and fill, and include the runner.log COMPLETED lines for tap and type. Second, cable the same phone, show that both USB and Network entries are listed, and repeat the snapshot, tap and typing over USB.

Not blocking: these can be taken or left: the new hint, error detail, flag and helper appear never to reach a caller, because both callers drop that error when fallback is allowed (only a unit test reads the detail), so selectUsbmuxDevice could just skip unaccepted Network entries and emit a diagnostic if visibility is wanted; the "has a CoreDevice tunnel" rule, derived here, in canFallBackFromUsbmux and in the command route resolver, could be one named predicate beside IosPhysicalDeviceRunnerControl or the resolver, used wherever that backend check decides the route, with the #4107 rationale kept there once; the PR body's "The reporter restored tap and fill" could say "a second user on an iPhone XR", since that result came from another phone and iOS version, and the squash message could drop the first commit's "older tunnel route" explanation, which the base route resolver does not support while a Network entry is listed; and a follow-up issue could check an XCTest-backed phone with sync on, which is still dialed through its Network entry as before although the runner appears to close such direct network connections unless forwarding is configured, and if refused, reject Network entries for every locally launched runner and keep the existing unattached hint.

These earlier threads no longer apply and can be resolved: the test now matches its XCTest-backed fixture, and the docs and help text now say "USB (usbmux) when connected by cable".

All CI jobs pass at this commit, except Proof, which is skipped. A cancelled "Body rules" run was replaced by a passing one; it checks PR text and does not exercise the changed route.

Not verified here: any device run or local test, as this review is based on the code, diff, issue comments and CI status. Not verified here: that the CoreDevice tunnel serves taps while Wi-Fi sync is on, because the supporting runs had sync off or usbmuxd listing nothing. Not verified here: why the reporter's snapshots succeeded over the base route while taps failed. Not verified here: whether any devicectl-listed device, such as an older OS version or Apple TV, has a usable Network entry but no resolvable tunnel; such a device would now fail where the base dialed the entry. One existing limit also remains: if devicectl list fails and only xctrace finds the phone, it is treated as xctest and the Network entry is still dialed.

Before merge, a live Wi-Fi iPhone run at this commit with Wi-Fi sync on must show that tap and fill succeed, together with the cabled control run.

@AlexGodard

Copy link
Copy Markdown

Field report for this PR: Wi-Fi sync on, cable unplugged, a CoreDevice iPhone. One caveat up front: this is not a run of 3993f4e. It's the same route decision patched by hand into an installed 0.21.33, so it shows the tunnel serves taps with sync on. It doesn't cover the rest of the PR.

Setup

  • iPhone 17 Pro (iPhone18,1), iOS 27.0.1 (24A446); macOS 26.7.1 (25G241), Xcode 27.2 (27B52); agent-device 0.21.33 with an externally built runner (--ios-xctestrun-file).
  • usbmuxd ListDevices lists the phone once, ConnectionType: Network, with no USB entry.
  • devicectl: transportType: localNetwork, tunnelState: connected, pairingState: paired.

Unpatched (same as #4107)

  • Every snapshot -i worked. Every press, by ref, selector or coordinates, failed with lost its transport response.
  • Request log: the readiness probe connects, then ios_runner_command_send {"command":"tap","error":"socket hang up"} after 22–96 ms, then the status probe gets Runner did not accept connection.
  • Runner log: no COMMAND_ACCEPTED for the tap, only tcp_output [C3:1] flags=[R.] … state=CLOSED on the following connections.

Patch: in the usbmux ListDevices pick (runner-startup-transport.js in the 0.21.33 dist), return the matching entry only when it is USB, instead of falling back to the first Network entry. With no USB entry, the lookup throws DEVICE_NOT_FOUND, markUsbmuxUnattached fires, and resolveRoute goes to resolveTunnel. For a CoreDevice phone this is what acceptsNetworkEntry: backend === 'xctest' decides. Unlike the PR, it also skips Network entries for XCTest-backed phones, but none was involved here.

Patched: same phone, sync still on, daemon restarted. open com.apple.AppStore --foreground, snapshot -i, press @e13 --settle, then more snapshots, a coordinate press and a longpress, all on one runner with no restart. Runner log, local time:

21:00:56.985 COMMAND_COMPLETED command=snapshot ok=1
21:00:57.536 COMMAND_COMPLETED command=snapshot ok=1
21:01:02.941 COMMAND_ACCEPTED command=tap
21:01:04.190 COMMAND_COMPLETED command=tap ok=1
21:01:04.922 COMMAND_COMPLETED command=snapshot ok=1
… 5 more snapshots ok=1 …
21:01:35.805 COMMAND_ACCEPTED command=tap
21:01:36.991 COMMAND_COMPLETED command=tap ok=1
… 7 more snapshots ok=1 …
21:02:32.053 COMMAND_COMPLETED command=tap ok=1
21:02:55.021 COMMAND_COMPLETED command=longPress ok=1

Both taps landed:

  • The first, on the App Store's Get button, changed it to "Préparation du téléchargement" in the following snapshot.
  • The second, a coordinate tap on the install sheet's Install button, opened the next sheet.

The last tap and the long press hit the App Store's Apple Account password sheet. Both reported ok but changed nothing on screen. I'd guess that sheet refuses synthesized input, but I haven't confirmed that.

Not covered:

  • fill/typing (the phone was on that password sheet).
  • The cabled control run.
  • 3993f4e itself.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the field report. It is useful evidence for the route decision: with Wi-Fi sync on, the cable unplugged and usbmuxd listing only a Network entry, sending the phone to the CoreDevice tunnel turned failing taps into COMMAND_COMPLETED command=tap ok=1, on one runner with no restart. That answers the main open question from the review of 3993f4e: the tunnel does serve taps while sync is on.

The live evidence requirement is still open, because the report itself names what it does not cover:

  • a run of 3993f4e (or the final head), not a hand patch of 0.21.33, which also skipped Network entries for XCTest-backed phones;
  • fill or typing over the tunnel, with the COMPLETED command=type line;
  • the cabled control run on the same phone, with both USB and Network entries listed.

A run at the PR head that covers these closes the requirement.

@thymikee

Copy link
Copy Markdown
Member Author

@AlexGodard, would you be up for a paired run on the same iPhone 17 Pro using this PR at 3993f4e96d and your existing externally built runner? With Finder Wi-Fi sync on, could you run open, snapshot -i, press, and fill first unplugged with a Network-only usbmux entry and devicectl connected, then cabled with USB and Network entries? The exit codes and runner.log completion lines for tap and type in both runs would cover the remaining review request. Your patched-release trace already showed the wireless tap can reach the runner.

@thymikee

Copy link
Copy Markdown
Member Author

Paired physical run at 3993f4e96d12f261745f919d382171c9ba8e5148 on an iPhone 17 Pro, iOS 27.0.1, Xcode 27.1. I built the local CLI from the PR commit and used the same provisioned runner via --ios-xctestrun-file for both runs. Finder Wi-Fi sync was enabled.

Connection usbmuxd before and after CoreDevice open / snapshot / press / fill / final snapshot
Unplugged Network only localNetwork, tunnel connected 0 / 0 / 0 / 0 / 0
Cabled USB and Network wired, tunnel connected 0 / 0 / 0 / 0 / 0

The sequence opened Settings, ran snapshot -i, pressed Search, refreshed the refs, and filled the search field with Bluetooth. The final snapshot confirmed the value in both runs.

Runner log excerpts:

Network only · COMMAND_COMPLETED command=tap  ok=1
Network only · COMMAND_COMPLETED command=type ok=1
USB + Network · COMMAND_COMPLETED command=tap  ok=1
USB + Network · COMMAND_COMPLETED command=type ok=1

Two cabled setup attempts immediately after reconnecting stopped before snapshot with a runner listener Address already in use error. A separate signed runner passed the cabled sequence, and the final cabled run above also passed with the original runner. Both final sessions closed and their daemons stopped.

@thymikee

Copy link
Copy Markdown
Member Author

The paired physical run at 3993f4e covers the evidence the review asked for. On an iPhone 17 Pro (iOS 27.0.1) with Wi-Fi sync on, the run was done twice: unplugged with a Network-only usbmux entry and a connected CoreDevice tunnel, and cabled with both entries listed. Each run had open, snapshot -i, press and fill exit 0, runner.log showing COMMAND_COMPLETED for tap and type, and the filled value confirmed by a final snapshot. The required evidence is satisfied. The cabled Address already in use setup failures right after reconnecting come from the runner listener and fall outside this route change.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 29, 2026
@AlexGodard

Copy link
Copy Markdown

Thanks for running it on your side. Your paired run at 3993f4e covers both cases I'd have run, unplugged and cabled, with tap and type completing, so I won't add a duplicate. If the head changes before merge, I can rerun it on my phone.

…when usbmux lists only Wi-Fi sync

With Finder's "Show this iPhone when on Wi-Fi" on, usbmuxd lists the phone as a
Network entry. The route resolver preferred that entry over the CoreDevice
tunnel, and the runner's listener refuses connections arriving on the phone's
link-local Wi-Fi address, so snapshots that rode an older tunnel route kept
working while every tap and keystroke was refused before the command started.
Wi-Fi sync off restored press and fill, which named the entry as the cause.

Keep usbmux first for a cabled phone. For a CoreDevice-backed phone whose only
usbmux entry is Network, the transport now refuses to dial it and publishes the
same typed unattached verdict a missing entry publishes, so the command goes to
the CoreDevice tunnel through the existing fallback. A device with no CoreDevice
backend keeps its Network entry: usbmux is its only route.

Closes #4107
@thymikee
thymikee force-pushed the t3/route-coredevice-network-commands branch from 3993f4e to b5f43ec Compare November 30, 2026 11:58
@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 30, 2026
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of b5f43ec

Since the review of 3993f4e: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (021423b31fa9).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

No code problems were found at b5f43ec, and the required evidence is in place. The earlier review at 3993f4e also found none.

Both earlier threads are fixed and can be resolved: the test name now matches its XCTest-backed fixture, and the "cable entry" wording is gone from the docs.

The Smoke Tests (ios) failure is likely unrelated to this PR. In "Restore and build iOS XCTest runner", the message that follows a successful build was printed, then gate: unable to flush stdout: output drain timed out ended the step. The log shows no compile or isolation error, and this PR changes nothing under apple/, scripts/, .github/ or package.json. Smoke Tests fails only because it requires both Apple jobs to succeed. macOS smoke and the tvOS/visionOS/watchOS runner build pass.

Not verified here: the iOS simulator smoke scenarios have not run at this commit, and no device run or local tests were performed for this review. The physical device results (usbmux listings, exit codes, runner.log lines) come from the PR comment and were recorded at 3993f4e on the older base. They are carried forward because the route files are identical and the route did not change upstream. The newer Swift changes from main to tap preparation and post-snapshot stabilization were not exercised with this patch. An XCTest-backed phone with Wi-Fi sync on was not exercised either; its behavior matches the base. A new device run is not required for the unchanged route.

There is no code or evidence reason to hold the merge. Before merge, rerun the failed Smoke Tests (ios) job so that it and Smoke Tests pass.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 30, 2026
@thymikee
thymikee merged commit 4865d84 into main Nov 30, 2026
25 of 27 checks passed
@thymikee
thymikee deleted the t3/route-coredevice-network-commands branch November 30, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS physical device over Wi‑Fi: every tap fails with "lost its transport response" while snapshots work (USB works)

2 participants