Repository navigation
Record no page place for a key pressed with nothing focused, and give focusInPage one home - #5425
Merged
Merged
Conversation
…press in it In a workspace, j, k, d and u moved nothing from a fresh load, and since #5228 they also moved nothing after a click on a pane's words or a wheel in it. The first press now moves the page's largest pane with more to show, and a press or wheel in a pane gives that pane the keys. #5228 widened pageDocument() to body, so inPage(document.body) became true, and focus on the body, which stands on nothing, read as standing in the page. focusInPage answers that question once for userReadingRegion, pageReadingRegion and version.js's place recorder, whose page place outranked the one the reader made in a pane. With nothing named, mainReadingRegion answers where the page has nothing to scroll, and a step the keys take names its region as a wheel does, so a walk goes on from where it reached. Closes #4062. The focus mark and the pane-to-pane key stay postponed until a user loses track of the active pane. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Takes mainReadingRegion, actedIn and their tests and docs off this branch, for a separate proposal, and returns #4062's reference to Refs. What stays is focusInPage, which the three readers #5228 changed ask: userReadingRegion, pageReadingRegion and version.js's place recorder. A new test holds the wheel and the walk from a pane, with the rail holding the most to scroll so that a pane chosen for the user can't pass it. Refs #4062 Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
marked this pull request as ready for review
November 5, 2026 09:12
leaf-agent
previously approved these changes
Nov 5, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
test_a_click_on_a_panes_words_makes_it_the_subject_of_every_scroll_key failed on this review's runner, but not because of this change. Its #right-start click timed out because the "Comment on pane · Left reading" face (.lf-response-face) blocked the pointer. Current main fails the same way there, and on both runs the test stopped before reaching the code this PR changes. The two new tests, which take the same click-on-words route through #rail-words and a wheel, pass both locally and in this PR's test job.
test_motion_preference_changes_are_heard_without_reloading stubs requestAnimationFrame and reads a frame request after `d` as the glide starting. rendering.js asks for a frame only when none is pending, so a frame already queued takes the glide's first tick without a new request, and the count read 0. On main the keydown recorder, which focusInPage now stops for focus on the body, happened to make the request, so the test failed alone on this branch and passed in a batch. It now lets the page render what it queued before stubbing. With the tick's own reduced-motion check removed it fails, "an active glide kept moving". Refs #4062 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
previously approved these changes
Nov 5, 2026
#5468 landed the same body-focus predicate for userReadingRegion and pageReadingRegion, as a local focusInPage in reading-regions.js, and its own fix to the motion test. This keeps main's motion test, and keeps one focusInPage, in passages.js with main's wording, since version.js's place recorder, which main left on inPage, reads it too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…e-fallback Carries #5425's merge with main: one focusInPage in passages.js, and main's motion test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Nov 5, 2026
This was referenced Nov 5, 2026
Closed
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
… page (#5511) Since #5228, focus in a comment editor seated in a widget's outlet no longer counts as focus in the page, so the version controller never records it as the user's place, and a resize leaves the editor scrolled out of view. On the visual review journey at a phone width, the page stayed at the top with the editor's field at y=1187. **Cause.** `focusInPage` (`browser/runtime/passages.js`) is `at !== body && inPage(at)` after #5228 and #5425, and `inPage` excludes every runtime surface, `.lf-chrome, [data-lf-runtime]`. The seated editor's bar carries `data-lf-runtime`, so `recordCurrentLocation` (`version.js`) returns early for it. Before #5228 the check was `under(at, main)`, which a seated editor passed. **Change.** `focusInPage` climbs from a Leaf surface to the element it is seated in, then asks the original question of that element: under `body`, not `body` itself, and not a Leaf surface. A comment editor in a widget's outlet stands in the widget, so it counts. The hidden field Copy appends to `body`, which `copy-control.js` marks so that its focus "isn't the page's", stands on `body`, so it doesn't. The chrome stands on `html`. `inPage` still answers for authored content, and the two `reading-regions.js` callers keep #5425's exclusion of `body`. **Tests.** `tests/browser/test_render_visual_review_journey.py::test_visual_review_keeps_its_inline_comment_editor_in_view_after_phone_resize[600]` and `[760]` failed on main and pass with the change. `test_panes.py::test_a_wheel_or_a_press_on_words_gives_a_pane_the_reading_keys_and_the_walk`, which #5425 added for the `body` case, still passes. Refs #5475 — automated triage --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: leaf-agent <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
…t stand beside (#5512) On a workspace with two panes side by side, a click on the left pane's words shows the resting comment box (#5428) over the right pane's first line. The next click there opens the box instead of reaching the page. This keeps the box off any target with no margin beside it, as #5428 described: "Without room there, as on a workspace page or in a window under about 1340 px, it waits for the press". **Cause.** The placement (`browser/runtime/annotation-overlay/composing/floating-response.js`) withholds the resting box only when its seat is above or below the target. Clicking the pane's words focuses its scroller, so `c` names the whole pane. The seat on the right has 600 px of room, but that room is the neighbouring pane, not a margin: a workspace keeps no rail, and a pane isn't in the column the rail lies beside (`margin-layout.js`). **Change.** The resting box also waits for `c` when the rail doesn't stand beside its target. That fact now has one home, `railStandsBeside(target)` in `margin-layout.js`, which `marginSpot` reads too; the box no longer infers it from `place.margin`, which can be a shown row's rectangle wherever the rail stands. Pressing `c` still opens the comment box. The module header now says so. **How #5228 relates.** The box came after #5228. #5475 bisected the panes test to #5228, which first broke it at `userReadingRegion()`; #5425 fixed that, and the click then hit this box. **Tests.** `tests/browser/navigation/test_panes.py::test_a_click_on_a_panes_words_makes_it_the_subject_of_every_scroll_key` failed on main and passes with the change. The new `test_the_box_waits_for_the_press_beside_a_pane_the_rail_does_not_stand_by` covers an empty pane and a pane already showing another comment's pin. The resting-box tests in `tests/browser/navigation/test_commenting.py` pass, including `test_the_box_waits_for_the_press_with_no_room_beside_its_target`. Refs #5475 — automated triage --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 8, 2026
#5425 landed the repair this branch sat on, so its focusInPage move and its wheel test are main's now. passages.js takes main's focusInPage, which #5511 extended to Leaf surfaces seated in the page. reading-regions.js keeps this branch's chosen region beside main's removal of the local focusInPage. test_panes.py keeps #5512's resting-box test, the wheel test once, then this branch's two tests. Refs #4062
max-sixty
added a commit
that referenced
this pull request
Nov 9, 2026
…the page ahead of it (#5456) On a fresh workspace load, `j`, `k`, `d` and `u` move nothing: nothing names a pane yet, and the page they go to has nothing to scroll. With this change, a step the page can't take goes to the page's largest pane, and names it. This is a new policy, taken as a call Max may reverse; the repair it builds on is #5425. Refs #4062. The focus mark on the active pane and the key that moves from pane to pane stay postponed until a user loses track of the active pane, or tabs through a pane to reach the next one. The diff against `main` is +338/−14 across 4 files: `browser/runtime/navigation.js`, `browser/runtime/reading-regions.js`, `docs/ui.html` and `tests/browser/navigation/test_panes.py`. ## The rule With no region named, the page takes each step it can. - **A step down the page can't take** goes to the largest shown region on the page with room below. Area is counted in whole pixels. Of two the same size the one with the most to scroll goes first, then the first in reading order. - **A step up** chooses a region the same way, but only while the window holds all of `main`, top and bottom: on a page that doesn't scroll, or on one that scrolls only by a footer after `main`. On a long page, `k` at its top moves nothing, as it does today, and so does a short `main` that a site header pushes past the window's foot. - **After a step chooses a pane**, the page stays ahead of it in both directions until the user acts: a press, a wheel, a touch or an arrival. `u` gives the page back the height of a header or footer beside `main` before the pane moves, and `j` takes it again first. The chosen pane is still named for walks, so `m` goes on from where the steps reached. - **A region the user named** keeps the keys, even with nothing to scroll. The code is `regionForStep`, `mainFits` and `stepReading` in `navigation.js`, and `chooseReadingRegion` and `chosenReadingRegion` in `reading-regions.js`. `userReadingRegion` doesn't change here, so `z` and walks answer as they do on #5425 until a step chooses a pane. ## How a step finds the largest pane At the key, `regionForStep` reads the box each unconcealed region's body shows as (`shownBox`, the box `shownRect` clips), clipped to the window, and sorts the regions by that area, largest first. No region shows more of itself than that box within the window, so the walk measures what each region shows only until it reaches a box smaller than the most a region has shown. A pane off screen has a box of 0 there, so only the panes on screen are measured. A key held while the runtime loads reads the same rects when it replays. ## Review findings Each finding was measured in Chromium and Firefox, except the cost, which was measured in Chromium. - **A header or footer beside `main`** gives the page a little scroll: 53 and 125 px on my test pages, 89 and 125 px in the review's. The first version gave the page the keys whenever it could scroll at all, so `j` moved the page twice and then nothing. Now the page takes what it can and the pane takes the rest. - **Ranking:** the first version ranked by box area alone, so of two equal panes it took the first, and on `current-proposed-comparison` that one is the shorter. The second ranked by scroll range alone, and at 900x600 on `alert-review` it moved the side list rather than the item beside it. Area, then range, picks the item panel there and Proposed on `current-proposed-comparison`. - **The stray `k`:** the second version let `k` at a long page's top choose a following log in view. With lines arriving, the log was left short of its newest entry and stopped following, and later keys moved the log rather than the page. A step up now chooses only while the window holds all of `main`. That still lets a fresh `k` move a workspace's following log back from its newest entry, which choosing only on a step down would not. - **`k` after a hand-off** never returned the page, so 89 or 125 px stayed scrolled. A chosen pane now stays behind the page. - **Per-keystroke cost** (Tend's review): choosing measured every region's shown box and scroll range on the keystroke, so the first `j` at 801 panes spent 23 to 31 ms in its keydown handlers, against the 8 ms root `AGENTS.md` gives a keystroke. It now spends 2.1 to 2.3 ms there (see "Cost"). - **Equal panes measured whole** (independent review of an intermediate version, which ranked by areas a size observer recorded): equal boxes tie at the stopping edge, so with 801 panes in 300 px rows, the workspace body at its end and the page's title clicked, the first `j` still measured every pane, 12.1 ms. Clipping each box to the window gives the panes off screen a box of 0; that state now takes 2.8 to 3.0 ms. - **`k` beside a footer** (Tend's review, below its bar): the step up asked whether the page scrolls, so on a fresh workspace with a footer after `main`, `k` moved nothing, where the same workspace without the footer moved its log. It now asks whether the window holds all of `main`. - **`main`'s height is not containment** (independent review): the intermediate version compared `main`'s height with the window's, so a fresh `k` moved a following log on a column page whose 825 px `main` starts about 330 px down a 900 px window. `mainFits` now asks whether `main`'s top and bottom both stand inside the window. - **Tab into a pane the keys chose** (Tend's review, below its bar): not reproduced. On the footer and header test pages in Chromium, after the keys chose the detail pane, Tab into it and then `j` and `u` moved the pane and left the page where it stood, as on `main` for a pane the user tabbed into. Tab itself scrolled the page by 41 or 53 px to show the focused pane, which Tab on `main` does too. ## Evidence From a fresh load at 1440x900 unless stated, by real key presses. In the "here" column Chromium and Firefox moved the same amounts on every row. | Page | First `j` on `main` | First `j` here | | ------------------------------------- | ------------------- | -------------------------------------- | | `rust-sort` | nothing | Source pane, 60 px | | `review-queue` | nothing | detail pane, 60 px; the queue stays | | `alert-review` | nothing | queue list, 60 px, its only region | | `alert-review` at 900x600 | not run | item panel (586 px wide), 60 px; the list (288 px) stays | | `current-proposed-comparison` | nothing | Proposed pane, 60 px; Current stays | | `code-comparison` | nothing | preview, 22 px, its whole range | The "on `main`" column is Chromium on every row, and Firefox on `rust-sort` and `review-queue`, the two pages I ran there. Down and back, `j j d d u u u u`, with the rail beside the detail pane staying at 0 throughout: - **Footer beside `main`** (page range 125 px): the page moves to 60, 120 and 125, then the detail pane to 421. The first `u` returns the page to 0 with the pane still at 421, and the next returns the pane to 0. - **Header beside `main`** (page range 53 px): the page moves to 53, then the pane to 60, 524 and 732. The first `u` returns the page to 0, then the pane goes to 268 and 0. At a long page's end with a log in view, `j j` moves the log to 60 and 120, and `k k` then moves the page up by 60 and 60 while the log stays at 120. These probes gave the same output on this version as before the cost change, in both engines. `k j j k k` from a fresh load on pages with a log at its newest entry, the same in both engines: | Page | First `k` | Then | | ---- | --------- | ---- | | Workspace | log back 60 px | `j` returns the log; `k k` move it back | | Workspace with a footer after `main` | log back 60 px | `j j` move the page; `k k` return it | | Workspace with a header above `main` | nothing | `j` moves the page 53 px; `k` returns it | | Column page, log at the top of a long `main` | nothing | the page takes every step | | Column page, short `main` below a 330 px site header | nothing | the page takes every step | | Column page, short `main` above a tall site footer | log back 60 px | the page takes every step | ## Cost The PR's pages are workspaces of 801 panes in a ten-column grid, each pane holding a 400 px paragraph; the panes are too short for their own headers, so the workspace body overflows and, as the largest region, takes a fresh `j`. The review's page sets the same panes in 300 px rows; its state scrolls the workspace body to its end and clicks the page's title, which names the page, so the first `j` chooses among the panes. Each journey reads, for each keydown: - **handlers**: from a window capture listener, which runs before Leaf's document capture listener, to a document capture listener added after Leaf's; - **dispatch**: from the keydown to a `MessageChannel` message posted at it, the reading the earlier versions of this PR reported. It also counts any frame the browser runs before that message, here the first frame of the glide the step starts; - **main-thread time**: Chromium's `TaskDuration` over the 450 ms after the key. Three rounds of `uv run leaf-dev probe <page> --journey <journey> --viewport macbook --base 567c1e7`, alternating the two pages, at load 5 to 10. 567c1e7 is this PR before the cost change, and each probe runs it and this version back to back. Times in ms, at 801 panes: | Reading | Before | Here | | ------- | ------ | ---- | | Fresh load, first `j`, handlers | 23.5, 31.4, 23.6 | 2.1, 2.3, 2.1 | | Fresh load, first `j`, dispatch | 24.6, 32.5, 41.9 | 11.3, 13.1, 3.6 | | Fresh load, `k` with no pane to move, handlers | 2.0, 2.6, 2.1 | 1.6, 1.7, 1.5 | | 300 px rows at the body's end, first `j`, handlers | 20.8, 12.0, 11.7 | 2.9, 3.0, 2.8 | | 300 px rows at the body's end, first `j`, main-thread time | 73.8, 62.7, 59.7 | 52.4, 51.5, 52.5 | The key's own work fits the budget in both states. Each region still costs one rect read and its concealment checks at the key. The dispatch reading mostly measures the glide's first frame whenever the browser runs it before the message, and a `j` in the named workspace body on `main` read 28 to 29 ms there on an earlier run. The main-thread time after a `j` is mostly that glide's frames: in a profile, most of it was the reading-place recorder (`recordPlaces` in `version.js`, through `blocksOnScreen` in `reading-place.js`), which a `j` in the named body on `main` pays as well. ## What I ran - `tests/browser/navigation/test_panes.py`, `tests/browser/projection/test_reading_position.py`, `tests/browser/widgets/test_workspaces_and_bounds.py`, and the 21 tests elsewhere that press a reading key or read a workspace walk, by node id, at two workers: 120 passed. - `pnpm run test:runtime` (898) and `pnpm run check:browser`. - Each new part reverted alone, reading which test catches it: - the walk stopping at a box equal to the most shown, which skips the second of two equal panes: both cases of `test_of_two_panes_the_same_size_on_screen_the_one_with_more_to_scroll_takes_the_step` time out. `test_the_page_hands_a_step_it_cannot_take_to_its_largest_pane_and_takes_it_back` passes with it, since its footer clips both panes as the page scrolls, which is why the new test exists; - `mainFits` by `main`'s height: `test_a_step_up_goes_to_a_log_only_where_the_window_holds_main[site-header]` fails; - a step up choosing only on a page that doesn't scroll: the same test's `[workspace-footer]` case times out. - Each part of the earlier versions removed alone, run before this change and reported in the earlier description, with the step-up test under its earlier name: no fallback, the old page-can't-scroll-at-all guard, ranking by area alone or by range alone, and the chosen pane treated as named fail `test_the_page_hands_a_step_it_cannot_take_to_its_largest_pane_and_takes_it_back`; a region before the page fails that test and `test_a_step_up_goes_to_a_log_only_where_the_window_holds_main[long-page]`; no name on the chosen pane fails the first, where `m` doesn't reach `#second`; a step up choosing on any page fails `[long-page]`, where the log moves 60 px off its newest entry. I did not run WebKit, or `leaf page check --render` over the corpus. `leaf-dev bench` generates no page of panes, so the cost readings come from the probes above, not from the bench. This adds no work on the startup path, so I made no base and head startup comparison. ## Calls Max may reverse - **The rule at all.** Leaving the keys dead until the user acts in a pane is the alternative, and it needs no code. #5425 stands either way. - **The page ahead of a chosen pane in both directions**, rather than the pane first and then the page, as native scroll chaining orders an inner box and its outer one. The page carries the pane, so the reader sees the text move by each step either way. This order also leaves a `k` to the page after a `j` at a long page's end has moved a log. The cost is that the log stays where that `j` left it. - **Area before range.** A long narrow rail never wins over a wider pane with less to scroll. That matches what the review found on `alert-review`, and the range tie-break keeps Proposed on `current-proposed-comparison`. - **Whether the window holds all of `main`** as the test for a step up. A workspace with a header above `main` fails it, so a fresh `k` there moves nothing, as before this PR. A short page with a tall site footer passes it, so `k` at its top moves a log in view there. ## Still failing Space, PageDown and the arrow keys on a fresh workspace move nothing in Chromium or Firefox (`rust-sort`), since they stay the browser's own keys and focus stands on the body. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[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 key pressed with focus on the body, which is where focus stands after a click on words or a wheel, no longer records a place for the page. That place outranked the one the reader made in a pane, so a window narrowed afterwards left them at the top of the page rather than on the paragraph they had read. Recording it on every keydown also cost 303.8 ms per key on a workspace of 801 panes.
Refs #4062. That issue's fresh-load gap, where the keys move nothing before the user acts in any pane, stays open here; choosing a pane for the user is proposed separately in #5456.
Cause
#5228 widened
pageDocument()frommaintobody, soinPage(document.body)became true. The browser gives the body focus whenever focus stands on nothing. Three readers asked whether focus stands in the page, and each then answered yes. #5468 fixed two of them,userReadingRegionandpageReadingRegion, with a localfocusInPageinreading-regions.js, and fixedtest_motion_preference_changes_are_heard_without_reloadingtoo. The third,recordCurrentLocationinversion.js, still readsinPageonmain.Change
focusInPagemoves topassages.js, besideinPage, and all three readers import it: one home for the question, with #5468's wording.browser/AGENTS.md, "One answer for each question", names it.Evidence
A wheel in a pane, a key, then a window narrowed to 520 px, in Chromium: on the parent of #5228 and on this branch the page returns to the paragraph the reader had reached (
scrollTop941). WithinPageback in the recorder it stays at 0.Keydown dispatch for a key pressed with focus on the body, on a workspace of N panes, in ms. The
mainfigures are one run at 22accdd, and this branch's the range over three rounds before the merge:maininPageOn
main, four times the panes cost 8 to 14 times as much per key, which rootAGENTS.md, "Responsiveness", rules out. The last column shows that the recorder alone holds that cost. I measuredkandj; the recorder runs on every keydown, so I expect the same of other keys, but did not measure them.What I ran
On the merge with b5f5c5d:
test_a_key_pressed_with_nothing_focused_keeps_the_place_read_in_a_panepasses here, and fails onmain's runtime withassert 0 > 0.test_a_wheel_or_a_press_on_words_gives_a_pane_the_reading_keys_and_the_walkpasses here and onmain's runtime. Let a key go of focus the user can't see, and read where they are by one rule #5468 fixed the readers it holds, so it now guards them.test_motion_preference_changes_are_heard_without_reloadingpasses. Before the merge, the 46 tests by node id that press a reading key, read the region answer or restore a place all passed at two workers.pnpm run test:runtime(815 passed) andpnpm run check:browser.test_a_click_on_a_panes_words_makes_it_the_subject_of_every_scroll_keyfails here and onmain's runtime alike: the resting "Comment on pane · Left reading" button that #5428 added covers#right-start, so the click never lands.I did not run WebKit, or
leaf page check --renderover the corpus. The change adds no work on the startup path.