fix(mobile): reject stale refs after transition refresh

Merged
SH
18d ago
+48-5

What and why

  • After a transition wait, a test action re-finds its control in a fresh snapshot. When that snapshot no longer lists the control, main sent the old binding anyway, so a recycled native ref could tap another control.
  • Now relocated() throws retryable NODE_STALE before any input (packages/mobile/src/surface.ts, relocated()), and the locator resolves the selector again within its timeout (performUntil re-resolves on retryable NODE_STALE).
  • Merged with main after #1297 (keyboard transitions) and #1410 (input revalidation): the input path keeps #1410's stricter checks and message; the new throw covers every other action.
  • Related: #1413 pins refs to their snapshot generation; it overlaps in relocated() and should keep this throw when it merges after this PR.

Issue

Closes #1299.

Verified

Ran it locally: no device run. Unit evidence on the head merged with main:

  • Restoring main's found === undefined ? entry : ... fallback fails both regressions: "acts on a control that came with the last action where a fresh snapshot lists it once the budget has passed" and "does not tap a recycled ref when a native button becomes a tab during relocation".
  • pnpm check and all 413 mobile unit tests pass.
Scenariomainthis branch
Target absent after refreshDispatches stale bindingNODE_STALE, no input
Old ref reused by another controlTaps the wrong controlLocator resolves the intended control again