Repository navigation
feat(mobile): add device.isKeyboardShown() - #1893
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Reviewed at 6577433 against main: code, unit tests, the agent-device 0.21.38 keyboard producers, and the failing Android CI job. Assignment is fine (#1855, assigned to @leszko11).
Must fix
-
apps/mobile-benchmark/tests/device.e2e.ts:49-android deterministic(and somobile gate) fails on this PR. The newexpect(await device.isKeyboardShown()).toBe(true)readsfalseon all 4 attempts. The failure screenshot shows no soft keyboard afterfillon the Android emulator, soisKeyboardShown()answered correctly and the assertion is what's wrong. Fix: tap the field before asserting so it opens the keyboard, thenawait expect.poll(() => device.isKeyboardShown()).toBe(true), because it slides in. Or keep thetrueassertion iOS-only. The immediate read on iOS also depends on the keyboard having appeared already, so poll there too. -
packages/mobile/src/surface.ts:197(KEYBOARD_NOT_IN_TREE) - mappingkeyboard-not-observedandkeyboard-visibility-probe-unsupportedtofalsecontradicts agent-device's own contract (SnapshotKeyboardBandFactinsdk-contracts.d.ts: "A full pre-projection iOS root scan proves absence; projected or partial nodes and omitted facts never do"). In 0.21.38:keyboard-not-observedcomes fromacquireProviderKeyboard/observeCompleteTreeKeyboard. A complete tree with no keyboard evidence getsabsent. This reason shows up only when the tree is incomplete, or when it holds keyboard evidence (aUIRemoteKeyboardWindowrole, KB key or prediction cells) but no element e2e counts as a keyboard. That is exactly the case where agent-device refused to claim "no keyboard".keyboard-visibility-probe-unsupportedcomes from the WebDriver providers when Appium has nois_keyboard_shownroute. That includes Android (runtime13.js,backend: android), where the page source does not hold the IME window, so a cloud Android session with the keyboard up answersfalse. The comment's "(iOS)" premise is not checked anywhere.
Fix: delete the set and let these reasons fall through to
UNSUPPORTED_CAPABILITY.absentis the proof of absence. If a real iOS screen comes back askeyboard-not-observedwith no keyboard showing, that gap belongs in agent-device, not a reinterpretation here. Please say which fact your post-discardfalsereads on the iOS 27 sim came from.
Should fix
surface.tsnow holds three definitions of "keyboard is up":measuredKeyboard,keyboardShowing(used bydismissKeyboard), andkeyboardShownIn, pluskeyboardBandinnodes.ts. They already disagree. Withvisibility-only: falseplus keys in the tree, for example,isKeyboardShown()saysfalsewhiledismissKeyboard()drags. MakekeyboardShowing(raw)keyboardShownIn(raw) === true(unknown stays "don't drag") so there is one rule. It's a one-line change and removes the drift this PR adds.keyboardShownInis a pure function of the capture, the same kind of logic askeyboardBand. Move it next tokeyboardBandinnodes.ts(or a smallkeyboard.ts) instead of growingsurface.ts, which is already 1967 lines.tree-rejectedwithoutvisiblereturnstruewithout checking the keys. agent-device emits it when any keyboard element is in the tree, so a keyboard element left off-screen after dismissal would readtrueforever. Answer from visible, on-screen keyboard elements there, the waykeyboardBandfilters them.
Nits
docs/ja/reference/mobile.mdx:870,docs/zh/reference/mobile.mdx- the new Throws table keeps English headers (Throws | When), but the other tables on those pages are translated (エラー | 発生条件). The cubic P3s are valid.- Reference Throws row for
ENGINE_FAILUREsays "agent-device reported no keyboard". It reported no reading. "measured nothing" is closer. - Cubic P2 on
surface.ts:217(a negativevisibility-onlyshould yield to tree keys) is not a real issue: that probe is Appium's ownisKeyboardShown, andkeyboardBandtreats it the same way.
Verified
tsc --noEmit(mobile),oxlint, andcheck-docs-translationspass.vitest tests/unitpasses 554/554. The one failing suite,provider-example, needs a built mobile dist and is environment-only.- Mutation testing: flipping
tree-rejectedto?? false, dropping theisTruncatedbranch, flipping theKEYBOARD_NOT_IN_TREEanswer, and forcingvisibility-onlytotrueeach fail the new tests. - CI:
ios deterministicpasses.android deterministicfails atdevice.e2e.ts:49on attempt 1, attempt 2, and rerun 1 (screenshot shows no keyboard). That failure is caused by this PR, not a flake. - Parity: Appium XCUITest
isKeyboardShownchecks for a keyboard element in the tree. UiAutomator2 uses the IME probe (dumpsys input_method), and agent-device exposes that askeyboard statuson Android only (unsupported on iOS in 0.21.38). Detox has no keyboard-visibility API.
6577433 to
66e7e7b
Compare
|
[claude-opus-5-5] responding on behalf of @leszko11 Thanks. Addressed in 66e7e7b, rebased on main:
Verified on an iPhone 18 Pro simulator with iOS 27.2: the onboarding test passes, |
There was a problem hiding this comment.
All reported issues were addressed across 13 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/reference/mobile.mdx">
<violation number="1" location="docs/reference/mobile.mdx:938">
P2: The example reads `isKeyboardShown()` right after `fill`, but this section says to poll after an action that opens the keyboard. The PR notes that `fill` on Android does not open the input method, so the example should tap the field first and poll the read.</violation>
</file>
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked at c419d99 against main 9d240ac: the code, unit tests, mutants, the cubic threads, and the Android/iOS CI runs at 3c8b3bd and c419d99.
Earlier asks, all done:
KEYBOARD_NOT_IN_TREEis gone. Onlyabsent, or a probe or rejected frame that says hidden, answersfalse.keyboard-not-observedandkeyboard-visibility-probe-unsupportedfail withUNSUPPORTED_CAPABILITY.- One rule:
keyboardShownInlives inkeyboard.ts,keyboardShowing(raw)iskeyboardShownIn(...) === true, and the dismiss drag readsreading.shown. tree-rejectedwithoutvisibleanswers from on-screen keyboard elements (keyboardOnScreen), else a settlingENGINE_FAILUREthat gets a short, budget-bounded recapture.- ja/zh Throws tables are translated, and the
ENGINE_FAILURErow says "measured nothing". - Android test: the 3c8b3bd run shows the tap did not help. The failure screenshot has the email field focused and no soft keyboard drawn, and
isKeyboardShown()readfalse38 times. Sofalsewas the right answer, and keeping the keyboard test iOS-only is justified.
Must fix
None.
Should fix
packages/mobile/src/keyboard.ts:148/surface.ts:162-keyboardOnScreencountsSystemInputAssistantViewas the keyboard, butkeyboardToponly looks atKEYBOARD_KINDS. If a capture lists only the assistant bar (for example with a hardware keyboard connected),dismissKeyboardByGesturenow drags withkeyboardTop = viewport.height. That puts the drag start band over the bar. On main this case never dragged. Fix: compute the top fromkeyboardBand(...), which already includes the strip. Or leave the assistant bar out of the drag decision.docs/reference/mobile.mdx:957(open cubic P2, real): the example readsisKeyboardShown()once, right afterfill, while the text above says to poll after an action that opens or closes the keyboard. Mid-slide that single read throwsENGINE_FAILURE. Show the documented pattern instead, e.g.await device.dismissKeyboard(); await expect.poll(() => device.isKeyboardShown()).toBe(false);.
Nits
keyboardShowingnow also feeds the projection'skeyboardVisible, whichwaitForTransitioncompares. No test covers that path: putting the old rule back inkeyboardShowingkeeps all 252 engine tests green. Worth one test, or a line in the changeset, since the transition wait changes forvisibility-onlyandderivedcaptures.
Verified
tsc --noEmit(mobile) andoxlintpass.vitest tests/unitpasses 559/559.provider-exampleneeds a built mobile dist, so its failure is environment-only.- Mutants, each failing the new tests: counting off-screen keyboard elements, unknown facts answering
false, no settle recapture,tree-rejectedansweringtruewith no key on screen, and ignoringtruncated. The one that survives is thekeyboardShowingrule (see the nit). - CI at c419d99:
ios deterministicpasses, including the new iOS-only test.android deterministicfails 57/57 at the home-screentoBeVisibleinopenScenario. All 57 failure traces show the emulator's "System UI isn't responding" dialog, so this is an emulator infra flake and not this PR. At 3c8b3bd, the same job passed everything except the test that has since moved to iOS only. Needs a rerun ofandroid deterministic.
Asks done, see latest automated re-check.
|
[claude-opus-5-5] responding on behalf of @leszko11 Thanks. Addressed in feb461e:
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked at e8f8d02 (feb461e + e8f8d02 on top of c419d99, merges cleanly into main 402a615) against the review at c419d99 and the cubic threads.
Earlier asks: all done.
- Drag over the strip:
keyboardTopnow falls back tokeyboardElementsTop, the highest on-screen keyboard element under the same predicatekeyboardOnScreen(and sokeyboardShownIn) uses, strip included. Building on this rather than onkeyboardBandis the right call:keyboardBandreturnsundefinedfortree-rejected, whichkeyboardShownIncan still answertruefor from drawn keys.keyboardTophas one caller,dismissKeyboardByGesture; swipe, scroll and covered-node checks still go throughkeyboardBandand do not change. - Reference example now dismisses, then polls
isKeyboardShown()tofalse(en, ja, zh). The cubic P2 is resolved. keyboardVisiblein the transition wait: covered by the changeset line, fine.- e8f8d02 answers cubic's P3 on the test comment. No open cubic findings.
Must fix
None.
Should fix
packages/mobile/tests/unit/engine.test.ts:1784- the new test lists only the strip, so it cannot tell "highest element" from "any element": changingMath.min(top, rect.y)toMath.maxinkeyboardElementsTopkeeps all 253 engine tests green. With keys plus a strip (the common iOS capture with no measured band),maxwould start the drag at the keys' top, over the strip. This commit also changes that case (main only counted keys), so add the strip above a row of keys and assert the drag starts above the strip.
Nits
packages/mobile/src/nodes.ts- the "drawn keyboard element" predicate (rectnonzero,visibleToUser !== false,isKeyboardElement) is now written out in bothkeyboardBandandkeyboardElementsTop. One smalldrawnKeyboardRects(nodes)helper both read from would keep them from drifting.
Verified
@e2e-dev/mobiletsc --noEmitclean,pnpm lintclean, mobile unit tests 560/560 (provider-example.test.tsonly fails to import@e2e-dev/mobile/leasewithout mobile's dist, unrelated).- Mutants:
keyboardTopignoring tree elements fails the new test; restoring main's keys-onlykeyboardTopfails it; dropping the on-screen filter fails 2 existing tests.min->maxsurvives (above). - CI on e8f8d02: all green, including
android deterministic,ios deterministicandmobile gate.
|
[claude-opus-5-5] responding on behalf of @leszko11 Thanks. Addressed in 8d3dfca:
|
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked at 8d3dfca (one commit on top of e8f8d02, merges cleanly into main 5e9b82e) against the review at e8f8d02.
Earlier asks: all done.
- Should fix (test cannot tell "highest" from "any"): the test now runs the strip alone and the strip over the keys, and the strip holds only text, so it is no control and cannot hide the mutant.
Math.min->Math.maxinkeyboardElementsTopnow fails it (confirmed). - Nit:
drawnKeyboardRects(nodes)holds the drawn-keyboard predicate, andkeyboardBandandkeyboardElementsTopboth read from it.keyboardBandbehavior is unchanged.
No regressions: the commit touches only nodes.ts (pure refactor) and the test. keyboardShownIn in keyboard.ts is untouched, so keyboard-not-observed and keyboard-visibility-probe-unsupported still fail with UNSUPPORTED_CAPABILITY and never map to false. cubic reports 0 issues on this push.
Must fix
None.
Should fix
None.
Nits
packages/mobile/tests/unit/engine.test.ts:1802-expect([keyboard.length, from.y < 200]).toEqual([keyboard.length, true])labels the case but hides the actualyon failure.expect(from.y, `${keyboard.length} keyboard elements`).toBeLessThan(200)(orit.eachover the two layouts) reports both.
Verified
@e2e-dev/mobiletsc --noEmitclean,oxlintclean, mobile unit tests 560/560 (provider-example.test.tsonly fails to import@e2e-dev/mobile/leasewithout mobile's dist, unrelated).- Mutants:
Math.min->Math.maxinkeyboardElementsTopfails the new test; dropping its on-screen filter fails 2 existing tests. - CI on 8d3dfca: all green, including
android deterministic,ios deterministicandmobile gate.
|
🤖 gpt-6.2-sol responding on behalf of Krzysztof
All four targeted iOS 26.5 benchmark tests passed with the built CLI, including the new |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Post-release check at 8d3dfca against main 8eb3cc2: merges clean, mobile typecheck and unit tests pass on the merged tree, CI green, and no peer floor is needed (mobile only, agent-device 0.21.40 from #1975 typechecks).
Open item: Krzysztof's comment from after the last review is not answered yet. When the probe reports { kind: 'visibility-only', visible: true } with no frame and no keyboard elements, dismissKeyboardByGesture (packages/mobile/src/surface.ts:1728-1749) falls back to the bottom of the viewport as keyboardTop, so it can start a swipe inside the keyboard. Please require usable keyboard bounds before swiping (else UNSUPPORTED_CAPABILITY) and add his landscape 844 x 390 case as a unit test.
|
[claude-opus-5-5] responding on behalf of @leszko11 @KrzysztofMoch thanks, real. Fixed in c215e05 (rebased on main after #1975). @okwasniewski's nit is in the same commit: the strip test's assertion now reports the actual |
There was a problem hiding this comment.
0 issues found across 7 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
035a718 to
c215e05
Compare
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked at c215e05 (rebased onto main 309f690 after #1975, plus one new commit) against the post-release check at 8d3dfca and Krzysztof's comment.
Earlier asks: all done.
- Krzysztof's visibility-only swipe:
keyboardTop(packages/mobile/src/surface.ts:162) now returnsundefinedwhen the capture has no measured frame and no keyboard element on screen, anddismissKeyboardByGesture(surface.ts:1752-1759) throwsUNSUPPORTED_CAPABILITYwith the usual alternatives before any swipe. It coversvisibility-onlyandtree-rejectedwithvisible: truealike, and the re-read after the first drag goes through the same check. The 844 x 390 landscape case is a unit test that asserts the code, the message, and zerointeractions.swipecalls. - The nit on the strip test is done: the assertion now reports the actual
ywith the element count as its message. - JSDoc, the en reference Throws row and the changeset name the new case. ja and zh match it.
- Range-diff against 8d3dfca: the 10 earlier commits change only through the rebase. No regressions in them.
Must fix: none.
Should fix: none.
Verified:
pnpm --filter @e2e-dev/mobile typecheckpasses. Mobile unit tests: 569/569 (after building core, e2e and mobile dist).- Mutant: I put back the old fallback (
top ?? viewport.height) and the new landscape test failed. With the fix restored it passes. - No em or en dashes in the added lines. Peer floors are unchanged and none are needed: the change is mobile only, with no new action kind or core contract, and agent-device stays at 0.21.40 from #1975.
- CI at c215e05 is all green.
ios deterministicranisKeyboardShown follows the keyboard up and through a dismissaland it passed (57 passed, 1 skipped).android deterministichad 57 passed and 1 flaky:a label query resolves a labeled text field, which is the known first-test Android cold-launch retry and not this PR's fault. Merge state is clean, no rebase needed.
kdy1
left a comment
There was a problem hiding this comment.
Note
This text was drafted with AI and posted after human approval.
- Harness: T3 Code
- AI agents: Claude Opus 5.5 (claude-opus-5-5), GPT-6.2 Astra (gpt-6.2-astra), GPT-6.2 Sol (gpt-6.2-sol), Claude Sonnet 5.5 (claude-sonnet-5-5)
Requesting changes for two bugs that this PR adds. Both are fixable without a redesign. I also left 4 smaller comments inline (7 inline comments in total).
Must fix
keyboardReadingcan start its last capture with almost no budget left. AdismissKeyboard()that worked on main can then fail withACTION_MAY_HAVE_COMMITTED(seesurface.ts:1693).- When the suggestion strip is the only keyboard element in the tree,
isKeyboardShown()returnstrueanddismissKeyboard()drags (seenodes.ts:145).
Should fix
- A derived keyboard frame still puts the drag start on the strip. This is not new, but it is the same class of bug that this PR fixes for the tree-only case (see
surface.ts:163). - The docs say that
expect.pollretries throughENGINE_FAILURE. In fact it retries every error (seedevice.ts:211).
Low priority
These two need inputs that are unlikely in practice: an off-screen keyboard counted as on screen when the capture has no screen bounds (see nodes.ts:156), and a sparse capture's absent reading dropped by the sparse retry (see surface.ts:1696).
How this was checked
- Four independent reviewers (two GPT models and two Claude models) reviewed the diff at c215e05. I then checked each finding against the code.
- Each behavior claim comes from a scripted-client unit probe that a reviewer or I ran on main 309f690 and on this head. No simulator or emulator was used, so how often (1)–(3) happen with real agent-device captures is not measured.
- At this head,
@e2e-dev/mobiletypecheck passes,vitest tests/unitpasses 569 of 569, andpnpm run lintpasses.
I rejected two findings:
- The capture in
isKeyboardShown()makes refs held from an earlier capture stale (NODE_STALE). This is the existing design, andlocatedoes the same. - The iOS benchmark test was not verified.
ios deterministicpassed at this head.
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 e2e-inc#1855 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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>
…roof 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>
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>
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>
…e 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
…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>
…rror 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>
fa408f8 to
3ae4c7d
Compare
|
[claude-opus-5-5] responding on behalf of @leszko11 @kdy1 thanks, all seven threads are answered. The branch is rebased on main 3e7d19d, with a conflict with #1919 resolved in
Each fix has a unit test that fails on c215e05. Not verified on a device yet: my local iOS 27.2 simulator showed no soft keyboard for a focused field, so |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked at 3ae4c7d (rebased onto main 3e7d19d, 2 new commits on top of the 11 reviewed at c215e05) against kdy1's review and his 7 inline comments.
Range-diff against c215e05: commits 1-11 change only through the rebase (the #1919 conflict in surface.ts / README.md, resolved cleanly). The new work is faca3e8 and 3ae4c7d.
kdy1's asks: all done.
- Must fix 1 (settle loop budget):
keyboardReading(packages/mobile/src/surface.ts:1748-1757) now reservesbackoffMs + captureMs, with the last capture's duration, assnapshot()does. The slow-capture test runs both of his probes (800 msdismissKeyboard()resolves after one swipe, 1000 msisKeyboardShown()ends in the settlingENGINE_FAILURE, not a timeout). - Must fix 2 (strip alone reads as the keyboard):
keyboardOnScreen(packages/mobile/src/nodes.ts:145) counts onlykeyboardandkeykinds. The strip only bounds the drag start, throughkeyboardElementsTop. A strip-only tree with no fact now failsisKeyboardShown()withUNSUPPORTED_CAPABILITYanddismissKeyboard()sends no drag, as on main. The transition wait'skeyboardShowinguses the same rule. - Should fix 3 (derived frame under the strip):
keyboardTop(surface.ts:173) takes the higher of the frame top and the highest on-screen keyboard element. The strip test covers keys in the tree and aderivedframe. - Should fix 4 (poll docs): the JSDoc in
device.ts, the en reference and theUNSUPPORTED_CAPABILITYrow now say a poll reads again after any error and that a lastingUNSUPPORTED_CAPABILITYwaits out the timeout. ja and zh match. - Low priority, no screen bounds:
keyboardOnScreentakes bounds only from the viewport or a window/application node (screenOf). With neither, no keyboard counts. This case has a test now. - Low priority, sparse retry dropping
absent: left as is on purpose, and the reason holds. The retry is the newer capture, and mixing its tree with the older capture's fact would answer from two moments. Main'ssnapshot()does the same. I agree with leaving it.
Krzysztof's visibility-only swipe ask is still in place: keyboardTop returns undefined with no frame and no element on screen, and the landscape 844 x 390 test passes.
No heuristics added. Every true comes from an agent-device fact or a keyboard/key element on screen. false comes only from absent. The retry loop runs only while the capture itself reports the keyboard as moving (tree-rejected with nothing on screen). It does not wait on a timer.
Must fix: none.
Should fix: none.
Nits:
packages/mobile/src/nodes.ts:166-drawnKeyboardRects(nodes, include = isKeyboardElement)has one caller that overrides the default and one that does not. Two named calls,drawnKeyboardRects(nodes)and adrawnRects(nodes, isSoftKeyboard), or passing the predicate at both sites, would make the strip/no-strip split visible at the call site. Optional.
Verified:
@e2e-dev/mobiletypecheck passes, oxlint is clean, and mobile unit tests pass 577/577 (core, e2e and mobile dist built first).- Mutants, each caught by exactly one test: budget check back to
backoffMsonly (slow-capture test fails), strip counted inkeyboardOnScreen(strip-alone test fails), frame-onlykeyboardTop(derived-frame strip test fails),screenOfback to theviewportOfextent fallback (the no-viewportisKeyboardShowncase fails). - No em or en dashes in added lines. No peer floor is needed: the change is mobile only, adds no new action kind or core contract, and does not change any dependency.
- CI at 3ae4c7d is all green.
ios deterministicranisKeyboardShown follows the keyboard up and through a dismissaland it passed (59 passed, 1 skipped).android deterministichad 60 passed and 1 skipped. Merge state is clean, so no rebase is needed.
Claude-Session: https://claude.ai/code/session_01Ls2e1zN3D7gPgfCyeefyGb Co-authored-by: Claude <noreply@anthropic.com>
What and why
Adds
device.isKeyboardShown(): Promise<boolean>to@e2e-dev/mobile, the AppiumisKeyboardShown()row from the umbrella issue.It reads one capture (a sparse tree is captured again first) and answers from what agent-device reports for the keyboard, else from visible keyboard elements in the tree: the same band observations hide covered nodes under (
keyboardBand,packages/mobile/src/nodes.ts).visible,derivedtrueabsentfalsevisibility-only,tree-rejectedwithvisiblevisibletree-rejectedwithoutvisibletruefor a keyboard element drawn on screen. With none, the keyboard is moving: it is captured again briefly, thenENGINE_FAILURE(whichexpect.pollretries)unmeasurable, or no readingtruefor a keyboard element drawn on screen. With none:ENGINE_FAILUREfor a sparse or cut tree, elseUNSUPPORTED_CAPABILITY. Onlyabsent(or a hidden probe) answersfalseIt is a recorded step (
device.isKeyboardShown), bounded byactionTimeout, and changes nothing on the device. It reads the screen as it is now, so after an action that closes the keyboard the docs say to poll it:dismissKeyboard(), and the wait before acting on a control after the keyboard opened or closed, decide whether the keyboard is up by the same rule (keyboardShownIninpackages/mobile/src/keyboard.ts): a reading that cannot answer means no drag. The dismissing drag starts above the highest keyboard element drawn on screen, suggestion strip included (keyboardElementsTop), so a capture that lists only the strip (a hardware keyboard) drags from above it. A keyboard reported up with no frame and no keyboard element on screen gets no drag:UNSUPPORTED_CAPABILITY, since no point is known to be above it.Docs:
docs/reference/mobile.mdx(summary row, entry, Throws), the Appium guide row moves from "What e2e doesn't have yet" to "Map each command", and thejaandzhpages get the new heading and code so their outline still matches. The mobile README lists the method.Issue
Part of #1855, checklist item
device.isKeyboardShown()(Device and app).Verified
Ran it locally: yes
The
truereads after the discard are real: the sheet and the keyboard animate out for about 2.5 s on that machine.tree-rejectedwithoutvisibleright afterfill, while the keyboard slides in. Such a reading is now captured again until the keyboard lands.dismissKeyboard()) readfalse,true,falseon an earlier build.apps/mobile-benchmark/tests/device.e2e.tson the iOS 27.2 simulator, with the benchmark app built after fix(mobile-benchmark): adopt UIKit scenes so the app launches on iOS 27 #1898: the new keyboard test and both onboarding tests pass, twice.isKeyboardShownpolling read 4 settling captures beforetrue, and the phone step dismisses. That run also carried the separate iOS 27 toolbar fix fordismissKeyboard, which comes as its own PR; without it, iOS 27 refuses the first drag. Some runs failed earlier, reading the home list, while the Mac's load average was 30 to 200. Android was not run locally. The Android emulator in CI draws no soft keyboard, even for a tapped field, so the keyboard reads are their own iOS-only test (isKeyboardShown follows the keyboard up and through a dismissal), and the onboarding test is unchanged from main.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed (packages/mobile/dist/device.d.ts).tests/types/sdk-types.tscoverse2e, not the mobileDeviceinterface, so it is unchanged; no wire change.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.🤖 Generated with Claude Code