fix(device_batch): return bare ref id from findRefByTestID (#396)#401
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #396 —
device_batchtestID steps failed on the in-tree runners with a misleadingSTALE_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
@-prefixed (mapRunnerNodesToFlat→ref: '@e68'); the deleted agent-device daemon emitted them bare.findRefByTestIDpassed the envelope ref through verbatim.device_batch(find+tap / press / fill) compose the target as`@${ref}`→@@e68.lookupRefstrips exactly one@, sorefMap.get('@e68')misses (keys are baree68) and the_staleRefsentinel 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
findRefByTestIDnow returns the canonical bare id in both envelope shapes (flat nodes + nested tree) via abareRefhelper. 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
@-prefixed runner envelopes (flat + tree) resolve to bare ids; a composed-target invariant test pins/^@[^@]/for both envelope ref styles (this test reproduces the on-device@@e151failure before the fix).@e7/@e12) had pinned the buggy passthrough — now pin the bare-id contract. Legacy-tier expectations unchanged, proving bare refs pass through untouched.Device verification (iOS, iPhone 16 Pro simulator)
device_batch [{action:'press', testID:'wizard-title-input'}]— now passes (was:STALE_REF @@e68100% repro).wizard-next-btn@e101→@e48); the follow-up testID press re-resolves to the new ref and lands. NoSTALE_REFanywhere.@-prefixed flat nodes), so the fix applies symmetrically.Closes #396
🤖 Generated with Claude Code