Skip to content

Let the Ask arrival rest and the page present before two nightly readings - #358

Merged
max-sixty merged 2 commits into
mainfrom
fix/ci-34058747810
Sep 6, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/ci-34058747810

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The nightly leg of ci on f5d4fac went red on five readings. Three are the live interaction gallery's and are already fixed in #353. The other two are this PR's, and neither comes from that commit's diff — each is a reading taken while its page was still moving.

test_a_selected_question_keeps_one_action_context_while_tab_reaches_its_field — the a arrival is a glide, and the three Tab presses go in while it is still running. The measurement lands mid-flight: sampled here at scrollY 1574 with the field 13.4px from the line, while the glide goes on to 1726, where it stands 165px clear. Reproduces on 8bf8154 on this runner every time. CI has read 11.4px and #353 read ~1.5px from the same assertion, which is the same fault sampled at three points of one animation.

test_a_draft_that_outlives_its_passage_returns_with_that_passage — the test selects its passage after #p arrives in markup, which is well before the page is presented. presentPage restores a standing draft into the composer and that restore focuses the field; normally it runs before the click, the click blurs it, and the assertion passes. Under load the click gets there first and the restore's focus lands on a field the test has already read. Reproduced 1 in 8 with four spinners running, and a wrapped HTMLElement.prototype.focus names the caller in every run: openComposer ← presentPage (skills/leaf/assets/leaf.js:132) ← readAndPresent.

Solution

Both are the class tests/CLAUDE.md owns under A state the page passes through is not a state to poll for — state the ordering rather than repeat the gesture.

The options reading asks the arrival for no motion at all: page.emulate_media(reduced_motion="reduce") before the press makes scrollBehavior() return instant, so both of goToAsk's document scrolls — the instant reveal and the glide onto the region — land inside the press and there is no settling frame for the Tab presses to race. It also stages the ask in a 390×640 window instead of 390×844, and asserts the field is under the line before the presses: with the whole ask on screen after the arrival the Tab stop needs no travel at all, so the old reading went green over the scroll it is about. Checked against that — with scroll-padding-bottom forced to 0 the browser leaves the field 38.6px under the line, and with it the field lands 224px clear.

The outbox reading goes through navigate, which waits on the page's three readiness stamps, so the selection is a gesture the reader could actually have made.

Testing

  • uv run pytest tests/test_render_options.py tests/test_render_outbox.py --run-nightly — 87 passed
  • uv run pytest tests — 898 passed, 6 skipped
  • each repaired reading 6× on its own under four spinners: both stable
  • bug-back on the options reading with scroll-padding-bottom forced to 0: fails at landed >= 20 by 38.6px
  • pre-commit on the changed files
Why not a `scrollend` wait

The first version of the options fix waited for the document's own scrollend, copying the block in test_render_controls.py. That wait returns at the arrival's first rest, and an unframed page ask has two document scrolls: scrollToElement(next, "instant", "nearest") to reveal it, then scrollToElement(region, scrollBehavior(), "start") for the arrival proper. The instant one fires its own scrollend, so the wait is satisfied in the window before the glide's first frame. Measured at 390×844 it returned at scrollTop 1559 while the glide ran on to 1726. The block it was copied from pairs that wait with the mark reaching its computed destination, which is what makes it a wait on the final scroll; the pairing did not come across. It did not fail at 390×640 only because that height happens to make the arrival a single instant scroll — so the reading was held still by the window, not by the wait it claimed to stand on.

One seam this did not fix

The restored composer stands only because it takes focus. updateFab ends with else if (fabAnchor?.quote && !fabHoldsCapturedPassage()) showFab(null), and after a reload there is no page selection, so the field holding focus is the only thing keeping the bar up. Passing focus: false at leaf.js:132 does stop the restore taking a keyboard the reader never gave it — a reader who picks a passage out while the page is starting gets their cursor moved into a box they did not open — but it also takes the restored box down: test_the_composer_never_stands_on_its_own_mark then finds .lf-fab-bar at display: none. Giving a restored draft its own hold on its passage is a change to what keeps that bar standing, so it is not in this PR.


Automated fix for failed run

…ings

The nightly leg of ci on main went red on two readings that each measure a
page mid-transition.

test_a_selected_question_keeps_one_action_context_while_tab_reaches_its_field
pressed Tab into the glide the 'a' arrival starts, so the clearance it read
was a position the document was still passing through. It now waits for the
document's own scrollend before pressing, and stages the ask in a window
short enough that the add field really is under the key line when the reader
arrives -- with the whole ask on screen the Tab stop needs no travel and the
reading says nothing about the reservation it names.

test_a_draft_that_outlives_its_passage_returns_with_that_passage selected its
passage after the paragraph arrived in markup rather than after the page was
presented, so on a loaded runner the click landed before presentPage restored
the standing draft and the restore's own focus call took the field the
assertion had just read. It goes through 'navigate', which waits on the
page's three readiness stamps.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The outbox reading is sound: presentPage sets the presented stamp and calls openComposer for the standing draft in the same synchronous task, so navigate's stamp wait cannot return between them — the restore's focus is now always before the click that blurs it, rather than usually.

One finding on the options reading, inline: the scrollend wait returns at the arrival's first rest, which is the instant pre-scroll's rather than the glide's destination. What holds that reading still is the 390x640 window, not the wait.

Measured on this runner, with the PR's own listener

At 390x844 — the height this PR replaces, same code otherwise — wait_for_function returns at scrollTop 1559 with only two entries logged, and the glide then runs on without it:

at wait return: [1559, 2]
log: [['scroll', 1559], ['scrollend', 1559], ['scroll', 1562], ['scroll', 1574],
      ['scroll', 1614], ['scroll', 1683], ['scroll', 1698], ['scroll', 1708],
      ['scroll', 1720], ['scroll', 1723], ['scroll', 1725], ['scroll', 1726],
      ['scrollend', 1726]]

The 1574 reading the description reports from CI is the fourth entry in that log.

At 390x640 the whole arrival is one instant scroll — [['scroll', 1726], ['scrollend', 1726]], stable over three runs — so the wait is satisfied by the first poll and never has a second rest to miss.

The window change itself checks out, and the description's claim about the old one is right: under reduced_motion="reduce" at 390x844 the field lands 165px clear of the key line before any Tab is pressed, so that reading was green over no travel at all. At 390x640 it lands 38.6px under the line, and the three presses take it to 224px clear.

Comment thread tests/test_render_options.py Resolved
The scrollend wait this reading used returns at the arrival's first rest,
which for an unframed page ask is the instant reveal scroll's rather than
the glide's destination: goToAsk makes scrollToElement(next, "instant",
"nearest") before scrollToElement(region, scrollBehavior(), "start"), and
the first fires its own scrollend. Measured at 390x844 the wait returns at
scrollTop 1559 while the glide runs on to 1726. What held the reading still
at 390x640 was the window height, which happens to make the arrival a single
instant scroll, not the wait -- so the guard read as stated while standing on
something else.

Motion is not what this reading is about, so the arrival is asked to make
none: under reduced motion scrollBehavior() is "instant", both scrolls land
inside the press, and there is no settling frame for the Tab presses to race.
That is the arrangement test_render_conversations.py and test_render_drafts.py
already use for motion that is not the subject.
@max-sixty
max-sixty merged commit 5751266 into main Sep 6, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix/ci-34058747810 branch September 6, 2026 23:26
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