Skip to content

fix: return deterministic matched-target metadata for find click responses#178

Merged
thymikee merged 2 commits intomainfrom
claude/dazzling-cray
Mar 3, 2026
Merged

fix: return deterministic matched-target metadata for find click responses#178
thymikee merged 2 commits intomainfrom
claude/dazzling-cray

Conversation

@thymikee
Copy link
Copy Markdown
Contributor

@thymikee thymikee commented Mar 3, 2026

Summary

Fixes #170.

find "<label>" click was passing through the raw response from the underlying press handler, which could include non-deterministic platform runner data (e.g. app-root ref/coordinates from the iOS XCTest runner).

  • Build the success response from the matched snapshot node instead of spreading the press handler's data
  • Response now always contains: ref (matched element), locator (find strategy), query (search term), x/y (center of matched element's rect)
  • Platform runner data no longer leaks into the find response
  • Session action record now includes locator and query for better replay observability

Also makes dispatch injectable in handleFindCommands (matching the existing pattern in handleInteractionCommands) to enable unit tests without network calls.

Test plan

  • New tests in find.test.ts assert the deterministic response shape for find click with both any and explicit locator strategies
  • New tests verify platform-specific runner data does not appear in the response
  • All 77 existing tests continue to pass (npm test)

…onses (#170)

On success, build the response from the matched snapshot node rather than
passing through whatever the underlying click/press handler returns.
Response now includes: ref, locator, query, and x/y derived from the
matched element's rect — all stable across runs.

Also makes `dispatch` injectable in `handleFindCommands` (matching the
pattern in `handleInteractionCommands`) and adds tests that assert the
deterministic shape and verify that non-deterministic platform runner
data does not bleed into the response.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-178/

Built to branch gh-pages at 2026-03-03 18:08 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

…ences

Add response shape documentation for `find "<query>" click --json` to:
- website/docs/docs/selectors.md (new "Response shape (click)" section)
- skills/agent-device/SKILL.md (guardrail note)
- skills/agent-device/references/snapshot-refs.md (new "find click response" section)

Follows the fix in #178 that made the response deterministic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thymikee thymikee merged commit 427093d into main Mar 3, 2026
6 checks passed
@thymikee thymikee deleted the claude/dazzling-cray branch March 3, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return deterministic matched-target metadata for find/click success responses

1 participant