Repository navigation
Edit inside a motion study in place, so a revision keeps the reader's place in it - #5399
Merged
Merged
Conversation
… place in it `lf-motion` declares `x-patch: members`, as `lf-pane` does since #5397, so a revision that changes only what a study holds edits it in place rather than replacing it whole, and the browser's scroll anchoring keeps the node the reader had. `lf-trace` stays undeclared, since the declaration would change nothing there. Pixels are `origin/main` -> this commit, from `leaf-dev probe motion --viewport 390x844 --base origin/main`: a revision adds five paragraphs at the top of the fold study, above the window, while the reader reads its second figure. | | Chromium | Firefox | |---|---|---| | The figure read moves | 43.9px -> 0.9px | 45px -> 2px | | It is the node the reader had | no -> yes | no -> yes | The same paragraphs inserted by script move the figure -0.06px in Chromium and 0px in Firefox, so the 1-2px left comes from the revision install after anchoring has done its part (not isolated). ## The study reads nothing a revision inside it leaves stale The module builds its transport beside the previews and reads only which videos they hold, at the moment it asks. One thing it did build from them at connection: a `loadedmetadata` listener on each video it found, which a recording added by a revision would lack. One capture listener on the study replaces them. It seeks every recording to the clock and repaints the transport, so an added recording stands at the clock's time, and Play draws as available once the study has something to play. ## The example page draws the parts its study holds now The motion example's page module mounted each study once and kept the nodes it found. A study replaced whole came back as a new element and mounted again; a study edited in place doesn't. With this commit's Leaf, a revision that wraps the alternative fold drawing in a frame left the drawing at its authored frame, on arrival and after a seek, with the old script, and drew it on both with the new one. The drawing now reads its parts as it draws, and each `PAGE_INTERFACE` fits and draws them again. The authoring snippet on the page drops its once-per-study guard and assigns `renderFrame` with the nodes the study holds at each `PAGE_INTERFACE`, as `page-behavior.md` asks of a script holding authored nodes. ## lf-trace is not declared A trace's only authored children are `lf-trace-bookmark`s, which hold nothing (`x-content: empty`). For an `x-content: members` widget, `reachesMembers` compares the element's attributes and each child's tag, attributes and text, which is the whole of a trace's markup: wherever it would allow a patch, the markup is unchanged and the trace is already kept. With a scratch declaration, a revision renaming a bookmark still replaced the trace in both arms (Chromium, `playwright-trace-gallery`). That comparison is also what keeps the bookmark list `#build` parses once valid. ## What changes for the user A revision inside a motion study no longer stops it. Playing at quarter speed when a revision landed in it, the fold study on `main` came back paused at 0ms, the time it last saved; it now plays on, 53ms -> 127ms over the next 300ms. A page that assigned `renderFrame` once keeps its drawing, where the study replaced whole came back without one. A recording a revision adds joins the clock. ## Tests - New: `test_a_revision_inside_a_study_keeps_the_paragraph_read_where_it_stood` (both engines). Without the declaration it fails in both: the revision replaced the paragraph being read. - New: `test_recordings_a_revision_adds_join_the_studys_clock`. A revision adds two recordings to an empty study sought to 2s. With a listener per video found at connection they stay at 0 and the wait times out; without the repaint Play stays `aria-disabled`. - Also ran: the four other `test_motion.py` tests, `test_a_display_widget_draws_on_a_page_without_leaf`, `pnpm run test:runtime`, the browser type check, `leaf package check packages/motion --render`, and `leaf page check --render` on the motion example.
leaf-agent
approved these changes
Nov 5, 2026
This was referenced Nov 5, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
`test_a_wait_takes_the_suites_deadline` refuses a literal timeout anywhere in the suite. A deadline sized to the author's machine fails a correct product on a busy runner (`tests/AGENTS.md`, "Functional results do not depend on execution speed"). It has failed in the last two scheduled runs and on current main because of seven new literal timeouts: - #5359: the two pin-clearance `wait_for_function` calls in `tests/browser/margin/test_pins.py`, plus Copy's `click` and the `lf-withheld` expectation in `tests/browser/margin/test_scrollers.py` (`timeout=5000`) - #5399: the motion study's shared-clock wait in `tests/browser/widgets/test_motion.py` (`timeout=10_000`) - #5371: the two closed-tab `data-lf-source` expectations in `tests/browser/widgets/test_code_and_documents.py` (`timeout=15_000`) None of these waits measures how long its subject takes, so each now takes `SERVED_TIMEOUT_MS`, the default that `render_harness` gives every wait that names none. The lint test fails on main `e0c0f9c5f` and passes with this change. These tests also pass with it: `test_a_control_an_authored_anchor_name_moves_into_a_pin_s_seat_moves_the_pin`, `test_a_page_s_reaction_to_a_runtime_mark_moves_a_pin_clear`, `test_a_pin_on_a_code_block_s_first_line_leaves_copy_pressable`, `test_a_row_in_content_skipped_until_near_stands_once_the_page_scrolls_to_it`, `test_recordings_a_revision_adds_join_the_studys_clock` and `test_a_tab_opened_while_closed_documents_draw_reports_its_document_at_once`. `test_a_comment_on_a_closed_tab_s_document_never_reads_as_earlier_data` fails with and without this change: its thread quote is never found, the same failure as in push run [41976158322](https://github.com/max-sixty/leaf/actions/runs/41976158322). Refs #4225 — automated triage 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.
A revision inside a motion study now edits it in place (
x-patch: membersonlf-motion), as #5397 did forlf-pane, so the browser's scroll anchoring keeps the reader's place among its previews. Replaced whole, the study lost the node the browser anchored on: a revision adding five paragraphs at the top of themotionexample's fold study, above the window, moved the figure being read 43.9px in Chromium and 45px in Firefox (390×844). It now moves 0.9px and 2px, and stays the same node. Inserting the same paragraphs by script moves it 0px, so the last 1–2px comes from the revision install itself; I haven't found the step. This is part of the places step of the cutover to one way of knowing what's on screen.What else had to change
lf-motion.jsput aloadedmetadatalistener on each video at connection, so a recording a later revision added would never join the clock: with the declaration alone, an added recording stayed at 0s while the clock read 2s, and Play stayed unavailable. One capture listener on the study replaces them; it moves every recording to the clock's time and redraws the controls. The module otherwise reads its videos fresh each time.examples/developer/motion.page/motion.js) set each study up once and kept the nodes it drew, which worked only because a revision replaced the study and the script set it up again. It now reads its parts as it draws and fits again on eachPAGE_INTERFACE, whichpage-behavior.mdalready asks of a script holding authored nodes; the code sample on the page drops its once-per-study guard.Behavior changed
A revision inside a playing study used to leave it paused at 0ms; it now keeps playing.
lf-traceneeds no declaration: its only authored children are emptylf-trace-bookmarks, so wherever a members patch would be allowed nothing inside it has changed, and the trace is already kept.Tests
In
tests/browser/widgets/test_motion.py:test_a_revision_inside_a_study_keeps_the_paragraph_read_where_it_stood(both engines; fails in both without the declaration) andtest_recordings_a_revision_adds_join_the_studys_clock(times out with per-video listeners, and fails on Play's state without the redraw). The four existing motion tests,leaf package check packages/motion --renderandleaf page check --renderon the example pass.