Files
e2e/apps
Łukasz LechandClaude Opus 5.5 1d28ac0fea feat(mobile): add device.isKeyboardShown() (#1893)
* feat(mobile): add device.isKeyboardShown()

Returns whether the soft keyboard is on screen from one capture: the
keyboard agent-device reports (a measured or derived frame, or a
visibility probe), else visible keyboard elements in the tree, the same
band observations hide covered nodes under. A capture that cannot answer
(no keyboard in a sparse or cut tree, or keyboard elements agent-device
rejected with no probe) fails with ENGINE_FAILURE instead of guessing.

Refs #1855

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(i18n): mirror the isKeyboardShown heading and rows in ja and zh

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(mobile): note that isKeyboardShown reads the screen as it is now

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): answer isKeyboardShown only from what the capture can prove

- An unmeasurable keyboard reading answers false only for the reasons that
  say agent-device read the whole tree; a capture that could not see the
  keyboard's window fails with UNSUPPORTED_CAPABILITY.
- A rejected docked frame with no probe reads as shown: agent-device
  rejects one only for a tree that lists keyboard elements, as a keyboard
  still sliding in does on an iPhone.
- The incomplete-tree failure no longer claims a retryable flag that
  EngineError drops for ENGINE_FAILURE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): read the keyboard by one rule and answer false only on proof

Review follow-up for isKeyboardShown:

- keyboardShownIn moves to keyboard.ts and is the one rule:
  dismissKeyboard's check is keyboardShownIn === true.
- Only agent-device's `absent` (or a probe that says hidden) answers
  false. keyboard-not-observed and keyboard-visibility-probe-unsupported
  now fail with UNSUPPORTED_CAPABILITY.
- Tree answers count keyboard elements drawn on screen only, so a
  keyboard left in the tree off screen does not read as shown.
- A tree-rejected reading with no on-screen key is the keyboard moving:
  both isKeyboardShown and dismissKeyboard capture again, briefly, before
  they answer.
- The benchmark test taps the field first, since a fill on Android opens
  no input method, and polls both reads.
- The ja and zh Throws tables are translated, and the Appium guide notes
  that the call reads the screen as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(mobile): say a keyboard reading can take several captures

isKeyboardShown's JSDoc and the reference said one capture, but a
keyboard still moving is captured again. keyboardShownIn's comment now
names what it decides instead of every keyboard check (observations
report measured state only), and the unsupported message says the tree
shows no keyboard drawn on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mobile-benchmark): read the keyboard on iOS only

The Android emulator in CI draws no soft keyboard, even for a tapped
field, so isKeyboardShown polled false until it timed out. The keyboard
reads move to their own iOS-only test, and the onboarding test is back
to what main has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): start the keyboard drag above every element that says the keyboard is up

The drag's top edge came from keys alone, while isKeyboardShown also counts
the suggestion strip, so a capture that lists only the strip (a hardware
keyboard) dragged from under it. The reference example now polls the read
after dismissKeyboard, and the changeset notes the transition wait follows
the same rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mobile): say the strip drag starts above the strip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mobile): pin the drag above the strip when keys sit under it

The strip-only test could not tell the highest keyboard element from any
of them. It now also lists the strip above the keys, with the strip holding
only text so nothing but the keyboard's top keeps the drag off it. The
drawn-keyboard predicate is one helper that keyboardBand and
keyboardElementsTop both read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): refuse a keyboard drag when nothing bounds the keyboard

A visibility probe that says the keyboard is up, with no frame and no
keyboard element on screen, left keyboardTop at the bottom of the screen, so
the drag could start on the keyboard. dismissKeyboard now fails with
UNSUPPORTED_CAPABILITY there instead of guessing. The strip test's
assertion names the failing y.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): read the soft keyboard from keys, and keep each look in the budget

The suggestion strip alone, as XCTest lists it with a hardware keyboard, no
longer reads as the soft keyboard shown; it still bounds where the
dismissing drag may start, now also above a measured or derived frame. The
settle loop reserves the last capture's time along with its backoff, so a
slow capture after the drag no longer times the dismissal out. A capture
with no viewport and no window places no keyboard on screen, since the
tree's own extent holds the keyboard it is asked about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(mobile): say expect.poll reads isKeyboardShown again after any error

A lasting UNSUPPORTED_CAPABILITY makes the poll wait out its timeout; the
docs implied only ENGINE_FAILURE was read again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:58:41 +01:00
..