Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f1e3508
feat(apple-runner): build the XCUITest runner for the watchOS simulator
thymikee Nov 19, 2026
7f0d8dc
feat(apple): admit watchOS simulators through one watch fact leaf
thymikee Nov 19, 2026
d1e5e1e
docs: document watchOS simulators and amend ADR 0009
thymikee Nov 19, 2026
02d59df
fix(apple): harden the watchOS runner paths and watch classification
thymikee Nov 19, 2026
649f61b
fix(apple): keep the snapshot-presentation manifests on SwiftPM's wat…
thymikee Nov 19, 2026
1f3c8ca
fix(command-surface): keep the watchOS scroll note in CLI help only
thymikee Nov 19, 2026
0f87fee
fix(apple): bind only the operations a watch admits
thymikee Nov 19, 2026
be30bda
fix(apple): apply the watch admission to the runner seam and correct …
thymikee Nov 19, 2026
e852f0b
ci(apple): compile the watchOS runner on runner-owning PRs
thymikee Nov 19, 2026
7a133ca
fix(apple): refuse an undispatched watch back tap and test the runner…
thymikee Nov 19, 2026
4141dd9
fix(apple): bound the idle wait of the watchOS edge-swipe drags
thymikee Nov 19, 2026
25a0267
fix(apple): verify the watchOS back swipe and the input sheet commit
thymikee Nov 19, 2026
9591e88
fix(apple): compare the watchOS screen by structure when verifying back
thymikee Nov 19, 2026
6806bc1
fix(apple): drop the watchOS back edge-swipe fallback
thymikee Nov 19, 2026
03b1dbb
fix(apple): refuse watch typing when the field tap was not dispatched
thymikee Nov 19, 2026
f1b2791
fix(apple-runner): press the watchOS Digital Crown without bringing t…
thymikee Nov 19, 2026
485ab86
fix(apple-runner): keep watchOS hardware presses on the presented sur…
thymikee Nov 19, 2026
ac8d720
fix(apple-runner): name Apple Watch Ultra in the watchOS action-butto…
thymikee Nov 19, 2026
47676bf
fix(apple-runner): confirm the watchOS back-button press changed the …
thymikee Nov 19, 2026
4ae2e56
refactor(apple-runner): share synthesized sample dispatch with iOS an…
thymikee Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,23 @@ jobs:
run: test "$RESULT" = success

# PR-time compile guard for the runner platforms the smoke lanes never build. The iOS and
# macOS runners are compiled by smoke-apple-platform above, but tvOS and visionOS compiled
# only at release time (scripts/build-package-xcuitest.mjs), which let #4608 escape to
# release. This job runs the same xcodebuild build-for-testing compile for those two
# macOS runners are compiled by smoke-apple-platform above, but tvOS, visionOS, and watchOS
# compiled only at release time (scripts/build-package-xcuitest.mjs), which let #4608 escape
# to release. This job runs the same xcodebuild build-for-testing compile for those three
# platforms, on the same PRs that own the runner sources, so a build break that only the
# release would have caught fails the PR instead.
build-runner-tvos-visionos:
name: Runner Build (tvOS + visionOS)
build-runner-tvos-visionos-watchos:
name: Runner Build (tvOS + visionOS + watchOS)
if: ${{ !github.event.pull_request.draft }}
# Same image as the smoke lane's runner build; its Xcode ships the tvOS and visionOS SDKs
# Same image as the smoke lane's runner build; its Xcode ships the tvOS, visionOS, and watchOS SDKs
# alongside iOS, so no separate image or toolchain selection is needed.
runs-on: blacksmith-6vcpu-macos-26
timeout-minutes: 60
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
TVOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/tvos-runner-derived
VISIONOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/visionos-runner-derived
WATCHOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/watchos-runner-derived
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
Expand All @@ -310,11 +311,11 @@ jobs:
# The same selector the iOS runner build rides on (scripts/device-lane-impact.ts over the
# affected-check model): the job pays macOS minutes only on PRs that own the runner build
# sources (apple/runner/** and the other own:swift trees), and fails open when the change
# set cannot be established. Pushes to main run both builds unconditionally.
- name: Select tvOS/visionOS runner builds
# set cannot be established. Pushes to main run every build unconditionally.
- name: Select tvOS/visionOS/watchOS runner builds
id: runner-impact
shell: bash
run: node --experimental-strip-types scripts/device-lane-impact.ts swift-runner-tvos swift-runner-visionos
run: node --experimental-strip-types scripts/device-lane-impact.ts swift-runner-tvos swift-runner-visionos swift-runner-watchos
# One build per platform, mirroring the iOS runner build step: separate DerivedData and
# cache key per platform, generic simulator destinations so no device or runtime boot is
# needed, and the release package build's variant (no unit-test flag), which is the
Expand Down Expand Up @@ -345,3 +346,16 @@ jobs:
xcuitest-destination: generic/platform=visionOS Simulator
env:
AGENT_DEVICE_XCUITEST_ARCHS: arm64

- name: Restore and build watchOS XCTest runner
if: ${{ !cancelled() && steps.runner-impact.outputs.run != 'false' }}
uses: ./.github/actions/setup-apple-runner-build
with:
derived-path: ${{ env.WATCHOS_DERIVED_PATH }}
cache-key-prefix: watchos-runner-prebuilt
cache-key-suffix: -watchos-arm64
gate: swift-runner-watchos
xcuitest-platform: watchos
xcuitest-destination: generic/platform=watchOS Simulator
env:
AGENT_DEVICE_XCUITEST_ARCHS: arm64
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AgentDeviceRunner/Info.plist;
"INFOPLIST_FILE[sdk=macosx*]" = "";
"INFOPLIST_FILE[sdk=watchsimulator*]" = "";
"INFOPLIST_KEY_WKApplication[sdk=watchsimulator*]" = YES;
"INFOPLIST_KEY_WKWatchOnly[sdk=watchsimulator*]" = YES;
// The SwiftUI watch host replaces the Objective-C UIKit host on watchOS only.
EXCLUDED_SOURCE_FILE_NAMES = AgentDeviceRunnerWatchApp.swift;
"EXCLUDED_SOURCE_FILE_NAMES[sdk=watchsimulator*]" = "";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = NO;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -387,9 +393,10 @@
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,7";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator watchsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 15.6;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
Expand All @@ -403,6 +410,12 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AgentDeviceRunner/Info.plist;
"INFOPLIST_FILE[sdk=macosx*]" = "";
"INFOPLIST_FILE[sdk=watchsimulator*]" = "";
"INFOPLIST_KEY_WKApplication[sdk=watchsimulator*]" = YES;
"INFOPLIST_KEY_WKWatchOnly[sdk=watchsimulator*]" = YES;
// The SwiftUI watch host replaces the Objective-C UIKit host on watchOS only.
EXCLUDED_SOURCE_FILE_NAMES = AgentDeviceRunnerWatchApp.swift;
"EXCLUDED_SOURCE_FILE_NAMES[sdk=watchsimulator*]" = "";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = NO;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -423,9 +436,10 @@
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,7";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator watchsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 15.6;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
};
Expand Down Expand Up @@ -456,9 +470,10 @@
SWIFT_OBJC_BRIDGING_HEADER = "AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h";
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,7";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator watchsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 15.6;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
TEST_TARGET_NAME = AgentDeviceRunner;
};
name = Debug;
Expand Down Expand Up @@ -487,9 +502,10 @@
SWIFT_OBJC_BRIDGING_HEADER = "AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h";
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,7";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator watchsimulator";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 15.6;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
TEST_TARGET_NAME = AgentDeviceRunner;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ int main(int argc, const char *argv[]) {
return 0;
}

#else
// watchOS has no UIApplicationMain. Its host is AgentDeviceRunnerWatchApp.swift.
#elif !TARGET_OS_WATCH
#import "AgentDeviceRunnerApp.h"
#import <UIKit/UIKit.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import SwiftUI

/// The watchOS host the runner's XCTest bundle launches. The runner drives other apps by bundle ID,
/// so the host shows only its title, like the UIKit host on the other Apple OSes.
@main
struct AgentDeviceRunnerWatchApp: App {
var body: some Scene {
WindowGroup {
Text("Agent Device Runner")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,16 @@ extension RunnerTests {
return .context(ActiveCommandContext(app: mainOwned.app ?? app))
case .presentedSurface:
// The command is about the surface that already has focus; activating an app under it would
// cancel exactly what the command is about.
#if os(iOS)
// cancel exactly what the command is about. On watchOS that surface is often the watch face or
// the app grid a Digital Crown press left.
#if os(iOS) || os(watchOS)
return .context(ActiveCommandContext(app: resolveAppWithoutActivation(command: command)))
#else
// The platform exception, written once: `SystemSurfaceHostRegistry` registers no hosts off iOS,
// so nothing is ever served in place there and such a command keeps the activation route this
// axis found it on. The host never sends either command here on macOS — `alert` answers through
// the helper and `action-button` is refused by its owner fact before dispatch — so off iOS this
// route is reached only by the tvOS and visionOS runners.
// The platform exception, written once: `SystemSurfaceHostRegistry` registers no hosts on tvOS,
// visionOS, or macOS, so nothing is ever served in place there and such a command keeps the
// activation route this axis found it on. The host never sends either command here on macOS —
// `alert` answers through the helper and `action-button` is refused by its owner fact before
// dispatch — so this route is reached only by the tvOS and visionOS runners.
return prepareActivatedTarget(command: command)
#endif
case .existingApp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ extension RunnerTests {
else {
return invalidScrollDirectionResponse(commandName: "scroll")
}
#if os(watchOS)
return try watchCrownScroll(app: activeApp, command: command, direction: direction)
#endif
guard let scrollContext = try synthesizedCoordinateContext(app: activeApp) else {
return Response(
ok: false,
Expand Down Expand Up @@ -576,7 +579,7 @@ extension RunnerTests {
error: ErrorPayload(
code: RunnerWireErrorCode.hardwareControlUnavailable,
message: "actionButton requires a device model with an Action Button",
hint: "The Action Button is on iPhone 15 Pro and later and iPad Pro (M4) and later. Assign a Shortcut or App Intent to it in Settings > Action Button."
hint: Self.actionButtonUnavailableHint
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ extension RunnerTests {
#endif
}

#if os(watchOS)
static let actionButtonUnavailableHint = "The Action Button is on Apple Watch Ultra. Open an Apple Watch Ultra simulator."
#else
static let actionButtonUnavailableHint = "The Action Button is on iPhone 15 Pro and later and iPad Pro (M4) and later. Assign a Shortcut or App Intent to it in Settings > Action Button."
#endif

/// Presses the iPhone Action Button, returning false when this device cannot express the press.
///
/// `XCUIDevice.press(_:)` has no hold-duration overload, so a single press is the whole gesture
Expand All @@ -251,8 +257,8 @@ extension RunnerTests {
/// lower, so an older system refuses rather than pressing a control that cannot exist there.
Comment thread
thymikee marked this conversation as resolved.
Resolved
@discardableResult
func pressActionButton() -> Bool {
#if os(iOS)
guard #available(iOS 16.0, *) else { return false }
#if os(iOS) || os(watchOS)
guard #available(iOS 16.0, watchOS 9.0, *) else { return false }
guard XCUIDevice.shared.hasHardwareButton(.action) else { return false }
XCUIDevice.shared.press(.action)
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,17 @@ extension Command {
case .querySelector:
return .selectorResolution

case .mouseClick, .home, .recordStart, .activate:
// The watchOS Digital Crown press acts on whatever is on screen: from an app it shows the watch
// face, and from the face it opens the app grid. Like the other hardware presses, it must not
// bring the session app forward first.
case .home:
#if os(watchOS)
return .presentedSurfaceMutation
#else
return .appMutation
#endif

case .mouseClick, .recordStart, .activate:
return .appMutation
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ extension RunnerTests {
logSwipe(trace.logLine(name: "error", code: String(describing: type(of: error))))
throw error
}
#elseif os(watchOS)
return try performWatchBack(app: app)
#else
// visionOS has no back command. The daemon refuses it at the back capability fact, so this
// answers only a direct runner request, with nothing sent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension RunnerTests {
}

private func rotateDevice(to orientationName: String) -> String? {
#if os(macOS) || os(tvOS) || os(visionOS)
#if os(macOS) || os(tvOS) || os(visionOS) || os(watchOS)
return nil
#else
switch orientationName {
Expand All @@ -72,7 +72,7 @@ extension RunnerTests {
}

private func observedDeviceOrientation() -> String? {
#if os(macOS) || os(tvOS) || os(visionOS)
#if os(macOS) || os(tvOS) || os(visionOS) || os(watchOS)
return nil
#else
switch XCUIDevice.shared.orientation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ import CoreVideo
extension RunnerTests {
// MARK: - Screen Recorder

#if os(watchOS)
/// watchOS has no `AVAssetWriter`. The daemon refuses recording on a watch, so this answers only a
/// direct runner request.
final class ScreenRecorder {
init(outputPath: String, fps: Int32?) {}

func start(
bootstrap: () -> Result<CapturedAppScreen, RunnerAppScreenCaptureFailure>,
frame: @escaping @Sendable () -> RunnerImage?
) throws {
throw NSError(
domain: "AgentDeviceRunner.Record",
code: 2,
userInfo: [NSLocalizedDescriptionKey: "runner recording is unavailable on watchOS"]
)
}

func stop() throws {}
}
#else
final class ScreenRecorder {
private let outputPath: String
private let fps: Int32?
Expand Down Expand Up @@ -291,6 +311,7 @@ extension RunnerTests {
}

}
#endif
}

extension RunnerTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,12 @@ extension RunnerTests {
if plan.contactOrigin == runnerScreenEdgeContactOrigin {
return .screenEdgeTouch
}
#elseif os(watchOS)
// The watchOS sampled path starts a screen-edge contact on the edge itself; a fast coordinate
// drag would start inside the plan's in-content margin and reach a row instead.
if plan.contactOrigin == runnerScreenEdgeContactOrigin {
return .sampled(schedule: nil)
}
#endif
guard plan.topology == "single" else { return .sampled(schedule: nil) }
return plan.executionProfile == "endpoint-hold" ? .fastSwipe : .sampled(schedule: plan.executionProfile)
Expand Down Expand Up @@ -826,6 +832,32 @@ extension RunnerTests {
}
#endif

#if os(iOS) || os(watchOS)
/// Hands one planned gesture's `{ x, y, offsetMs }` pointer samples to the private synthesizer and
/// maps its result. The iOS and watchOS sampled paths differ only in how they build the samples.
@MainActor
func dispatchSynthesizedPointerSamples(
app: XCUIApplication,
window: XCUIElement?,
orientation: Int,
pointerSamples: [[[String: NSNumber]]]
) throws -> RunnerInteractionOutcome {
var dispatched: ObjCBool = false
let failure = RunnerSynthesizedGesture.synthesizeGesture(
withApplication: app,
resolvedWindow: window,
interfaceOrientation: orientation,
pointerSamples: pointerSamples,
dispatched: &dispatched
)
return try Self.synthesizedGestureOutcome(
failure: failure,
dispatched: dispatched.boolValue,
refusalHint: "This gesture uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists."
)
}
#endif

/// A synthesized gesture's result. A failure before its events reached XCTest sent nothing, so it
/// is a `.notDispatched` refusal, which a policy may still answer with an XCTest fallback. A failure
/// after may have run, so it throws `RunnerGestureOutcomeUnknown`, which no fallback repeats.
Expand Down Expand Up @@ -853,24 +885,19 @@ extension RunnerTests {
case .resolved(let resolved): planned = resolved
case .refused(let outcome): return outcome
}
var dispatched: ObjCBool = false
let failure = RunnerSynthesizedGesture.synthesizeGesture(
withApplication: app,
resolvedWindow: planned.context.resolvedWindow,
interfaceOrientation: planned.orientation,
pointerSamples: planned.pointerSamples,
dispatched: &dispatched
)
return try Self.synthesizedGestureOutcome(
failure: failure,
dispatched: dispatched.boolValue,
refusalHint: "This gesture uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists."
return try dispatchSynthesizedPointerSamples(
app: app,
window: planned.context.resolvedWindow,
orientation: planned.orientation,
pointerSamples: planned.pointerSamples
)
#elseif os(tvOS)
return .unsupported(
message: "multi-touch gestures are not supported on tvOS",
hint: "tvOS has no touch input; use remote-driven navigation."
)
#elseif os(watchOS)
return try watchSampledPlannedGesture(app: app, plan: plan)
#elseif os(visionOS)
return .unsupported(
message: "multi-touch gestures are not supported on visionOS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ extension RunnerTests {
guard let text = command.text else {
return Response(ok: false, error: ErrorPayload(message: "type requires text"))
}
#if os(watchOS)
return try watchTypeCommandResponse(activeApp: activeApp, command: command, text: text)
#endif
let delaySeconds = Double(max(command.delayMs ?? 0, 0)) / 1000.0
let textEntryMode = resolveTextEntryMode(command)
let target: TextEntryTarget
Expand Down
Loading
Loading