Skip to content

test(android-e2e): wait for the foreground to leave the fixture after Home - #5045

Merged
thymikee merged 1 commit into
0.22from
t3/foreground-transition-readiness
Nov 24, 2026
Merged

thymikee merged 1 commit into
0.22from
t3/foreground-transition-readiness

Conversation

@thymikee

@thymikee thymikee commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #4990.

assertHomeAndRecentsRestoration read the foreground once after home, so the smoke lane failed when that read landed while WindowManager was still resuming the launcher. All three reported runs show one ordering: home finished after 55-121 ms (one injected keyevent), the next appstate read started 90-193 ms later, answered in 193-443 ms, and still named com.callstack.agentdevicelab/MainActivity. Run 45068801264's failed-step evidence shows topResumedActivity=NexusLauncherActivity about 1.5 s after the keyevent, so Home did happen; the read was early. #4716 bounded the pixel transition and kept this single read. The lane now waits at that owner with waitForForegroundLeaves — the same deadline, poll and per-attempt bound as waitForSurfaceChange — and reads pixels only once the device reports the foreground left the fixture. A foreground that never leaves fails at the deadline with its last observation. Test harness only.

Before / after

The scenario through runScenario, scripted to answer the first appstate reads after Home with the fixture package:

  • Before: rejects with notStrictEqual, actual = expected = com.callstack.agentdevicelab — the hosted signature.
  • After: fulfills after four read Android Home foreground state (attempt N) steps. A foreground that never transitions rejects at the deadline, before any Home-surface capture.

Validation

Head ae8463ae7c on origin/0.22 (80678b6823). pnpm install --frozen-lockfile, pnpm build, typecheck, format, oxlint, and the five android-emulator-e2e suites passed: 39/39, 7 new tests. pnpm check:affected --run --base origin/0.22 --head ae8463ae7c passed exactCommit=true (receipt .tmp/validation/run-gaUrUm). Hosted Smoke Tests runs the live Android lane; no local device was allocated here.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

… Home (#4990)

The Android smoke lane failed at the Home foreground assertion on three
unrelated 0.22 PRs (jobs 137197315801, 137220955468, 137350879830). Each
run shows the same ordering: `home` finished after 55-121 ms (one injected
keyevent), the next `appstate` read started 90-193 ms later, answered in
193-443 ms, and still named com.callstack.agentdevicelab/MainActivity.
The retained failed-step evidence for run 45068801264 shows
`topResumedActivity=NexusLauncherActivity` about 1.5 s after the keyevent,
so Home did happen; the scenario read the foreground while WindowManager
was still resuming the launcher.

#4716 added the bounded wait for the pixel transition and kept the single
unconditional foreground read. `assertHomeAndRecentsRestoration` now waits
at that observation with `waitForForegroundLeaves` (same owner, deadline,
poll and per-read bound as `waitForSurfaceChange`), and the lane reads
pixels only once the device itself reports the foreground left the fixture.
A foreground that never leaves fails at the deadline with its last
observation; no sleep, no assertion retry, no relaxed check.

Coverage runs through the harness entry: a scripted device that keeps the
foreground stale for the first reads passes only via the wait (the
pre-fix route fails it with the hosted notStrictEqual signature), and a
foreground that never transitions fails the lane before any Home-surface
capture. The wait owns delayed reads, read failures, reads that answer no
package, reads bounded to the remaining deadline, and late observations.
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.05 MB 5.05 MB 0 B
Package (unpacked) 5.05 MB 5.05 MB 0 B
Package (download) 1.54 MB 1.54 MB -6 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 32.2 ms 29.7 ms -2.5 ms
CLI --help 62.8 ms 51.0 ms -11.8 ms

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of ae8463a

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (ecb2089867e9).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

The PR is ready at ae8463a. The new foreground wait in the live-surface transition helper looks correct, and the required evidence is in place. The checks show everything passing except the two cancelled Body rules runs, which only exercise PR body text and not the files this diff changes, so those need a rerun before merge. No conflicts. Not blocking, and fine to take or leave: waitForForegroundLeaves at https://github.com/callstack/agent-device/blob/ae8463a/test/integration/android-emulator-e2e/live-surface-transition.ts#L118 repeats the deadline, poll and last-observation loop of waitForSurfaceChange, so a follow-up could extract one shared poll helper; and the wait at line 135 ends on any non-fixture package, including a system dialog, as the replaced check did, so Home returning to a launcher is not asserted. Not verified here: the tests were not run locally, the Smoke Tests job log was not inspected, and whether runStep with allowFailure rejects or returns on a CLI timeout was not traced.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit d8e9d8e into 0.22 Nov 24, 2026
16 of 18 checks passed
@thymikee
thymikee deleted the t3/foreground-transition-readiness branch November 24, 2026 07:07
thymikee added a commit that referenced this pull request Nov 24, 2026
… Home (#4990) (#5045)

The Android smoke lane failed at the Home foreground assertion on three
unrelated 0.22 PRs (jobs 137197315801, 137220955468, 137350879830). Each
run shows the same ordering: `home` finished after 55-121 ms (one injected
keyevent), the next `appstate` read started 90-193 ms later, answered in
193-443 ms, and still named com.callstack.agentdevicelab/MainActivity.
The retained failed-step evidence for run 45068801264 shows
`topResumedActivity=NexusLauncherActivity` about 1.5 s after the keyevent,
so Home did happen; the scenario read the foreground while WindowManager
was still resuming the launcher.

#4716 added the bounded wait for the pixel transition and kept the single
unconditional foreground read. `assertHomeAndRecentsRestoration` now waits
at that observation with `waitForForegroundLeaves` (same owner, deadline,
poll and per-read bound as `waitForSurfaceChange`), and the lane reads
pixels only once the device itself reports the foreground left the fixture.
A foreground that never leaves fails at the deadline with its last
observation; no sleep, no assertion retry, no relaxed check.

Coverage runs through the harness entry: a scripted device that keeps the
foreground stale for the first reads passes only via the wait (the
pre-fix route fails it with the hosted notStrictEqual signature), and a
foreground that never transitions fails the lane before any Home-surface
capture. The wait owns delayed reads, read failures, reads that answer no
package, reads bounded to the remaining deadline, and late observations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant