Repository navigation
Let the Ask arrival rest and the page present before two nightly readings - #358
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
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.
Problem
The nightly leg of
cionf5d4facwent 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— theaarrival is a glide, and the three Tab presses go in while it is still running. The measurement lands mid-flight: sampled here atscrollY1574 with the field 13.4px from the line, while the glide goes on to 1726, where it stands 165px clear. Reproduces on8bf8154on 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#parrives in markup, which is well before the page is presented.presentPagerestores 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 wrappedHTMLElement.prototype.focusnames the caller in every run:openComposer←presentPage(skills/leaf/assets/leaf.js:132) ←readAndPresent.Solution
Both are the class
tests/CLAUDE.mdowns 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 makesscrollBehavior()returninstant, so both ofgoToAsk'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 — withscroll-padding-bottomforced 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 passeduv run pytest tests— 898 passed, 6 skippedscroll-padding-bottomforced to 0: fails atlanded >= 20by 38.6pxpre-commiton the changed filesWhy not a `scrollend` wait
The first version of the options fix waited for the document's own
scrollend, copying the block intest_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, thenscrollToElement(region, scrollBehavior(), "start")for the arrival proper. The instant one fires its ownscrollend, so the wait is satisfied in the window before the glide's first frame. Measured at 390×844 it returned atscrollTop1559 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.
updateFabends withelse 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. Passingfocus: falseatleaf.js:132does 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_markthen finds.lf-fab-baratdisplay: 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