Skip to content

test: focus the diff header directly in the sideways-reader test, without the animated close - #6500

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-5883-diff-fold
Nov 19, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-5883-diff-fold

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

test_a_changed_diff_file_keeps_its_sideways_reader failed intermittently at its first ] because its setup acted during an animated close. The test now focuses the first file's header directly instead. That removes the race: 10 of 10 local runs and 18 of 18 copies at --cpu-throttle 8 pass, against 8 failures in 12 local runs before.

Cause. To reach the header, the test clicked it (closing the file), pressed Tab, refocused the header and pressed ArrowRight to reopen it. A pointer close runs the fold's collapse animation (--lf-motion-fold, disclosure.css). While the collapse runs, the closing file still has height, so its sticky header stays pinned at the window's top. Tab scrolls the next file's comment button into view, and scroll_settled returns at once because the fold doesn't move the scroll. So focus() finds the header on screen and doesn't scroll. When the fold ends, the header sits above the window: in a captured failure it was at top −36 with scrollY still 1433. ArrowRight then lets go of focus the user can't see (letsGo in keyboard/controller.js) instead of opening the file, and ] walks into app/routes.py. That is the end state in every CI failure listed on #5883, including the two after #6279.

Change. Both files start open, so focusing the first header and walking its hunks gives the same starting point. The click, Tab and ArrowRight came with the test's first version (#1624) as setup, not as the behavior under test. What the test protects is unchanged: a refreshed file keeps its sideways scroll and its focused row. The product behaves as designed throughout: a key pressed on a header that has left the screen lets go of it.

Captured failing sequence (event log in the page)
keydown Tab         scrollY 972   header top 397   files open [False, True]
scrollend           scrollY 1433  header top 0     (pinned while the fold runs)
keydown ArrowRight  scrollY 1433  header top -36   focus on header
focusout → BODY     (let-go; file stays closed)
keydown ]           focus on BODY → walks to app/routes.py

A passing run with the same log shows document.scrollHeight shrinking over several frames after Tab (3362 → 3017) with scrollY fixed, which is the fold collapsing.

Refs #5883 — automated triage. The issue's other undiagnosed failures, such as the visual action's Locator.focus timeout, are untouched.

…hout the animated close

`test_a_changed_diff_file_keeps_its_sideways_reader` put focus on the
first file's header by clicking it (closing the file), pressing Tab,
refocusing the header and pressing ArrowRight to reopen it. A pointer
close runs the fold's collapse animation (`--lf-motion-fold`,
packages/diff/styles/disclosure.css). While it runs, the closing file
still has height, so its sticky header stays pinned at the window's top.
Tab had scrolled the second file's comment button into view, and
`scroll_settled` returns at once because the fold moves no scroll. So
`focus()` found the header on screen and didn't scroll. Once the fold
finished, the header sat above the window (top -36 at scrollY 1433 in a
captured failure). ArrowRight then let go of focus the user can't see
instead of opening the file, and `]` walked into app/routes.py, which is
the end state every CI failure showed.

Both files start open, so the test now focuses the first header
directly and walks its hunks from there. What it protects is unchanged:
a refreshed file keeps its sideways scroll and its focused row. The
click, Tab and ArrowRight were setup from the test's first version
(#1624), not behavior under test.

Before: 8 of 12 local runs failed at the first `]`. After: 10 of 10
local runs and 18 of 18 copies under
`leaf-dev suite flake --cpu-throttle 8` passed.

Refs #5883
@max-sixty
max-sixty merged commit 3e7e0fc into main Nov 19, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-5883-diff-fold branch November 19, 2026 07:31
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