Skip to content

test: run the file editor's save-retry test on real animation frames - #6905

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-6903
Nov 23, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-6903

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

test_file_editor_adopted_text_starts_undo_history_and_save_retries failed on main in run 45249094355 with moved-without-input on the editor's .cm-gutterElement rows, by (0, 4) and (0, 14). The shift was made by the test's own fake clock. This PR removes the clock from that test.

Cause. The test installed page.clock, and Playwright's clock turns requestAnimationFrame into a timer (clock.addTimer({type: "AnimationFrame", delay: clock.getTimeToNextFrame()})). When the file's text arrives, the widget's resume calls view.setState, which builds a new CodeMirror ViewState whose height oracle starts at lineHeight=14 and then calls requestMeasure(). With real frames that measure runs before the next paint. On a fake frame it runs as an ordinary timer task, so a real paint can show the gutter rows at 14px before the measure moves them to the editor's 24px lines. The watch sees that move with no input. A probe put it during page load, about a second before the test's first gesture.

Change. The clock only skipped the 500 ms save delay before the Retry check, and expect(retry).to_be_visible() already waits for that event. The test now runs on real time with every assertion unchanged. It still checks that adopted text starts undo history and that the save shortcut retries a failed write.

Evidence (leaf-dev suite flake on Linux):

condition before after
--cpu-throttle 8 11 of 12 failed, same finding as CI 18 of 18 passed
--cpu-throttle 16 — 9 of 9 passed
--load 2 — 9 of 9 passed

Two more checks:

  • With the clock still installed but real requestAnimationFrame restored by init script, 12 of 12 passed. That isolates the fake frame as the cause.
  • The last green commit 1bf92095f fails 6 of 6 at throttle 8, so this is a latent race that a slow frame exposes, not a regression in the range.

#6872 recorded the same failure on the macOS scheduled run, with the same ERR_FAILED and gutter-shift diagnostics, and left it waiting on a recurrence. This PR covers that entry too. #6872 stays open for its read-state teardown shift.

The same mechanism can reach any clocked page whose widget measures in requestAnimationFrame after a DOM write. Two other tests in this file install the clock and have shown no such failure, so this PR leaves them alone.

Refs #6872
Closes #6903 — automated triage

`test_file_editor_adopted_text_starts_undo_history_and_save_retries`
installed Playwright's clock, which replaces `requestAnimationFrame` with
a timer. When the file's text arrives, `view.setState` gives CodeMirror a
fresh height oracle (14px lines) and requests a measure; on a fake frame
that measure runs as a timer task, so a real paint can show the gutter at
14px rows before the measure sets them to the editor's 24px. The motion
watch reported that correction as `moved-without-input` on
`.cm-gutterElement`. A real browser runs the measure before the paint, so
no user sees it.

The clock only skipped the 500ms save delay before the Retry check, which
`expect(retry).to_be_visible()` already waits for. The test now runs on
real time. Under `leaf-dev suite flake --cpu-throttle 8` it failed 11 of
12 copies before the change, and passes 18 of 18 after, plus 9 of 9 at
throttle 16 and 9 of 9 under `--load 2`. The behavior it protects
(adopted text starts undo history, the save shortcut retries a failed
write) is unchanged.

Closes #6903
@leaf-agent
leaf-agent merged commit ad9e350 into main Nov 23, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-6903 branch November 23, 2026 22:09
leaf-agent added a commit that referenced this pull request Nov 24, 2026
…#6974)

`test_a_page_seat_the_open_panel_stands_over_is_not_read` failed on
macOS at teardown with `moved-without-input` on the diff's `leaf-text`
(−257 / −297 px). The test scrolled to the agent's answer as soon as the
answer entered the DOM. On a starved runner, the answer's layout (the
thread outlet growing 150 → 238 px) and the scroll then land in the same
frame. The shift watch sees the outlet grow without any input and
reports it, even though the answer was still below the window's foot
when it was drawn. The test's own docstring says the answer "arrives
below the window's foot, where it is drawn at once", so the test now
waits for `rendered(page)` after the answer appears and before it
scrolls. No runtime code changes.

On the macOS runner (`ci` dispatched with `leaf-dev suite flake
--workers 3 --load 2`):

- main at `bd26a80ca`, 27 copies of each parameter: 8 of 54 failed with
the same shift ([run
45342510720](https://github.com/max-sixty/leaf/actions/runs/45342510720))
- this branch, 54 copies of each parameter: 108 of 108 passed ([run
45342507421](https://github.com/max-sixty/leaf/actions/runs/45342507421))

This was the last test on #6872 still owned there. #6887 fixed the
pr-walkthrough ring and #6905 fixed the file editor test. The
align-current-item and motion-recording tests passed every copy on the
macOS runner, so they wait for a recurrence, and the next failed run's
report will bring them back.

Closes #6872 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 24, 2026
…ion frames (#7027)

`test_file_editor_status_controls_take_a_finger_on_a_phone` failed on
macOS in scheduled [run
45378690705](https://github.com/max-sixty/leaf/actions/runs/45378690705)
with `moved-without-input` on the editor's `.cm-gutterElement` rows by
(0, 4) and (0, 14). That is the shift #6905 traced to Playwright's fake
clock in the neighbouring `adopted_text` test, and this test installed
the same clock before the page loaded. The clock turns
`requestAnimationFrame` into a timer, so CodeMirror's measure after
`view.setState` can land after a real paint, and the watch sees the
gutter rows move from their 14px estimate to the editor's 24px lines
with no input.

The clock only advanced the 500 ms save delay and the retry's wait, and
`short_aims` already waits for each control to be visible before
measuring it. The test now runs on real time with every assertion
unchanged: Retry and the conflict menu still have to be finger-sized at
390px under touch.

**Evidence** (`leaf-dev suite flake --cpu-throttle 8` on Linux):

| | failed |
|---|---|
| main at `e80dd78be` | 11 of 12, same gutter finding as CI |
| this branch | 0 of 18 |

The other clocked test in this file installs its clock after the editor
has loaded and has shown no such failure, so it is left alone.

This was the last open item in #6872: the ring, the `adopted_text` save
test and the read-state shift were fixed in #6887, #6905 and #6974, and
the align and motion tests wait for a recurrence.

Closes #6872 — automated triage

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.

ci failing on main (push)

1 participant