Skip to content

Stop the interaction gallery test polling for a ready state the demo plays straight past - #770

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-35268514325
Sep 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-35268514325

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The nightly leg of ci on main went red on run 35268514325: tests/test_site.py::test_interaction_gallery_contains_page_chrome expected the gallery's status to read Ready and read Complete. This holds that leg to the reduced motion the rest of the test already runs under, which is what makes the ready state a state to wait for at all.

The leg switched the page to no-preference and then waited for Ready. With motion allowed, the gallery plays a demo the moment it is both loaded and on screen: syncActive activates the demo, renderControls writes Ready, and maybePlay calls play() — which sets playing synchronously — in the same task. Nothing is painted in between, so Ready is not a state the browser ever shows. What decided whether the test saw one was where the reload's restored reading position left the gallery, which the test never arranged: measured locally, the gallery lands 1235px above the viewport, the demo never starts, and the status rests at Ready; on the CI runner it landed inside the viewport and the demo had played through to Complete before the first poll. The call log in the failing run shows exactly that — Loading…, Loading, Playing, Complete, and no Ready.

Under reduced motion maybePlay returns early whatever the scroll, so Ready — motion will start only when you press Play is a resting state, and the press that follows is what drives the replay. The leg still proves what it is there for: after a reload with the demo's tab remembered, the replay waits for the restored frame instead of failing its first attempt. Motion preference was never its subject — the gallery's own timing does not go through motion(), so the replay path is the same either way.

Reproduction and verification

The CI shape is an arrangement, not a frequency: an init script that holds #bg-interactions in the viewport across the reload makes the old assertions fail with the run's own message, Locator expected to have text 'Ready' / Actual value: Complete. The same arrangement passes with this change, as does the off-screen arrangement the local host produces.

Instrumenting the page after the reload gives the mechanism directly — ['status', '5083', 'Ready', 12602, -1198] (status, ms, text, scrollY, the gallery's top), then the demo starts only once a scroll brings the gallery to intersectionRatio 0.99.

uv run pytest tests/test_site.py -n0 --run-nightly -k interaction_gallery passes (4 tests), and pre-commit run --files tests/test_site.py is clean. The everyday gate is unaffected: test_site.py is nightly-only.

max-sixty pushed a commit that referenced this pull request Sep 18, 2026
…me (#771)

`test_interaction_gallery_waits_for_a_restored_frame_tab` names the
arrangement it needs — a remembered chrome demo whose inner Leaf page is
slow to arrive — and then never makes it. Its init script was written as
a bare arrow function, and `add_init_script` takes source rather than a
function Playwright calls, so the document evaluates the arrow, discards
it, and `Element.prototype.append` is never patched. Wrapping it in the
IIFE the suite's other init scripts use makes the delay real.

Measured on the frame after the reload, with a counter added to the
script body: the arrow form reports `patched False, delayed 0` and the
demo is ready 4.8s in; the IIFE form reports `patched True, delayed 2`
and ready at 7.7s — the two contained `<script>` appends each held back
the stated 2s. The test passes either way, so nothing was red; it was
simply proving the ordinary path twice rather than the slow one it is
named for.

This is the only `add_init_script` call in the suite written that way —
the others pass plain statements or `(() => { … })()`. The same string
form is correct for `evaluate`, which is where the rest of the tree's
`"""() => …"""` blocks live, and which is presumably where this one came
from.

Found while diagnosing the nightly failure in #770; the two changes are
independent.

<details><summary>Verification</summary>

`uv run pytest
tests/test_site.py::test_interaction_gallery_waits_for_a_restored_frame_tab
-n0 --run-nightly` passes on repeat runs with the delay in force, and
`pre-commit run --files tests/test_site.py` is clean. `test_site.py` is
nightly-only, so the everyday gate is unaffected.

</details>

Co-authored-by: leaf-agent <[email protected]>
@max-sixty
max-sixty merged commit 6067849 into main Sep 18, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35268514325 branch September 18, 2026 05:45
max-sixty pushed a commit that referenced this pull request Sep 20, 2026
…test record (#871)

`nightly` on `main` went red at
[41d012d](41d012d)
on two independent browser cases ([run
35490092549](https://github.com/max-sixty/leaf/actions/runs/35490092549)).
This is the second: `test_the_interaction_gallery_drives_real_widgets`
waited for the gallery to report `Playing` and read `Ready` for five
seconds. The gallery reads whether it is on screen from the first record
of an `IntersectionObserver` delivery rather than the last, so one stale
record settles it as off screen for the rest of the page's life.

`([entry]) => { onScreen = entry.isIntersecting; … }` takes the oldest
record in the delivery. A delivery carries every record accumulated
since the previous one, and only its last says where the gallery is now.
Nothing follows to correct a wrong answer, because the observer reports
crossings rather than a state: the flag keeps a position the gallery has
already left until it crosses that boundary again, and a gallery
standing still in front of the reader never does. The callback now reads
the last record.

`threshold: 0.2` goes with it. The flag was read as `isIntersecting`,
true for a single visible pixel, so the declared ratio governed nothing
and only added deliveries at a boundary nobody read — a second reading
of the same fact, free to disagree with the deliveries maintaining it.
Whether any of the gallery is in view is the question playback asks, and
that is now the boundary the observer reports. No behaviour moves with
it.

That `Ready` names the off-screen state is #770's finding on this same
surface: on screen, the task that writes `Ready` goes on to call
`play()`, which sets `playing` synchronously, so the browser never
paints it. CI polled `Ready` seven times across its wait, so the flag
stood false for all of it. The gallery's own arrival supplies the
crossings that make it false — under a throttled CPU the observer
delivers `[true, 0.267]` at the fragment position, `[false, 0]` as the
page settles, then `[true, 0.841]` once the semantic arrival pass
scrolls to it — and Chromium coalesces records for a single target when
the main thread is busy between two rendering updates, which a direct
probe on a plain page reproduces as a delivery of `[[true, 0.5], [false,
0]]`. Coalescing the last two arrival crossings leaves the flag on
`false`.

That interleaving would not come out of this host, which is quieter than
CI's two-worker runner, so
`test_the_interaction_gallery_reads_where_it_is_now` states the delivery
shape rather than waiting for it: it arrives with the gallery off
screen, carries each observer record into the delivery after it, and
scrolls the gallery into view. Against `main` the status stays at
`Ready`, the reading CI reported; with this change it reaches `Playing`.

The first failure in that run, a response-surface case with an unrelated
cause, is in a separate PR.

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants