Skip to content

Fail a gesture whose own scroll carries the control it was pressed on - #3921

Merged
max-sixty merged 2 commits into
mainfrom
shift-watch-gesture-scrolls
Oct 25, 2026
Merged

max-sixty merged 2 commits into
mainfrom
shift-watch-gesture-scrolls

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The shift watch compares positions in layout coordinates, which remove
scrolling, and credits every move inside a gesture's rendering to that
gesture. So when Leaf scrolled during a gesture, the control under the
user's aim moved on screen and no test failed: before #2895, a send
scrolled the window 9px and the reply box went 9px up the screen while
its page position, which is all the watch compared, stood still.

What the watch checks now

Each press or key has an aim: the control a press lands on, or the one
holding focus for a key. Through the gesture's rendering the watch reads
the aim fresh in viewport pixels, beside the scroll offsets of the boxes
that carry it, and reports gesture-scrolled where a scroll carried it
on screen. A scroll may hold the control still, or take back part of
what the gesture's own layout moved it, as the #2895 send landing does
once the reply row reaches the band's foot, but not carry it further.

  • Exempt: a command that takes the user somewhere declares travels on
    its register row, and the dispatcher's lf-command-invoked carries it
    to the watch, so no list lives in the watch. A link's activation and a
    key the page leaves to the browser (Tab, Space, arrows) are exempt by
    the platform's own meaning, and wheels and drags aim at nothing.
  • Attribution: a scroll counts only where the gesture's own work called
    a scrolling API (focus without preventScroll included), which
    input_work_watch.js names the input of. A call from work no input
    owns during the rendering, as a test's script scrolling the page,
    leaves the gesture unjudged. A first version without this blamed a
    test's scrollIntoView on the click before it.
  • Known gap: a scroll begun where the input's source is lost, after a
    native await or in an observer's delivery, goes unjudged. The margin
    card's room-making scroll (makeRoom) is one; the Stability contract
    allows it anyway.

travels is declared on the walks and scrolls (t, m, d/u,
j/k, align, n search steps, row walks that scroll, tab walks, the
command reference's list, diff hunk and file steps, visual review
cases), Go-to's destinations and hint choices, first unread, Resume
writing, c, which goes to the box it names, and a board card's
keyboard move and its cancel.

Landings it caught, now fixed

  • Escape from a page thread's box, onto a thread that fits but whose
    head the user had scrolled above the window, scrolled the head back
    and carried the box 49px down (returnToThread, formerly
    standOnThread). A box that still stands in front of the user now
    keeps the thread where it is; a send that gave its box up, as a seat
    does to the thread it starts, still brings the thread into view.
  • Show or Hide on a thread summary landed the whole thread and lifted
    the toggle 20px in Chromium, 27px in WebKit. scrollThreadIntoView
    now leaves a control the user already sees where it is; a reply row
    pinned to its scroller's foot still lands the thread's end.
  • The Threads list's landing: nothing caught in the panel list tests.

Cost

At --cpu-throttle 4, the watch's frame callback averaged 23.6 and
23.1 ms before and 23.3 and 23.4 ms after, over five watched tests
interleaved, which is inside the run-to-run spread
(notes/shift-watch-cost.md).

Tests

  • test_a_scroll_during_a_gesture_may_not_carry_its_control covers a
    press and a key that scroll, the hold, the take-back, a travelling
    command, a key left to the browser, and a passive scroll inside the
    rendering; the two scrolling cases fail with the judgement disabled,
    and the passive one fails without the attribution.
  • test_escape_from_a_box_leaves_it_where_it_stood fails on main by
    49px; the summary test now checks its toggle, failing on main by 20px
    and 27px.
  • test_sends_from_a_page_threads_box_hold_its_foot_at_the_bands now
    watches shifts. With the send landing reverted to landing the thread,
    the watch reports the reply box moving 11px and 16px.
  • Forcing the watch onto unsurveyed tab and merge-film tests still
    reports pointer presses; TODO.md lists them, since a press has no
    command to declare travels.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits October 25, 2026 01:16
The shift watch compares positions in layout coordinates, which remove
scrolling, and credits every move inside a gesture's rendering to that
gesture. So when Leaf scrolled during a gesture, the control under the
user's aim moved on screen and no test failed: before #2895, a send
scrolled the window 9px and the reply box went 9px up the screen while
its page position, which is all the watch compared, stood still.

## What the watch checks now

Each press or key has an aim: the control a press lands on, or the one
holding focus for a key. Through the gesture's rendering the watch reads
the aim fresh in viewport pixels, beside the scroll offsets of the boxes
that carry it, and reports `gesture-scrolled` where a scroll carried it
on screen. A scroll may hold the control still, or take back part of
what the gesture's own layout moved it, as the #2895 send landing does
once the reply row reaches the band's foot, but not carry it further.

- Exempt: a command that takes the user somewhere declares `travels` on
  its register row, and the dispatcher's `lf-command-invoked` carries it
  to the watch, so no list lives in the watch. A link's activation and a
  key the page leaves to the browser (Tab, Space, arrows) are exempt by
  the platform's own meaning, and wheels and drags aim at nothing.
- Attribution: a scroll counts only where the gesture's own work called
  a scrolling API (focus without `preventScroll` included), which
  `input_work_watch.js` names the input of. A call from work no input
  owns during the rendering, as a test's script scrolling the page,
  leaves the gesture unjudged. A first version without this blamed a
  test's `scrollIntoView` on the click before it.
- Known gap: a scroll begun where the input's source is lost, after a
  native `await` or in an observer's delivery, goes unjudged. The margin
  card's room-making scroll (`makeRoom`) is one; the Stability contract
  allows it anyway.

`travels` is declared on the walks and scrolls (`t`, `m`, `d`/`u`,
`j`/`k`, align, `n` search steps, row walks that scroll, tab walks, the
command reference's list, diff hunk and file steps, visual review
cases), Go-to's destinations and hint choices, first unread, Resume
writing, `c`, which goes to the box it names, and a board card's
keyboard move and its cancel.

## Landings it caught, now fixed

- Escape from a page thread's box, onto a thread that fits but whose
  head the user had scrolled above the window, scrolled the head back
  and carried the box 49px down (`returnToThread`, formerly
  `standOnThread`). A box that still stands in front of the user now
  keeps the thread where it is; a send that gave its box up, as a seat
  does to the thread it starts, still brings the thread into view.
- Show or Hide on a thread summary landed the whole thread and lifted
  the toggle 20px in Chromium, 27px in WebKit. `scrollThreadIntoView`
  now leaves a control the user already sees where it is; a reply row
  pinned to its scroller's foot still lands the thread's end.
- The Threads list's landing: nothing caught in the panel list tests.

## Cost

At `--cpu-throttle 4`, the watch's frame callback averaged 23.6 and
23.1 ms before and 23.3 and 23.4 ms after, over five watched tests
interleaved, which is inside the run-to-run spread
(`notes/shift-watch-cost.md`).

## Tests

- `test_a_scroll_during_a_gesture_may_not_carry_its_control` covers a
  press and a key that scroll, the hold, the take-back, a travelling
  command, a key left to the browser, and a passive scroll inside the
  rendering; the two scrolling cases fail with the judgement disabled,
  and the passive one fails without the attribution.
- `test_escape_from_a_box_leaves_it_where_it_stood` fails on main by
  49px; the summary test now checks its toggle, failing on main by 20px
  and 27px.
- `test_sends_from_a_page_threads_box_hold_its_foot_at_the_bands` now
  watches shifts. With the send landing reverted to landing the thread,
  the watch reports the reply box moving 11px and 16px.
- Forcing the watch onto unsurveyed tab and merge-film tests still
  reports pointer presses; `TODO.md` lists them, since a press has no
  command to declare `travels`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d035ac8 into main Oct 25, 2026
3 checks passed
@max-sixty
max-sixty deleted the shift-watch-gesture-scrolls branch October 25, 2026 08:25
leaf-agent added a commit that referenced this pull request Oct 25, 2026
Let the shift watch recognize standard caret navigation in text editors
even when the editor prevents the browser default to implement it
itself. CodeMirror's PageDown does that: its caret stays at the same
viewport offset while its content scrolls. The new watch from #3921
instead treated that intended movement as a forbidden scroll, failing
`test_file_editor_page_navigation_preserves_the_caret_position` in [the
main run](https://github.com/max-sixty/leaf/actions/runs/40176544925).

Read the caret keys from the runtime's canonical `CARET_KEYS` and
text-entry identity from its existing `typesText` reading. This changes
only the suite's judgment; editor behavior stays the same. Ordinary
edits and presses remain subject to the scroll check.

Validation: the original file-editor test reproduces the 552px finding
on main and passes after the correction. A new regression fails before
this change, then passes while also checking that an ordinary editing
key scrolling the same field still produces `gesture-scrolled`. All
seven existing gesture-scroll cases pass. Ruff checks and formatting
pass. The run's separate trace navigation declaration is in #3924, and
#3922 fixed its board-reference selector failure.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 25, 2026
Declare the recording timeline's first/last capture commands as
`travels`, preserving their existing navigation and scroll behavior
under the gesture watch introduced by #3921. In [the failed main
run](https://github.com/max-sixty/leaf/actions/runs/40176544925), End
reached the last capture but the watch rejected its 784px scroll because
these two command rows lacked the declaration.

The exact failing test,
`test_trace_frames_retain_saved_elements_and_disclosure_stays_closable`,
reproduces on current main and passes with these declarations. Its
assertions still check that saved elements survive capture navigation
and the disclosure remains closable. The file-editor PageDown finding is
a separate watch correction being handled in this CI repair; #3922
already fixed the run's board-reference selector failure.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
`test_the_gallery_embeds_an_ordinary_stamped_page` failed at teardown
with "a scroll during the click on button#bg-durable-frame-open moved
it by (0, -45)px". The feature gallery's button that opens the stamped
v2 frame centred the frame with `scrollIntoView({block: "center"})`,
scrolling the page 45px under the press even though the frame already
showed whole below the button. Since #3921 the shift watch fails a
gesture whose own scroll carries the control it was pressed on.

The button now scrolls the frame only as far as it needs to show
(`block: "nearest"`), so at the gallery's usual window the press
leaves the button where it was. The frame still comes into view where
the window is too short for it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
test_trace_initial_selection_opens_evidence_and_keeps_earlier_empty_stops
pressed ArrowRight on a scope radio and clicked Next as soon as the new
position read 0.015 s. Playwright scrolls Next into view before clicking
(565 to 557 here), and the shift watch added in #3921 charges a scroll
that lands inside a gesture's rendering to that gesture, once the gesture
has called a scrolling API itself (Web Awesome's `radio.focus()` without
`preventScroll`). So the driver's own 8px scroll was reported as the arrow
scrolling the page: 4 of 5 runs on origin/main ca26188, and the macOS
CI run. The journey now waits for the arrow's repaints before the next
press. No product behavior changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
…pressed (#3972)

#3921 failed a gesture whose own scroll carries the control it was made
on unless its command declares `travels`, so a press, which has no
command, could take the user nowhere. The tab tests stayed unsurveyed;
forced on, they reported three `lf-tabs` presses. Max chose: a root
switch travels, the sideways reveal stays, and the embedded move is a
defect.

## What the watch allows now

- A gesture that adds a history entry takes the user somewhere. The
  watch reads it from the Navigation API's `navigate` event (a `push`),
  so the root set's switch, which adds one and opens the view at its
  place, needs no declaration of its own. Renaming the entry the user is
  on (`replaceState`) takes them nowhere. The link exemption stays,
  since a link whose script travels in place of the browser adds its
  entry only after arrival.
- A scroll may bring the pressed control whole into the view of a box
  that showed only part of it (its scrollport less its scroll-padding,
  clear of the control's scroll-margin), by no more than the part it
  hid, as the browser's own focus does. `#showTab` revealing a tab from
  under the strip's edge press is one.
- A scroll counts only on the boxes the gesture's own calls scrolled:
  the box a call names, or every box holding a reveal's or a focus's
  target. Before, once a gesture had called any scrolling API, the test
  driver's actionability scroll before its next press counted too.
- Back and Forward open a rendering, as an input does: the browser's
  chrome makes them, so no event in the page carries them.

## What the forced run reported, measured

- The 295px "root switch" was the driver: after a framed tab's reveal,
  Playwright scrolled the page 370px to reach the next tab, and the
  watch blamed the framed tab's click. Per-box attribution removes it.
- The 51px "reveal" was the driver too. A first tab's ring room at its
  strip's start asked the strip to scroll -35px it could not travel;
  that no-op `scrollBy` marked the press as scrolling, and Playwright
  then scrolled the strip 51px for the next tab. `localScrollBy` now
  clamps every path to what the scrollport can travel, and
  `scrollIntoView` skips a box that won't move. The real reveal on the
  next press is 7px, its ring room.
- The root switch's own landing carries the tab 72px
  (`test_a_tab_layout_completion_preserves_native_navigation`) and is
  now allowed by its entry.
- The embedded set's 24px was scroll anchoring. The browser's anchor
  stood in the panel the switch hides; once anything laid out that
  panel's content again (the watch, a passage read, find-in-page), it
  lost the open panel's 24px padding and the page scrolled by that.
  Unwatched, one `getBoundingClientRect` on the hidden panel's heading
  after the switch reproduced it. A hidden panel or part now declares
  `overflow-anchor: none`: before 229 → 205 scrollY, after 229 → 229.

## Tests

- The tab tests (`widgets/test_tabs.py`, `navigation/test_tabs.py`) now
  watch shifts, except the gallery case whose live revision adds a tab
  set above and moves the strip 430px, recorded in `TODO.md`. The side
  list test's large root font is now the second page's own from first
  paint, since setting it by script moved the page without input.
- `test_a_scroll_during_a_gesture_may_not_carry_its_control` gains an
  entry the press adds (passes) and one it renames (fails); the first
  fails without the `push` rule. It now serves from an origin, which a
  data: URL lacks for the Navigation API.
- `test_a_press_may_bring_its_control_whole_into_its_scroller`: a scroll
  by exactly the hidden 40px passes, 80px fails; without the reveal rule
  the first fails, without its bound the second passes.
- Without the `overflow-anchor` rule,
  `test_embedded_tab_selection_preserves_the_document_reading_position`
  fails 205 vs 229; without the clamp,
  `test_pointer_tab_underline_moves_without_delaying_the_view` reports
  the 51px; without traversal as input,
  `test_back_to_a_fragment_the_page_has_hidden_since_lands_on_it`
  reports a passive 196px move.
- With #3921's Escape landing reverted and its position assertion
  removed, `test_escape_from_a_box_leaves_it_where_it_stood` still
  reports 49px under per-box attribution.

The merge film's Next inspection (83px) scrolls to keep its details in
view rather than to reveal the button, so it stays in `TODO.md`.

> _This was written by Claude Code on behalf of max-sixty_



> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 27, 2026
Main's #3935 builds the grip's arrow routes once, dropping up and down for a
card that shows another widget's answer; the merge names the left and right
routes for the column there. #3921's travels flag stays on the move route.
stills keeps both the phone states and main's metrics states.

Co-Authored-By: Claude Opus 5.5 <[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.

2 participants