Skip to content

Commit 306352c

Browse files
thymikeeclaude
andcommitted
refactor(keyboard): name the dispatched dismissal and split the wire-code map
Rename the dismiss outcome flag to dispatchedDismissal, since it also covers the tvOS Menu press. Move the keyboard-dismiss wire-code rename out of the diagnostic-only list into its own map, and name the iOS reason in the workflow help. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 579ad97 commit 306352c

5 files changed

Lines changed: 34 additions & 25 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ extension RunnerTests {
595595
return Response(ok: false, error: ErrorPayload(message: "keyboardDismiss produced no result"))
596596
}
597597
if result.wasVisible && !result.dismissed {
598-
return Response(ok: false, error: keyboardDismissRefusal(dismissControlFound: result.dismissControlFound))
598+
return Response(ok: false, error: keyboardDismissRefusal(dispatchedDismissal: result.dispatchedDismissal))
599599
}
600600
return Response(
601601
ok: true,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ enum RunnerKeyboardDismissMechanism: String {
3232
}
3333

3434
/// One `keyboard dismiss` attempt, plus the fact that decides how a refusal is classified:
35-
/// `dismissControlFound` says whether the runner ever dispatched a dismissal.
35+
/// `dispatchedDismissal` says whether the runner ever dispatched a dismissal.
3636
struct RunnerKeyboardDismissOutcome {
3737
let wasVisible: Bool
3838
let dismissed: Bool
3939
let visible: Bool
4040
let mechanism: RunnerKeyboardDismissMechanism?
4141
/// Whether a dismissal was dispatched — the keyboard's own control was tapped, or the tvOS remote's
4242
/// Menu press landed. Only its absence proves the command sent nothing.
43-
let dismissControlFound: Bool
43+
let dispatchedDismissal: Bool
4444
}
4545

4646
/// Keyboard coverage read from the capture's complete pre-projection root snapshot on iOS XCTest.
@@ -210,7 +210,7 @@ extension RunnerTests {
210210
dismissed: false,
211211
visible: false,
212212
mechanism: nil,
213-
dismissControlFound: false
213+
dispatchedDismissal: false
214214
)
215215
}
216216

@@ -225,7 +225,7 @@ extension RunnerTests {
225225
mechanism: tvVisible ? nil : .dismissKey,
226226
// `pressTvRemote` answers false only on a build that has no remote to press, so on tvOS the
227227
// Menu press went out and the refusal that follows did dispatch: it keeps the generic code.
228-
dismissControlFound: pressedMenu
228+
dispatchedDismissal: pressedMenu
229229
)
230230
#else
231231
if tapKeyboardDismissControl(app: app) {
@@ -242,7 +242,7 @@ extension RunnerTests {
242242
dismissed: !visible,
243243
visible: visible,
244244
mechanism: visible ? nil : .dismissKey,
245-
dismissControlFound: true
245+
dispatchedDismissal: true
246246
)
247247
}
248248

@@ -257,7 +257,7 @@ extension RunnerTests {
257257
dismissed: false,
258258
visible: isKeyboardVisible(app: app),
259259
mechanism: nil,
260-
dismissControlFound: false
260+
dispatchedDismissal: false
261261
)
262262
#endif
263263
}
@@ -267,8 +267,8 @@ extension RunnerTests {
267267
/// nothing and is the runner's own typed refusal (`KEYBOARD_DISMISS_UNAVAILABLE`, so the host
268268
/// publishes its `details.reason` instead of leaving callers to read the prose), while a control
269269
/// that was tapped and left the keys up did dispatch and keeps the generic code.
270-
func keyboardDismissRefusal(dismissControlFound: Bool) -> ErrorPayload {
271-
if dismissControlFound {
270+
func keyboardDismissRefusal(dispatchedDismissal: Bool) -> ErrorPayload {
271+
if dispatchedDismissal {
272272
return ErrorPayload(
273273
code: "UNSUPPORTED_OPERATION",
274274
message: "Unable to dismiss the keyboard: a dismiss mechanism ran and the keyboard stayed visible",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ extension RunnerTests {
144144
/// that was tapped and left the keys up did dispatch and keeps the generic code. The host reads the
145145
/// first code's literal to publish `details.reason`, so it is pinned here as the wire value.
146146
func testKeyboardDismissRefusalNamesItsOwnCodeOnlyWhenNothingWasDispatched() {
147-
let notDispatched = keyboardDismissRefusal(dismissControlFound: false)
147+
let notDispatched = keyboardDismissRefusal(dispatchedDismissal: false)
148148
XCTAssertEqual(notDispatched.code, "KEYBOARD_DISMISS_UNAVAILABLE")
149149
XCTAssertNotNil(notDispatched.hint)
150150

151-
let dispatched = keyboardDismissRefusal(dismissControlFound: true)
151+
let dispatched = keyboardDismissRefusal(dispatchedDismissal: true)
152152
XCTAssertEqual(dispatched.code, "UNSUPPORTED_OPERATION")
153153
XCTAssertNotNil(dispatched.hint)
154154
XCTAssertNotEqual(dispatched.code, notDispatched.code)

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,24 +365,22 @@ const BACK_SWIPE_NOT_DISPATCHED_RUNNER_CODE = 'BACK_SWIPE_NOT_DISPATCHED';
365365

366366
/**
367367
* Runner codes that classify a failure for the host without renaming it on the wire. They stay
368-
* `COMMAND_FAILED` unless their row names the code the caller already reads the family under, and
369-
* survive as `details.runnerErrorCode`, which is what family policy reads: `RUNNER_BUSY` for
370-
* retriable contention, `ALERT_NOT_FOUND` for an alert that is not there yet, the scroll keyboard
371-
* refusal for a surface the runner declined to swipe under the keys, the retriable
372-
* `APP_NOT_RUNNING` for a read the runner refused rather than launch the session app, and the
373-
* keyboard-dismiss refusal, which stays `UNSUPPORTED_OPERATION` because that is the code
374-
* `keyboard dismiss` already refuses with.
368+
* `COMMAND_FAILED` unless `DIAGNOSTIC_RUNNER_ERROR_WIRE_CODES` names the code the caller already
369+
* reads the family under, and survive as `details.runnerErrorCode`, which is what family policy
370+
* reads: `RUNNER_BUSY` for retriable contention, `ALERT_NOT_FOUND` for an alert that is not there
371+
* yet, the scroll keyboard refusal for a surface the runner declined to swipe under the keys, and
372+
* the retriable `APP_NOT_RUNNING` for a read the runner refused rather than launch the session app.
375373
*/
376374
const DIAGNOSTIC_ONLY_RUNNER_ERROR_CODES: ReadonlyMap<
377375
string,
378-
Readonly<{ wireCode?: AppErrorCode; retriable?: true }>
376+
Readonly<{ retriable?: true }>
379377
> = new Map([
380378
[RUNNER_BUSY_RUNNER_CODE, { retriable: true }],
381379
[MAIN_THREAD_TIMEOUT_RUNNER_CODE, {}],
382380
[APP_NOT_RUNNING_RUNNER_CODE, { retriable: true }],
383381
[ALERT_NOT_FOUND_RUNNER_CODE, {}],
384382
[SCROLL_KEYBOARD_OCCLUDES_SURFACE_RUNNER_CODE, {}],
385-
[KEYBOARD_DISMISS_UNAVAILABLE_RUNNER_CODE, { wireCode: 'UNSUPPORTED_OPERATION' }],
383+
[KEYBOARD_DISMISS_UNAVAILABLE_RUNNER_CODE, {}],
386384
[SYNTHESIZED_GESTURE_NOT_DISPATCHED_RUNNER_CODE, {}],
387385
[SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN_RUNNER_CODE, {}],
388386
[BACK_SWIPE_NO_CHANGE_RUNNER_CODE, {}],
@@ -391,6 +389,15 @@ const DIAGNOSTIC_ONLY_RUNNER_ERROR_CODES: ReadonlyMap<
391389
...[...RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES].map((code) => [code, {}] as const),
392390
]);
393391

392+
/**
393+
* Diagnostic-only codes that keep the wire code their command already refuses with instead of
394+
* `COMMAND_FAILED`: the keyboard-dismiss refusal stays `UNSUPPORTED_OPERATION`, the code
395+
* `keyboard dismiss` already refuses with.
396+
*/
397+
const DIAGNOSTIC_RUNNER_ERROR_WIRE_CODES: ReadonlyMap<string, AppErrorCode> = new Map([
398+
[KEYBOARD_DISMISS_UNAVAILABLE_RUNNER_CODE, 'UNSUPPORTED_OPERATION'],
399+
]);
400+
394401
/**
395402
* `details.reason` for the runner codes a consumer acts on, so it reads one field instead of
396403
* `details.runnerErrorCode`, which stays for the runner's own vocabulary. Both the codes that stay
@@ -477,12 +484,14 @@ export function classifyRunnerReportedError(
477484
runnerErrorCode === undefined
478485
? undefined
479486
: DIAGNOSTIC_ONLY_RUNNER_ERROR_CODES.get(runnerErrorCode);
487+
const wireCode =
488+
runnerErrorCode === undefined
489+
? undefined
490+
: DIAGNOSTIC_RUNNER_ERROR_WIRE_CODES.get(runnerErrorCode);
480491
const reason =
481492
runnerErrorCode === undefined ? undefined : RUNNER_REPORTED_ERROR_REASONS.get(runnerErrorCode);
482493
return Object.freeze({
483-
code: diagnosticOnly
484-
? (diagnosticOnly.wireCode ?? 'COMMAND_FAILED')
485-
: toAppErrorCode(runnerErrorCode),
494+
code: diagnosticOnly ? (wireCode ?? 'COMMAND_FAILED') : toAppErrorCode(runnerErrorCode),
486495
details: Object.freeze({
487496
runnerErrorCode,
488497
...(diagnosticOnly?.retriable === true ? { retriable: true as const } : {}),

‎src/commands/schema/cli-help.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Selectors:
105105
Text entry:
106106
fill replaces; type appends to an already-focused field: fill 'id="field-email"' "[email protected]"; type "Handle with care" --delay-ms 80
107107
fill <target> "" clears the field (replace with nothing); the empty argument must be present -- fill <target> alone is a missing argument.
108-
For dropped iOS text, retry with --delay-ms before clipboard paste. This also applies to Limrun iOS, which uses the same Apple runner.
109-
Element presses behind the keyboard are refused with tap_keyboard_occludes_target. keyboard dismiss taps its own dismiss key when one exists, else UNSUPPORTED_OPERATION. Android: try dismiss before back. iOS: when both fail, do not tap a static text/heading hoping it is safe; prefer type "\\n" to submit.
108+
For dropped iOS text, retry with --delay-ms before clipboard paste (Limrun iOS shares the Apple runner).
109+
Presses behind the keyboard are refused with tap_keyboard_occludes_target. keyboard dismiss taps its own dismiss key when one exists, else UNSUPPORTED_OPERATION (iOS: error.details.reason keyboard_dismiss_unavailable, dispatched: no). Android: try dismiss before back. iOS: when both fail, never tap static text/headings; prefer type "\\n" to submit.
110110
iOS paste-prompt limits and Android IME/handwriting capture quirks: help debugging.
111111
112112
Session ordering:

0 commit comments

Comments
 (0)