Surface targetHittable/hint for non-hittable press/fill targets (#1037)
Summary
Fixes the observability half of #1037: press/fill/click reported plain success even when the resolved target's underlying AX node was hittable: false, so a tap could silently land on inert UI with no signal back to the agent.
The Maps pin case from #1037: press 'text="Anthropic - Headquarters"' on the Apple Maps home screen exact-matched a 30x30 map-pin annotation (hittable: false) instead of the recents row a human means ("Anthropic - Headquarters, 548 Market St…", a separate, longer-labeled node). The selector was unique, so no ambiguity machinery ever ran — the command proceeded, tapped inert map area, and reported success. A follow-up wait text for the place card then failed, but by then the agent had already moved on assuming the press worked.
What is surfaced now
When resolveSelectorInteractionTarget/resolveRefInteractionTarget (src/commands/interaction/runtime/resolution.ts) settle on a final node — after any hittable-ancestor promotion — whose hittable === false, the success payload for press/fill/click/longpress now includes:
targetHittable: falsehint: e.g."The resolved element reports hittable: false, so this press may have had no visible effect. Verify with a snapshot, or prefer a @ref or a longer/more specific selector to target the intended element."
This flows through the existing ResolvedInteractionTarget contract (src/contracts/interaction.ts), the daemon's interactionResultExtra allowlist (src/daemon/handlers/interaction-touch-targets.ts — this is an explicit field allowlist, not a spread, so new fields had to be added there deliberately), and the MCP output schema (src/mcp/command-output-schemas.ts).
Also documents the selector disambiguation policy in agent-device help workflow (src/cli/parser/cli-help.ts): ambiguous matches on interactive commands resolve automatically — deepest node first, then smallest on-screen area, only an exact tie fails with "Selector did not resolve uniquely" — and replay/replay-heal apply the same policy for touch/fill/get-text. At least two contributors believed ambiguous selectors always failed; this closes that folklore gap.
What was deliberately NOT changed
- No stricter resolution. No strict-unique requirement, no hittable filtering in
resolveSelectorChain/resolveInteractionTarget. react-navigation's maestro suite has 185tapOns on short/duplicated labels ('Albums'x9,'Go back'x16) that exist as tab + header + button simultaneously — filtering or failing on non-hittable/ambiguous matches would break that suite. This PR is informational-only, per the issue's explicit ask. - The native iOS direct-selector fast path is untouched.
fill/clickwith a single-termid=/label=/text=/value=selector on iOS take a separate fast path (readSimpleIosSelectorTarget→dispatchDirectIosSelectorInteractioninsrc/daemon/handlers/interaction-touch.ts) that calls straight into the native XCTest runner (interactor.fillElementSelector/pressElementSelector) and never builds aSnapshotNode, so there is no localhittablevalue to check. Extending that would mean changing the runner protocol itself — out of scope here. Note the exact repro in the issue (press 'text="..."') is not affected by this gap:press's direct-selector path is click-only (readDirectIosSelectorTapTargetreturns null unlesscommandLabel === 'click'), so the reported scenario goes throughresolution.tsand is covered by this fix. Onlyfill/clickwith simple selectors on iOS retain the gap. - The native-ref fast paths (
maybeTapRefTarget/maybeFillRefTargetinsrc/commands/interaction/runtime/interactions.ts, used by backends exposingtapTarget/fillTarget, e.g. web) don't capture a snapshot at all, so there's nohittablevalue available to surface there either.
Testing
- Unit tests added in
src/commands/interaction/runtime/interactions.test.ts(press/fill non-hittable hint path, plus a negative case confirming hittable targets get no hint) andsrc/daemon/handlers/__tests__/interaction.test.ts(daemon-level payload assertions on an existing non-hittable-promotion fixture). - Doc test added in
src/__tests__/cli-help.test.tsasserting the new disambiguation paragraph. pnpm format && pnpm check:quickclean.pnpm exec vitest run— full suite, 341 files / 3125 tests passed.pnpm exec vitest run test/integration/provider-scenarios— 26 files / 87 tests passed (no response-shape regressions; these tests use partial-key matching so additive fields don't break them).
Closes #1037