Repository navigation
Preserve reader state through edits and refreshes - #1624
Merged
Merged
Conversation
Editing and automatic maintenance must not replay an old arrival. A visible inline reply previously jumped 73 pixels in the document or 19 pixels in a bounded reader on its first keystroke. Reply growth now reveals only the writing area through the shared nearest vertical landing operation. End reaction UI cleanup when the gesture enters the local ledger, let Page Map deferred focus yield to newer input, and remove stale-focus reveal from automatic contents fitting. Keep diff controls, file disclosures, code scrollports, and unchanged rows and gutters connected across patch and manifest refreshes. Prepare current manifest evidence before publishing its source origin, and use one file disclosure load owner across both source forms. Browser regressions cover typing, held responses and frames, resize after wheel reading, diff selections, sideways reading, source-form changes, and recovery after a failed deferred patch. Explicit keyboard arrivals remain covered by the existing navigation contrasts.
…es-reading-position # Conflicts: # skills/leaf/assets/runtime/reactions.js
Keep diff file controls across regular/rename transitions and bind each line comment to its actual gutter, including detached initial rendering. Reuse the shared DOM matcher and incremental text edits for renderer-owned text documents, preserving native selections in unchanged passages. Dispatch command-reference activation in the original gesture after modal close. Rejected commands reopen in a microtask before newer input can intervene. Cover origin arrival, newer-input authority, type roundtrips, current lazy evidence, exact gutter controls, and plain/syntax selection. Adopt the merged carried-history fixture boundary.
leaf-agent
previously approved these changes
Oct 2, 2026
Prepare open manifest evidence without changing accepted file records or native outlets. Publish the complete file reading in one synchronous commit and use the same preparation path for lazy disclosure, removing the intermediate manifest-rendering state. File replacement hands package source focus across its own coordinates while yielding supplied thread/composer outlets to core continuity. Native text/manifest and changed-line/file-kind regressions retain draft text, focus, selected caret range, and document scroll.
leaf-agent
reviewed
Oct 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
I found no actionable issues in this diff, but the red lint check withholds approval. Ruff removes two unused imports in dev/leaf_dev/delivery_eval.py, a file outside this PR; main's lint run shows the same failure. The gate needs a green result before I can approve.
A file opened while a manifest refresh prepared other open evidence could load from the accepted old source, paint a false revision error, and clear its retained rendering. Share the actual source render promise with lazy loading so disclosure reads evidence only after the owning render commits. Keep the existing completion-generation and deferred-source fences. The held-response browser regression reproduces the false error before this change and passes after it; all four inline reply focus contrasts pass again.
…es-reading-position # Conflicts: # skills/leaf/assets/runtime/thread/reply-landing.js
leaf-agent
approved these changes
Oct 2, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 9, 2026
…e page (#1784) Typing in a floating comment box scrolled the page whenever the box stood under or over its passage and grew past the room shown on that side. On every content change, `floating-response.js` asked `makeRoom` to scroll the reading region until the whole box fit clear of the passage. A stack-logged probe at 900x700 measured it. With the box over its passage at mid-window, the first keystroke scrolled the page 162px. With the box under a passage near the top, the page scrolled 55px once the box reached the window's foot. The user's rule is that the box moves and the page stays. The comment box's height may now reach the whole boundary on every side, as it already could beside its passage, and growth never spends scroll travel. It grows from the edge that holds it (#1890 holds a landed box by that edge). Once the window stops that edge, shift slides it over its passage, and once it fills the window it scrolls its own words. This is what a box beside its passage already did at the window's foot. Only a thread card opening under or over its target still scrolls to make room. The margin card's reply never scrolled the page while typing; the same probe confirmed that at both widths. Letting the box fill the window exposed a 2px mismatch at Send. The box reserved 2px less beneath its words than the card's reply row takes, so a card capped at the window's height shrank its transcript and shifted the sent words up 2px (`test_send_grows_thread_around_the_words` at 900x600). One token, `--lf-comment-reply-row`, now sizes both. Behavior changes the tests now protect: - `test_typing_moves_the_comment_box_and_leaves_the_page_still` (new) types line by line into a box under and over its passage and checks that the page never scrolls and the box stays in the window. Both cases fail on main. - `test_a_growing_text_comment_keeps_its_side_and_the_page_still` (was `..._keeps_its_passage_clear_without_changing_sides`) and `test_a_text_comment_chooses_above_when_the_page_has_more_room_there` asserted that typing scrolled the page and kept the passage clear. They now assert that the page stays put, and that a later scroll carries the grown box with its passage. - `test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame` types a shorter draft. In its pane cases, typing used to scroll the pane to make room under the passage, and the test expected the box there. - `test_where_a_comment_stands_before_and_after_send`'s phone case required the box to overlap its block only when the two couldn't show together, which only held while typing scrolled the page. It now requires a box that overlaps to stand at the window's edge. The assets AGENTS.md "Stability" section now says a floating box grows inside the window and never scrolls the page for its growth. A field in flow, which cannot move apart from the page, still keeps its controls in view. ## Add-on F: one shared reading of where the user works The design review proposed one reading of the user's working point, shared by the card's held edge (`holding`, fed by `drafting` in `margin-projection.js`), the place keeper (`recentPlaceInput` in `user-place.js`) and typing growth. This change doesn't add it. I sorted the place- and landing-hold repairs since 2026-09-23 by the question each answered: - Which edge of the card stays still: #1429, #1536, #1552, #1574, #1587, #1771. #1552 and #1574 fixed how the hold was keyed across a second placement pass and across Send's admission, not which point the user works at. - Which item in a scroller stays still: #1045, #1464, #1480, #1549, #1694, #1715, #1735. - What waits behind a notice: #1473, #1493, #1725, #1738, #1742. - What a landing reveals on entering, sending or typing: #1303, #1364, #1571, #1602, #1624, #1626, #1645. - Whether the box or the page moves as the box grows: #1453 and this one. None of these commits names a case where `drafting` and `recentPlaceInput` disagreed, so a shared reading wouldn't have prevented them. The two readings also differ by design. `drafting` counts words left in the reply and a send still in flight, both of which outlast focus and the pointer. The place keeper deliberately follows whichever of pointer and focus came last. Their outputs differ in kind too: one is an edge of a floating surface, the other a node in a scroller's list. The typing scroll was a question of which thing moves, so it needed no working-point reading. One rule does repeat: a focused control counts as the user's place only while it is on screen. `holdBox` (`reply-landing.js`), the place keeper's "begins in the band" filter, and #1735's resize landing each state it. It is a candidate for a shared predicate, but not the primitive F described. ## Overlap with work in other worktrees `leaf.shift-a-thread-jitter` has uncommitted changes to `comment-placement.js`, `floating.js` and `floating-response.js`, based on #1705. Its `floating-response.js` hunk is small. Its `comment-placement.js` header rewrite overlaps the paragraph this change rewrites, so expect a textual conflict there. `leaf.thread-card-margin-avoidance` is mid-merge in `comment-placement.js` and `margin-projection.js`. Neither touches `makeRoom`'s call from `floating-response.js` or the frame tokens. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
pushed a commit
that referenced
this pull request
Nov 19, 2026
…hout the animated close (#6500) `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`](https://github.com/max-sixty/leaf/blob/99ef78526d6bcfe546c389923ed292b36de56226/packages/diff/styles/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. <details><summary>Captured failing sequence (event log in the page)</summary> ``` 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. </details> Refs #5883 — automated triage. The issue's other undiagnosed failures, such as the visual action's `Locator.focus` timeout, are untouched. 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 visible reply used to jump the document on its first keystroke; automatic refreshes and delayed UI work could also reclaim the reader’s place. Editing now reveals only the writing area. Page Map deferred focus yields to newer input, reaction cleanup finishes with its gesture, automatic contents fitting preserves native scroll, and command-reference activation closes and dispatches in the same gesture.
Diff refreshes retain the toolbar, file owners, code scrollports, and unchanged rows and gutters, including regular-file ↔ pure-rename changes. Manifest refresh prepares open evidence without mutating accepted file records or native outlets, then commits the complete reading together. Lazy disclosure waits for the current source-render promise and uses the same preparation path, and repaired errors reconstruct their evidence. File focus fallback yields supplied reply/composer outlets to core, preserving the draft, focus, and selected caret range. Each line keeps exactly one comment control. Bound text documents reuse shared DOM matching and incremental text edits so updating one passage preserves a native selection in another.
Validation: the integrated final tree passes 27 focused browser cases, 193 runtime tests, both command-reference regressions, six evaluation assertions, all lint/import-graph checks, and independent code review. Browser cases include native disclosure during a held source refresh, inline reply draft/caret/focus, file-kind transitions, unchanged selection through edits and insertion, text documents, source-form changes, horizontal wheel/hunk navigation in Chromium and WebKit, and typing in visible replies. The full local Python gate passes all 1,738 tests. Browser framework and Worker checks pass on CI. All combined PR checks pass and the automated reviewer approved the final commit without findings. Against the integrated main baseline, the composed walkthrough retains 222 total and 218 code requests at presentation, with about 13.7 KiB additional code to establish stable inspection owners. Both versions present without console errors.