Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ extension RunnerTests {
}
if command.command == .keyboardDismiss {
guard !status.visible else {
return Response(ok: false, error: keyboardDismissRefusal())
return Response(ok: false, error: keyboardDismissRefusal(
returnKey: status.returnKey.flatMap(RunnerKeyboardReturnKey.init(rawValue:))
))
}
return Response(ok: true, data: DataPayload(
message: "keyboardDismiss", visible: false, wasVisible: false, dismissed: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,27 @@ extension RunnerTests {
}
#endif

func keyboardDismissRefusal() -> ErrorPayload {
ErrorPayload(
/// `returnKey` is the Return key the refusing status observed: where Return itself ends the edit,
/// the hint names `keyboard enter` and what it will do. Dismiss never presses Return (#4644).
func keyboardDismissRefusal(returnKey: RunnerKeyboardReturnKey?) -> ErrorPayload {
let dismissal = "Inspect the screen and press the visible Hide Keyboard key or an app control that ends editing. If the app supports interactive dismissal, use gesture pan to drag a finger down from inside its scrollable content and check the keyboard state again."
return ErrorPayload(
code: RunnerWireErrorCode.keyboardDismissUnavailable,
message: "The Apple runner cannot dismiss this keyboard automatically",
hint: "Inspect the screen and press the visible Hide Keyboard key or an app control that ends editing. If the app supports interactive dismissal, use gesture pan to drag a finger down from inside its scrollable content and check the keyboard state again."
hint: [Self.keyboardReturnEndsEditingHint(returnKey), dismissal].compactMap { $0 }.joined(separator: " ")
)
}

static func keyboardReturnEndsEditingHint(_ returnKey: RunnerKeyboardReturnKey?) -> String? {
switch returnKey {
case .search: return "To submit this search, run keyboard enter."
case .go: return "To submit this field, run keyboard enter (Return is Go)."
case .done: return "To finish editing, run keyboard enter (Return is Done)."
case .send: return "keyboard enter would send this message (Return is Send); run it only to send."
default: return nil
}
}

var keyboardReturnRefusal: ErrorPayload {
ErrorPayload(
code: RunnerWireErrorCode.keyboardReturnUnavailable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import AgentDeviceSnapshotPresentation

#if AGENT_DEVICE_RUNNER_UNIT_TESTS
extension RunnerTests {
func testKeyboardDismissRefusalNamesKeyboardEnterOnlyWhereReturnEndsTheEdit() {
let search = keyboardDismissRefusal(returnKey: .search)
XCTAssertEqual(search.code, RunnerWireErrorCode.keyboardDismissUnavailable)
XCTAssertTrue(search.hint?.hasPrefix("To submit this search, run keyboard enter.") == true)
XCTAssertTrue(keyboardDismissRefusal(returnKey: .send).hint?.contains("run it only to send") == true)
for key: RunnerKeyboardReturnKey? in [nil, .unknown, .enter, .next] {
XCTAssertFalse(keyboardDismissRefusal(returnKey: key).hint?.contains("keyboard enter") == true)
}
}

func testKeyboardStatusRequiresMeasuredDisplayBounds() {
let keyboard = CGRect(x: 0, y: 925, width: 834, height: 282)
XCTAssertNil(RunnerKeyboardStatus.observed(
Expand Down
2 changes: 1 addition & 1 deletion packages/command-surface/src/system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const foldCommandDescription = `Fold or unfold a foldable iPhone simulator (iPho
const appSwitcherCommandDescription =
'Open the device app switcher to inspect or change foreground apps. This changes the visible system UI and may move focus away from the current app.';
const keyboardCommandDescription =
'status (alias get) reads the keyboard state; a visible keyboard reports returnKey and its label. Unreadable Apple keyboard state reports OBSERVATION_UNAVAILABLE. Enter (alias return) sends Return to the focused input; it may submit, move focus, or insert a newline, and unconfirmed delivery reports keyboard_return_unavailable with dispatched: unknown (Return may have landed). On the native iOS runner, dismiss is a no-op when the keyboard is hidden; a visible keyboard returns keyboard_dismiss_unavailable with dispatched: no. Press the visible Hide Keyboard key or an app control that ends editing, or gesture pan down from the scrollable content with interactive dismissal, and verify with status. Android dismiss sends platform dismissal.';
'status (alias get) reads the keyboard state; a visible keyboard reports returnKey and its label. Unreadable Apple keyboard state reports OBSERVATION_UNAVAILABLE. Enter (alias return) sends Return to the focused input; it may submit, move focus, or insert a newline, and unconfirmed delivery reports keyboard_return_unavailable with dispatched: unknown (Return may have landed). On the native iOS runner, dismiss is a no-op when the keyboard is hidden; a visible keyboard returns keyboard_dismiss_unavailable with dispatched: no. When Return would submit or finish the edit (search, go, done, send), that refusal names keyboard enter. Press the visible Hide Keyboard key or an app control that ends editing, or gesture pan down from the scrollable content with interactive dismissal, and verify with status. Android dismiss sends platform dismissal.';
const clipboardCommandDescription =
'Read the current device clipboard text, or replace its contents with the given text. Android runs both through the clipboard service shell command, and a build that implements none (Android 16 does not) refuses with UNSUPPORTED_OPERATION rather than reporting an empty clipboard.';
const actionButtonCommandDescription =
Expand Down
Loading