fix(mobile): reject stale refs after transition refresh
Merged
SH
18d ago+48+48+01234567890123456789-5-5-0123456789
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 retryableNODE_STALEbefore any input (packages/mobile/src/surface.ts,relocated()), and the locator resolves the selector again within its timeout (performUntilre-resolves on retryableNODE_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 checkand all 413 mobile unit tests pass.
| Scenario | main | this branch |
|---|---|---|
| Target absent after refresh | Dispatches stale binding | NODE_STALE, no input |
| Old ref reused by another control | Taps the wrong control | Locator resolves the intended control again |