Skip to content

fix(mobile): reject stale refs after transition refresh - #1300

Merged
okwasniewski merged 5 commits into
e2e-inc:mainfrom
shamilovtim:codex/mobile-stale-transition-ref
Oct 29, 2026
Merged

okwasniewski merged 5 commits into
e2e-inc:mainfrom
shamilovtim:codex/mobile-stale-transition-ref

Conversation

@shamilovtim

@shamilovtim shamilovtim commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What and why

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.
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

@mintlify

mintlify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 1454929.

Approve preview

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@okwasniewski

Copy link
Copy Markdown
Member

Thanks @shamilovtim, this is a clean fix. Dropping the fallback in relocated() deletes a branch instead of adding one, and it brings the mobile engine in line with the engine contract (docs/writing-an-engine.mdx:158-160: a ref that no longer binds is NODE_STALE, never a node read from what is gone).

What I checked on c076670:

  • Both new regressions fail with packages/mobile/src/surface.ts reverted to main and pass with the fix. The first one taps @e42 and the second taps Orders' @e11.
  • The retry path is real. performUntil (packages/e2e/src/locator/engine.ts:526-533) re-resolves on retryable NODE_STALE within the deadline. On the retry the transition budget has already passed, so settled() returns at once and the loop cannot spin.
  • pnpm check passes, and the mobile unit tests pass (344/344 on the head, 351/351 merged onto current main with no conflicts).

Must fix

None.

Nits

  1. packages/mobile/src/surface.ts:1155: the JSDoc says "otherwise re-resolve before sending input", but this method throws and the locator does the re-resolving. Suggest: The same control in a fresh snapshot; retryable NODE_STALE when it no longer lists it, so the locator resolves again. Then drop the two-line inline comment at 1159-1160, since it repeats the JSDoc.
  2. packages/mobile/src/surface.ts:1124-1136: the settled() JSDoc still ends with "is then found again in a fresh snapshot". Add that a control the fresh snapshot no longer lists fails as stale, so the docblock describes the new contract.
  3. docs/reference/mobile.mdx:230-232: users don't know about snapshots or references. One sentence is enough: "If the control changes during the wait, the action finds it again within its timeout before tapping."

This was an automated review.

@shamilovtim

shamilovtim commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

[Codex] responding on behalf of shamilovtim

Addressed in 1454929: the two JSDocs now state that the locator re-resolves after retryable NODE_STALE, the repeated inline comment is removed, and the reference uses the suggested user-facing sentence. This follow-up changes no runtime behavior. pnpm check and all 344 mobile unit tests pass at this head; fresh-context review has no important or critical findings.

The PR body now records the relationship to #1297: that PR determines when a keyboard change requires a refresh; this one handles losing the target during the refresh. The keyboard-state prerequisite raised on #1297 is being checked separately. GitHub spec/docs/benchmark/mobile workflows still require maintainer approval at this head. The Ready for Human Review label is withheld until required checks actually run.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

Comment thread docs/reference/mobile.mdx Resolved
@okwasniewski

Copy link
Copy Markdown
Member

Thanks @shamilovtim. Re-checked 1454929. All three nits are done:

  1. The relocated() JSDoc now says it throws retryable NODE_STALE so the locator resolves again, and the repeated inline comment is gone (packages/mobile/src/surface.ts:1156).
  2. The settled() docblock now covers the case where the control is missing (surface.ts:1130-1131).
  3. docs/reference/mobile.mdx:230 is now the one user-facing sentence.

No runtime change since c076670. On the head merged into current main (clean merge), pnpm check passes and so do 352/352 mobile unit tests.

Optional nit: rewrap surface.ts:1130-1132. The inserted sentence left one line much longer than the rest of the block.

I approved the fork CI runs. Ready for a maintainer once they pass.

This was an automated review.

@github-actions github-actions Bot added size:S Up to 29 changed lines, not counting tests, fixtures, or the lockfile and removed Ready for Human Review labels Oct 28, 2026
@okwasniewski
okwasniewski merged commit 4af1aa8 into e2e-inc:main Oct 29, 2026
26 checks passed
@shamilovtim
shamilovtim deleted the codex/mobile-stale-transition-ref branch October 29, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review size:S Up to 29 changed lines, not counting tests, fixtures, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile transition refresh can tap another control through a recycled native ref

2 participants