Skip to content

fix(device_batch): return bare ref id from findRefByTestID (#396)#401

Merged
Lykhoyda merged 1 commit into
mainfrom
fix/396-batch-testid-double-at
Jul 2, 2026
Merged

fix(device_batch): return bare ref id from findRefByTestID (#396)#401
Lykhoyda merged 1 commit into
mainfrom
fix/396-batch-testid-double-at

Conversation

@Lykhoyda

@Lykhoyda Lykhoyda commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #396device_batch testID steps failed on the in-tree runners with a misleading STALE_REF (Element at ref @@e68 no longer hittable — UI re-rendered since snapshot), directly contradicting the tool schema's promise that testID steps "re-resolve via snapshot at execution time … immune to layout-change drift".

Root cause

  • The in-tree iOS/Android runners emit snapshot envelope refs @-prefixed (mapRunnerNodesToFlatref: '@e68'); the deleted agent-device daemon emitted them bare.
  • findRefByTestID passed the envelope ref through verbatim.
  • The three testID branches of device_batch (find+tap / press / fill) compose the target as `@${ref}`@@e68.
  • lookupRef strips exactly one @, so refMap.get('@e68') misses (keys are bare e68) and the _staleRef sentinel mislabels a fresh-snapshot resolution as "UI re-rendered".

Net effect: every testID-keyed batch step failed on both in-tree runners — the exact stale-ref failure mode the parameter exists to eliminate, plus a false diagnosis.

Fix

findRefByTestID now returns the canonical bare id in both envelope shapes (flat nodes + nested tree) via a bareRef helper. The @${ref} composition at the call sites is now always single-@. The second consumer (expect_visible_by_testid) only checks presence, so it is unaffected.

Tests

Device verification (iOS, iPhone 16 Pro simulator)

Closes #396

🤖 Generated with Claude Code

The in-tree runners emit envelope refs as '@E68' (mapRunnerNodesToFlat),
unlike the deleted agent-device daemon whose refs were bare. The testID
branches of device_batch compose the press target as `@${ref}`, so the
passed-through prefix produced '@@E68'; lookupRef strips exactly one '@',
missed the ref-map, and the _staleRef sentinel mislabeled a fresh-snapshot
resolution as "no longer hittable — UI re-rendered since snapshot".

findRefByTestID now normalizes to the canonical bare id in both envelope
shapes (flat nodes + nested tree), restoring the documented "re-resolve at
execution time" contract on iOS and Android. The GH #114 contract tests
pinned the buggy passthrough ('@e7'/'@E12') and are updated to the bare-id
contract; legacy-tier expectations are unchanged, proving bare refs pass
through untouched.

Closes #396

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Lykhoyda Lykhoyda merged commit 3cf6787 into main Jul 2, 2026
11 checks passed
@Lykhoyda Lykhoyda deleted the fix/396-batch-testid-double-at branch July 2, 2026 19:26
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.

bug: device_batch testID steps resolve against a stale cached snapshot, contradicting the re-resolve-at-execution contract

1 participant