fix(apple-runner): fill only the input a tap at the point reaches
Summary
On iOS, a sheet or popover can cover a text field that stays in the accessibility tree. When a fill point lay on both, the runner picked a target without proving the tap reached it: the point lookup ordered inputs by size, and the keyboard counted as focus. The clear, typing and read-back then went to the covered field, or the clear went to whichever field already had focus.
- When more than one input answers the point,
filltaps that point andtextInputTheTapReachedalone decides which input the tap reached: the first candidate that newly takes keyboard focus within the readiness wait (2 s). An input that already held focus counts as reached only when the full wait finds no newly focused candidate and it is the only uncovered candidate there. The chosen input stays bound through clear, typing and read-back, including the synthesized route's fallback when synthesis stops early, which reuses the bound input while it still holds focus. - Otherwise it types nothing and returns
TEXT_INPUT_NOT_FOCUSED. - A point with a single input keeps its current path, so secure fields and moved or replaced inputs behave as before. Point lookups (
queryTextInputs) keep the basesmallestElementFirstorder.
Trade-offs:
- Re-filling a field that already has focus at a point it shares with another input now waits the full 2 s before it is accepted. It is refused when another input there is also uncovered; the docs say how to recover: move focus off it (for example
keyboard dismiss) and retry. - Inputs without an accessibility identifier bind by their XCUIElement handle (the probe's index-bound query element): the identity re-check (element type plus an empty identifier) cannot tell two such inputs apart, so an overlap fill between unidentified inputs relies on that handle, as fills into unidentified inputs already did before this change.
Files: 4 runner sources, the fixture app, runner tests, commands.md. No linked issue.
Validation
Base ea414582b, head cb1f1af81, compared with the previous head e64804c37.
Simulator: iPhone 17, arm64, iOS 27.0 (24A434). Xcode 27.0 (27A266a). Generic simulator build, then test-without-building on one device, parallel testing off.
AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS=1 \
AGENT_DEVICE_XCUITEST_DESTINATION="generic/platform=iOS Simulator" \
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH="$PWD/.tmp/derived-ios" \
pnpm build:xcuitest:ios
xcodebuild test-without-building \
-xctestrun "$(find .tmp/derived-ios/Build/Products -maxdepth 1 -name '*.xctestrun' -print -quit)" \
-destination 'platform=iOS Simulator,id=<udid>' \
-parallel-testing-enabled NO \
-resultBundlePath .tmp/head.xcresult \
-only-testing:AgentDeviceRunnerUITests/RunnerTests/<each of the 45 tests below>
Test filter (45 tests)
testFocusedReplacementAndClearDispatchNoFocusOrCaretTap
testReplacementReadsFocusAgainAfterAnotherInputTakesIt
testFocusedUnidentifiedReplacementKeepsFocusAndCaretPreparation
testNewlyFocusedReplacementKeepsCaretPreparation
testFocusedAppendKeepsItsFocusTap
testFocusedClearMovesCaretForRejectedSelectAllDeletion
testFocusedClearDoesNotContinueIntoAReplacementInput
testFocusedClearReportsRejectedEditsInsteadOfSuccess
testLandscapeReplacementDispatchPreservesFocusedAndPenalizedRoutes
testFillWithKeyboardDownTypesIntoTheSheetInputNotTheOneItCovers
testFillWithKeyboardUpTypesIntoTheSheetInputNotTheOneItCovers
testFillRefusesAndKeepsTheFocusedFieldWhenTheSheetInputUnderThePointTakesNoFocus
testFillAtAPointAPopoverCoversTypesIntoThePopoverFieldNotTheFieldUnderIt
testFillTypesIntoThePopoverFieldThatTakesFocusLateNotTheFieldThatHeldFocus
testFillTypesIntoTheFocusedSheetInputWhenTheTapMovesNoFocus
testFillWhoseSynthesisStopsAfterTheClearTypesIntoTheBoundPopoverField
testTextInputProbeWalksTheLitWindowsOnce
testUnbookedLitPanelContentTranslationBooksTheRequestWindow
testTextInputProbePreservesEnclosingRunnerWait
testTextInputProbeIssueScopeIsThreadBound
testHealthyCoordinateTapPreservesBareTypingWitness
testFreshCoordinateTapEvidenceSkipsProbeAndClearsTypingWitness
testCoordinateTapEvidenceContainingInputPreservesBareTypingWitness
testTextInputProbeContainmentExcludesRequiredReadsAndLaterIssues
testSuppressedAxIssueMakesTextInputProbeUnavailable
testFreshCoordinateTapContainsUnavailableTextInputProbe
testPenalizedCoordinateTapOnNonTextControlDoesNotAuthorizeBareType
testPenalizedCoordinateFillAtAPointWithNoTextInputRefusesBeforeItsTapAndKeepsTheFocusedField
testConfirmedInputReadinessReturnsBeforeItsReadinessWindow
testFillReadsEachResolvedFieldThroughOneSnapshot
testUnboundResolutionReadsItsInputThroughThePointLookup
testFocusStabilizationAsksTheTappedInputBeforeTheKeyboard
testFillThatRaisesTheSoftwareKeyboardReusesTheReadThatConfirmedFocus
testSynthesizedReplacementPacesAnAppOwnedFieldAtItsAcknowledgeWindow
testSynthesizedReplacementLeavesAMaskedFieldUnverified
testSynthesizedReplacementRefusesTextBeyondTheDeliveryBudget
testSynthesizedReplacementClearsPastDroppedSelectAlls
testSynthesizedReplacementConfirmsAFieldThatMovedOnFocus
testSynthesizedClearEmptiesTheFieldThatMovedOnFocus
testSynthesizedClearFailsClosedWhenTheInputFoundUnderThePointIsGone
testSynthesizedClearFindsAnIdentifiedInputWhoseHandleReBound
testSynthesizedClearFailsClosedWhenTheInputFoundUnderThePointCannotBeRead
testSynthesizedReplacementFailsClosedOnAFailedLookupOfTheInputUnderThePoint
testSynthesizedReplacementRefusesABlindEnumerationAsUnreadableNotEmpty
testSynthesizedReplacementOnScreenWithoutInputsReportsAbsent
| Run | Exit | Passed / failed / skipped |
|---|---|---|
cb1f1af81, 45 tests | 0 | 45 / 0 / 0 (44 passes, plus the existing XCTExpectFailure self-test testTextInputProbeContainmentExcludesRequiredReadsAndLaterIssues) |
e64804c37 with this head's fixture and test file, the two new review tests | 65 | 0 / 2 / 0 |
On e64804c37 the two review tests fail before their value assertions:
testFillTypesIntoThePopoverFieldThatTakesFocusLateNotTheFieldThatHeldFocus: the old code accepts the field that held focus on the first poll and dispatches the clear to it; XCTest then refuses because the popover field has taken focus:Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: TextField, {{121.0, 294.0}, {160.0, 34.0}}, identifier: 'agent-device-popover-partly-covered-input', value: background.testFillWhoseSynthesisStopsAfterTheClearTypesIntoTheBoundPopoverField: the old fallback re-resolves by point after the clear and refuses:caught error: "TextEntryFocusNotConfirmed()".
testFillTypesIntoTheFocusedSheetInputWhenTheTapMovesNoFocus passes on this head. The late-focus fixture's shape check (popoverField.isHittable == false) passed on both heads.
Before-evidence from the released CLI on the overlapping-sheet fixture: fill at the shared point exited 1 with TEXT_ENTRY_MISMATCH, expected "sheetvalue", observed "background"; the sheet field stayed stale and the covered field stayed background. No checkout CLI run from this head was made, so that run is evidence of the bug only, not of this fix; the fix's evidence is the XCUITest run above.
Other checks at this head:
pnpm check:quick: passes.pnpm check:xctest-selection: passes. Output:xctest selection: 746 declared AgentDeviceRunnerUITests methods ā host lane (.github/actions/smoke-macos/action.yml, macOS, every PR) reaches 440, PR iOS branch lane (.github/actions/smoke-ios-run/action.yml, iOS Simulator, selected PRs and main) selects 6, nightly (.github/workflows/xctest-nightly.yml, iOS Simulator) reaches 737, its iPad leg selects 4; 0 reachable by no lane; RunnerTests/testCommand skipped everywhere.pnpm build:xcuitest:iosandpnpm build:xcuitest:macos: succeed.
CI: the new tests are iOS-only, so only the nightly iOS lane runs them.
š¤ Generated with Claude Code