Skip to content

Commit 76b2ea2

Browse files
thymikeeclaude
andcommitted
refactor(ios): drop BACK_UNSUPPORTED_PLATFORM and the unused TouchDispatch refusal init, and refresh stale back docs
The daemon already refuses visionOS back at the capability fact, so the runner's visionOS arm answers only a direct request and goes back to BACK_SWIPE_NOT_DISPATCHED. PreparedTouch's refusal init is an exhaustive switch, so a new outcome case is a compile error to handle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 89811a4 commit 76b2ea2

7 files changed

Lines changed: 24 additions & 68 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ extension RunnerTests {
108108
self = dispatched ? .interrupted(message: failure, hint: nil) : .notSent(message: failure, hint: nil)
109109
}
110110

111-
/// A refusal raised before any touch: only `.unsupported` is one.
112-
init(notSent refusal: RunnerInteractionOutcome) {
113-
guard case .unsupported(let message, let hint) = refusal else {
114-
preconditionFailure("a performed gesture is not a refusal before dispatch")
115-
}
116-
self = .notSent(message: message, hint: hint)
117-
}
118111
}
119112

120113
/// A gesture resolved up to its touch, so the time between the sample taken just before it and its
@@ -123,12 +116,15 @@ extension RunnerTests {
123116
case ready(@MainActor () throws -> TouchDispatch)
124117
case notSent(message: String, hint: String?)
125118

126-
/// A refusal raised before any touch: only `.unsupported` is one.
119+
/// A refusal raised before any touch. The switch is exhaustive, so a new refusal case must be
120+
/// handled here at compile time instead of trapping at run time.
127121
init(notSent refusal: RunnerInteractionOutcome) {
128-
guard case .unsupported(let message, let hint) = refusal else {
122+
switch refusal {
123+
case .performed:
129124
preconditionFailure("a performed gesture is not a refusal before dispatch")
125+
case .unsupported(let message, let hint):
126+
self = .notSent(message: message, hint: hint)
130127
}
131-
self = .notSent(message: message, hint: hint)
132128
}
133129
}
134130

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ extension RunnerTests {
9696
throw error
9797
}
9898
#else
99-
// visionOS has no edge swipe that pops a navigation stack; the host refuses before dispatch.
100-
return .refused(Self.backUnsupportedPlatformRefusal)
99+
// visionOS has no edge swipe that pops a navigation stack. The daemon refuses it at the back
100+
// capability fact, so this answers only a direct runner request, with nothing sent.
101+
return .refused(
102+
ErrorPayload(
103+
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."
106+
)
107+
)
101108
#endif
102109
}
103110

104-
/// The visionOS back refusal, the same wire shape as every back code: code, message, and hint.
105-
static let backUnsupportedPlatformRefusal = ErrorPayload(
106-
code: RunnerWireErrorCode.backUnsupportedPlatform,
107-
message: "visionOS has no back gesture",
108-
hint: "iOS back is a left-edge swipe; visionOS has none. Press the visible back control by its ref."
109-
)
110-
111111
#if os(iOS)
112112
/// What one iOS back measured, logged as one line whatever it concluded, so a failure on a slow
113113
/// host can be read from the runner log.
@@ -282,10 +282,11 @@ extension RunnerTests {
282282
}
283283
#endif
284284

285-
/// The frame the swipe compares, below the status bar, as a coarse grayscale grid when the display
286-
/// answered and the typed refusal otherwise. It samples the app's own screen only: a system-surface
287-
/// capture reads as "unchanged" across a before/after pair and launders a wrong-process frame into
288-
/// a false refusal. The status bar changes on its own (the clock, signal, a recording indicator).
285+
/// The app's screen as a coarse grayscale grid when the display answered, and the typed refusal
286+
/// otherwise; the comparison leaves out the fixed top band (`backCompareTopRowsIgnored`), where the
287+
/// status bar changes on its own. It samples the app's own screen only: a system-surface capture
288+
/// reads as "unchanged" across a before/after pair and launders a wrong-process frame into a false
289+
/// refusal.
289290
private func captureBackVisualState(
290291
app: XCUIApplication,
291292
context: SynthesizedCoordinateContext

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ final class RunnerTests: XCTestCase {
4444
/// `BACK_SWIPE_UNVERIFIED` is one whose screen kept changing on its own before the swipe, or could
4545
/// not be sampled afterwards. Both ran the swipe. `BACK_SWIPE_NOT_DISPATCHED` is a back swipe that
4646
/// was refused before any touch went down, so dispatched: no.
47-
/// `BACK_UNSUPPORTED_PLATFORM` is a back on a platform with no back gesture (visionOS); nothing ran,
48-
/// so dispatched: no.
4947
enum RunnerWireErrorCode {
5048
static let mainThreadTimeout = "MAIN_THREAD_TIMEOUT"
5149
static let appNotRunning = "APP_NOT_RUNNING"
@@ -56,7 +54,6 @@ final class RunnerTests: XCTestCase {
5654
static let backSwipeNoChange = "BACK_SWIPE_NO_CHANGE"
5755
static let backSwipeUnverified = "BACK_SWIPE_UNVERIFIED"
5856
static let backSwipeNotDispatched = "BACK_SWIPE_NOT_DISPATCHED"
59-
static let backUnsupportedPlatform = "BACK_UNSUPPORTED_PLATFORM"
6057
/// Refuses a repeat of a `commandId` the runner already finished, when that command's own
6158
/// classification keeps no response body to replay. Nothing ran for the repeat, but the daemon's
6259
/// dispatch disclosure stays `unknown` — only the runner knows whether an earlier send of that id

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ extension RunnerTests {
4444
XCTAssertEqual(payload.code, RunnerWireErrorCode.backSwipeUnverified)
4545
}
4646

47-
/// A screen that changes on its own every 0.5 s gives one quiet pair of samples 0.25 s apart, then
48-
/// changes before the after sample. Settling needs three agreeing samples, so it is never settled
49-
/// and back reports an unknown outcome instead of crediting the swipe.
47+
/// A screen that changes on its own every 0.5 s is never still for the required span (the contact
48+
/// allowance, one 0.25 s delay, and the slowest capture, over 0.5 s on a simulator), so it never
49+
/// settles and back reports an unknown outcome instead of crediting the swipe.
5050
@MainActor
5151
func testInAppBackOnAScreenChangingSlowerThanOneDelayIsNotPerformed() throws {
5252
_ = try launchBackFixture(["--agent-device-back-regression", "--slow-toggle"])
@@ -316,15 +316,6 @@ extension RunnerTests {
316316

317317
#endif
318318

319-
/// The visionOS arm's refusal carries the typed code the host maps to dispatched no, in the same
320-
/// shape as the other back codes.
321-
func testBackUnsupportedPlatformRefusalCarriesItsTypedCode() {
322-
let refusal = Self.backUnsupportedPlatformRefusal
323-
XCTAssertEqual(refusal.code, RunnerWireErrorCode.backUnsupportedPlatform)
324-
XCTAssertEqual(refusal.code, "BACK_UNSUPPORTED_PLATFORM")
325-
XCTAssertNotNil(refusal.hint)
326-
}
327-
328319
func testNavigationVisualObservationSeparatesChangeFromRefusal() {
329320
// A refused side makes the pair uncomparable, not "unchanged"; reading it as "unchanged" would
330321
// let a capture that refused become the reason `back` claims its swipe changed nothing.

‎apple/runner/RUNNER_PROTOCOL.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ verifies a change of the app's screen. Its failure codes are:
140140
| Code | When | Sent |
141141
| --- | --- | --- |
142142
| `APP_SCREEN_WINDOW_UNRESOLVED`, `APP_SCREEN_UNRESOLVED`, `APP_SCREEN_CAPTURE_UNRENDERABLE`, `APP_SCREEN_OFF_LIT_PANEL` | The screen could not be sampled before the swipe. | Nothing |
143-
| `BACK_SWIPE_NOT_DISPATCHED` | The swipe was refused before any touch went down. | Nothing |
144-
| `BACK_UNSUPPORTED_PLATFORM` | The platform has no back gesture (visionOS). | Nothing |
143+
| `BACK_SWIPE_NOT_DISPATCHED` | The swipe was refused before any touch went down, or the platform has no back gesture (visionOS; the daemon refuses it first). | Nothing |
145144
| `BACK_SWIPE_NO_CHANGE` | The swipe was sent and the sampled grid (48×96 grayscale cells, with the top 7 rows always left out; in portrait they hold the status bar and Dynamic Island, and in landscape the iPhone status bar is hidden and the Dynamic Island sits at a side edge, outside those rows) changed in at most 1% of the remaining cells by more than 24 of 256 levels. | The swipe |
146145
| `BACK_SWIPE_UNVERIFIED` | The swipe may have run; the outcome is unknown. | Possibly the swipe |
147146

‎packages/apple-runner/src/__tests__/runner-error-classification.test.ts‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
NO_TEXT_INPUT_AT_POINT_RUNNER_CODE,
88
RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES,
99
TEXT_INPUT_PROBE_UNAVAILABLE_RUNNER_CODE,
10-
buildRunnerResponseError,
1110
classifyRunnerReportedError,
1211
} from '../runner-contract.ts';
1312
import {
@@ -154,29 +153,6 @@ test('a back swipe that proved nothing stays COMMAND_FAILED, unknown, with its o
154153
assert.equal(notDispatched.code, 'COMMAND_FAILED');
155154
assert.equal(notDispatched.details.reason, 'back_swipe_not_dispatched');
156155
assert.equal(notDispatched.details.dispatched, 'no');
157-
// visionOS has no back gesture: the runner refuses before anything runs.
158-
const unsupported = classifyRunnerReportedError('BACK_UNSUPPORTED_PLATFORM');
159-
assert.equal(unsupported.code, 'COMMAND_FAILED');
160-
assert.equal(unsupported.details.runnerErrorCode, 'BACK_UNSUPPORTED_PLATFORM');
161-
assert.equal(unsupported.details.dispatched, 'no');
162-
});
163-
164-
// The exact reply the runner's visionOS arm sends: like every back code, only code, message, and hint.
165-
// The host reads the code through the one classifier, so the dispatch comes from
166-
// RUNNER_ERROR_CODE_DISPATCH, not from a fallback.
167-
test('the visionOS back refusal reply is COMMAND_FAILED with its runner code and dispatched no', () => {
168-
const error = buildRunnerResponseError({
169-
ok: false,
170-
error: {
171-
code: 'BACK_UNSUPPORTED_PLATFORM',
172-
message: 'visionOS has no back gesture',
173-
hint: 'iOS back is a left-edge swipe; visionOS has none. Press the visible back control by its ref.',
174-
},
175-
});
176-
assert.equal(error.code, 'COMMAND_FAILED');
177-
assert.equal(error.details?.runnerErrorCode, 'BACK_UNSUPPORTED_PLATFORM');
178-
assert.equal(error.details?.dispatched, 'no');
179-
assert.equal(error.message, 'visionOS has no back gesture');
180156
});
181157

182158
test('retryable requires an AppError with COMMAND_FAILED', () => {

‎packages/apple-runner/src/runner-contract.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,10 @@ export const TEXT_INPUT_PROBE_UNAVAILABLE_RUNNER_CODE = 'TEXT_INPUT_PROBE_UNAVAI
337337
* did not change. BACK_SWIPE_UNVERIFIED: the swipe was sent but the screen kept changing before it
338338
* or could not be sampled after it. Both ran the swipe, so they stay `unknown`.
339339
* BACK_SWIPE_NOT_DISPATCHED: the swipe was refused before any touch went down.
340-
* BACK_UNSUPPORTED_PLATFORM: the platform has no back gesture (visionOS), so nothing ran.
341340
*/
342341
const BACK_SWIPE_NO_CHANGE_RUNNER_CODE = 'BACK_SWIPE_NO_CHANGE';
343342
const BACK_SWIPE_UNVERIFIED_RUNNER_CODE = 'BACK_SWIPE_UNVERIFIED';
344343
const BACK_SWIPE_NOT_DISPATCHED_RUNNER_CODE = 'BACK_SWIPE_NOT_DISPATCHED';
345-
const BACK_UNSUPPORTED_PLATFORM_RUNNER_CODE = 'BACK_UNSUPPORTED_PLATFORM';
346344

347345
/**
348346
* Runner codes that classify a failure for the host without renaming it on the wire. They stay
@@ -360,7 +358,6 @@ const DIAGNOSTIC_ONLY_RUNNER_ERROR_CODES: ReadonlyMap<string, { retriable?: true
360358
[BACK_SWIPE_NO_CHANGE_RUNNER_CODE, {}],
361359
[BACK_SWIPE_UNVERIFIED_RUNNER_CODE, {}],
362360
[BACK_SWIPE_NOT_DISPATCHED_RUNNER_CODE, {}],
363-
[BACK_UNSUPPORTED_PLATFORM_RUNNER_CODE, {}],
364361
...[...RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES].map((code) => [code, {}] as const),
365362
]);
366363

@@ -402,7 +399,6 @@ const RUNNER_ERROR_CODE_DISPATCH: ReadonlyMap<string, DispatchDisclosure> = new
402399
[ALERT_BUTTON_NOT_FOUND_RUNNER_CODE, 'no'],
403400
[ALERT_UNRESOLVED_RUNNER_CODE, 'no'],
404401
[BACK_SWIPE_NOT_DISPATCHED_RUNNER_CODE, 'no'],
405-
[BACK_UNSUPPORTED_PLATFORM_RUNNER_CODE, 'no'],
406402
...[...RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES].map((code) => [code, 'no'] as const),
407403
]);
408404

0 commit comments

Comments
 (0)