Repository navigation
Stop the interaction gallery test polling for a ready state the demo plays straight past - #770
Merged
Merged
Conversation
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]>
This was referenced Sep 18, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The nightly leg of
cionmainwent red on run 35268514325:tests/test_site.py::test_interaction_gallery_contains_page_chromeexpected the gallery's status to readReadyand readComplete. 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-preferenceand then waited forReady. With motion allowed, the gallery plays a demo the moment it is both loaded and on screen:syncActiveactivates the demo,renderControlswritesReady, andmaybePlaycallsplay()— which setsplayingsynchronously — in the same task. Nothing is painted in between, soReadyis 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 atReady; on the CI runner it landed inside the viewport and the demo had played through toCompletebefore the first poll. The call log in the failing run shows exactly that —Loading…,Loading,Playing,Complete, and noReady.Under reduced motion
maybePlayreturns early whatever the scroll, soReady — motion will start only when you press Playis 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 throughmotion(), 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-interactionsin 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'stop), then the demo starts only once a scroll brings the gallery tointersectionRatio0.99.uv run pytest tests/test_site.py -n0 --run-nightly -k interaction_gallerypasses (4 tests), andpre-commit run --files tests/test_site.pyis clean. The everyday gate is unaffected:test_site.pyis nightly-only.