Skip to content

fix(mobile): wait for transitions before screen swipes - #1564

Merged
okwasniewski merged 4 commits into
e2e-inc:mainfrom
shamilovtim:codex/mobile-transition-input-budget
Nov 9, 2026
Merged

okwasniewski merged 4 commits into
e2e-inc:mainfrom
shamilovtim:codex/mobile-transition-input-budget

Conversation

@shamilovtim

@shamilovtim shamilovtim commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor
  • Screen swipes in tests now honor the transition budget after the preceding action, including native alert dismissal.
  • Share waitOutTransition(operation, budget) with control transitions. Unchanged-control shortcuts and agent settling remain. A budget too short for the transition fails unsent, including an early timer wake.
flowchart LR
  A[Last action returns] --> B[Wait within transition and action budgets]
  B --> C{Cancelled or budget too short?}
  C -->|Yes| D[No input]
  C -->|No| E[Send screen swipe]
Loading

Issue

Fixes #1562.

Verified

Ran it locally: yes.

Public controlled CLI reproduction: main 1bbda5a fails, this branch f52bdc7 passes. All 505 mobile tests and pnpm check pass. The agent-origin regression fails if its wait is made unconditional; integer/fractional early-wake, cancellation, and sufficient-budget cases pass.

Native pacing cost is measurable. Fixture source/build and timing suite, reports, and clips are public. These are median test-body seconds from the official bench:ab harness on the same UIKit 40-row list binary, iPhone 15 Pro / iOS 27.0 Simulator, agent-device 0.21.36. Each budget has three measured pairs and one excluded warmup, one worker, zero retries. Both builds pass both cases with matching reported behavior/counters.

Transition Native case Main 1bbda5a PR f52bdc7 Action API time, main → PR
500 ms Four consecutive swipes 4.48 s 6.35 s 2.21 → 4.11 s
500 ms scrollUntilVisible, row 25 5.44 s 6.53 s 3.63 → 4.60 s
1500 ms Four consecutive swipes 4.44 s 10.32 s 2.21 → 8.11 s
1500 ms scrollUntilVisible, row 25 5.69 s 10.46 s 3.70 → 8.56 s

API time sums the four screen.swipe steps or the one scrollUntilVisible step. Test bodies also include app launch and assertions. Identical temporary fixture files were untracked in both prepared checkouts; production files matched the listed commits.

Waiting between consecutive test swipes is intentional: a swipe can itself start a scroll or pager animation, and a screen-root gesture has no target binding whose unchanged position proves readiness. Captures and assertions consume the budget before the next swipe. The configured budget is a heuristic, not proof that a native animation has completed.

These fixture runs measure pacing cost, not a failure-rate improvement or the entire Expo benchmark suite. One measured pair per budget is linked below. GitHub disallows uploading attachments to this upstream repository with this account's read access, so the clips are published on the public evidence branch.

Transition Main clip PR clip
500 ms Video Video
1500 ms Video Video

@github-actions github-actions Bot added the size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 4, 2026

@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 8 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread packages/mobile/src/surface.ts Resolved
@github-actions github-actions Bot added size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile and removed size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 4, 2026
@shamilovtim

Copy link
Copy Markdown
Contributor Author

[Codex] responding on behalf of shamilovtim

CI is green and no review threads remain at 8c286c7. A temporary checkout combining the current heads of #1557, #1559, #1561 and #1564 passes all 516 mobile tests, build, typecheck and focused lint.

This account has read access and cannot apply the Ready for Human Review label. A maintainer with label permission will need to apply it.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review by Claude Code on behalf of maintainers.

Thanks, the bug is real: on main the screen-root branch of perform() sends the scroll without consulting the transition budget, while every other test action does. Applying the existing budget there is the right fix, and the cancellation handling looks solid.

A few things before this can go in:

  1. waitForTransition(entry: NodeBinding | undefined, operation, budget?: InputBudget) now does two jobs: the control "already in place" shortcut and a plain wait for the rest of the budget. That is where the nullable entry, the optional budget only one caller passes, and the JSDoc about screen swipes come from. Please split out the budget wait (e.g. waitOutTransition(operation, budget), cancellable, capped by budget.remainingMs()), have waitForTransition(entry, operation, budget) call it after the shortcut, and have the root branch call it directly. That is also the primitive #1563 asks for.
  2. Every test screen swipe now waits out the budget left from the previous action, including a previous screen swipe. screen.scrollUntilVisible swipes in a loop, so each page can gain up to transition minus the read time, and back-to-back screen.swipe() calls gain about 500 ms each. Please share mobile benchmark numbers before/after, or explain why waiting between consecutive screen swipes is intended.
  3. Please add a test that an agent-origin screen swipe does not wait: changing if (deterministic) to if (true) currently passes the whole suite.

Nits:

  • if (waitMs <= 0) return false; does nothing (the root caller ignores the result and send() already rejects a spent budget).
  • docs/reference/mobile.mdx and options.ts put the new sentence in different spots relative to "Raise it for slower transitions"; please match them and rewrap the long lines (same in both setup.md copies).
  • The changeset's second sentence is implementation detail; the first is enough.

Heads-up: this conflicts with #1557 in the comment above the root-swipe branch. The code composes (wait first, then #1557's keyboard snapshot), so whichever lands second needs a small rebase.

@shamilovtim
shamilovtim force-pushed the codex/mobile-transition-input-budget branch from 8c286c7 to f52bdc7 Compare November 5, 2026 17:08
@shamilovtim

shamilovtim commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

[Codex] responding on behalf of shamilovtim

Addressed in f52bdc7 after rebasing onto main 1bbda5a.

  1. waitOutTransition(operation, budget) now owns the cancellable, budget-bounded wait. Control transitions call it after their unchanged-control shortcut; the root branch calls it directly. No nullable target or optional budget remains. Capped waits explicitly fail unsent rather than relying on the clock reaching the deadline, with integer/fractional early-wake regressions.
  2. Consecutive waiting is intentional: a swipe can start a scroll/pager animation, and a root gesture has no target binding that proves readiness. Reads consume the remaining budget. The PR body now makes the native cost prominent: at 500 ms, four swipes rise from 4.48 to 6.35 s; at 1500 ms, from 4.44 to 10.32 s. scrollUntilVisible rises from 5.44 to 6.53 s and 5.69 to 10.46 s respectively. These are three paired samples plus warmup per budget on the same public UIKit binary, not a claim that waiting is free or guarantees animation completion. Source, configuration, reports, and native clips are public.
  3. The agent-origin regression now fails when its wait is made unconditional, while preserving driver settle options. Consecutive-swipe, action-budget, cancellation, and sufficient-budget cases are covered too.

The redundant boolean return is gone. The option/reference sentence order and wrapping match, both setup copies are wrapped, and the changeset keeps only its first sentence. This PR changes no gesture geometry. #1557 has now been withdrawn after its separate native SDK ownership audit, so the prospective root-comment conflict is gone and no stacking dependency remains.

All 505 mobile tests, build, typecheck, lint, and pnpm check pass. The public controlled CLI reproduction fails on current main and passes here. Native benchmark cases pass on both builds, with matching reported behavior/counters and zero retries. The dedicated fixture benchmark measures pacing cost rather than the entire Expo suite. Fresh independent review found no remaining important issues in this final source.

GitHub denied the programmatic re-review request for this account. @okwasniewski, please re-review f52bdc7 when available.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review (agent-run triage).

Re-review of f52bdc7: every ask is done.

  • waitOutTransition(operation, budget) (surface.ts:1249) is now the shared primitive. Control and root paths each wait once, and fill waits once and then relocates.
  • The bench:ab numbers hold up. They show about transition of extra time per back-to-back screen swipe, and main's times don't change with the budget.
  • The agent-origin path is covered now: forcing the wait for agent swipes fails "keeps agent-origin screen swipes immediate with driver settling".
  • Budget semantics: when the wait can't fit, it throws OPERATION_TIMEOUT (not retryable) before anything is sent. For taps and fills, main already failed with the same code, just later. scrollUntilVisible still turns a deadline cut into LOCATOR_NOT_FOUND.
  • 13 mutations on surface.ts: 10 killed, and the 3 survivors are equivalent. Mobile unit 505/505, tsc and oxlint clean, CI native jobs green, merges clean on main. #1557 was withdrawn, so that conflict is gone.

Nits (optional):

  • surface.ts:1258: the error message doesn't name the action or the fix (raise timeout or lower transition). It also builds the error outside InputBudget, so it skips spent(). That's safe today only because every wait comes before the first send.
  • surface.ts:1251 and :1270-1271 compute the remaining transition twice. A small helper would remove that.
  • The changeset should say screen swipes and scrollUntilVisible get slower by about transition per swipe. Users will notice it in run times.
  • The it.each([20, 20.5]) case for 20.5 adds little.

Maintainer call: accept about +0.5 s per scripted screen swipe by default, or skip the wait when the previous action was itself a root swipe. #1563 (device.waitForTransition()) is still unanswered.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile screen swipes bypass the transition budget after alert dismissal

2 participants