Repository navigation
Unify focus rings around the logical input destination - #2375
Conversation
Show the same ring after pointer and keyboard arrival throughout Leaf. Derive element, group and public shadow-part paint from the focus owner, retaining it through label presses and refreshing ancestry after retained moves. Keep component-owned classes untouched. Focus the screenshot divider on primary pointer input so keyboard adjustment continues after dragging. Update browser regressions for shadow controls, editors, held labels, forced colors and native reparenting.
Expose canonical focus ancestry on public shadow parts so each field selects its actual carrier. Disable vendor focus paint, replacing the per-control suppressions and preventing an open select from ringing both its field and focused option. Extend the real-browser regression through selection, cancellation, clearing and focus departure.
leaf-agent
left a comment
There was a problem hiding this comment.
The test check is red (7 failures, 16 errors). The focus-paint write failure below reproduces locally; the other failed assertions also need a passing check before approval.
Keep standing and keyboard routing synchronous, and coalesce marker updates through afterScript so native nested dialogs and forwarded arrivals do not remove and restore unchanged paint. Structural invalidations use that same queue. Protect a same-script focus round trip with an observable mutation regression. Keep the thread-notice keyboard regression beside its seat: its former Shift+Tab predecessor was Skip, whose native scroll correctly released offscreen held news before the test tried to activate it.
Recorded checkpoints and screencast frames can have different native extents. Reproduce a viewport resize and assert the retained evidence viewport plus each decoded raster fitting its own dimensions, while preserving exact image and comment restoration coverage.
test_phone_diff_headers_keep_distinguishing_parent_folder_readable failed at teardown on loaded CI runners: the second lf-diff file header "moved without input by (0, 49)px" after the tap that opened the first file. Opening a closed file loads its evidence in a promise (the Markdown grammar and Shiki rendering) that lf-diff declares through `present`, so the page's presentation proof stays pending until the lines land. The shift watch ended a gesture's ownership on `lfRenderingSettled` alone, which by its contract (runtime/rendering.js) cannot see promise-held work. On a slow machine the loop settled before the file's lines arrived, so their growth read as passive. The product behaved correctly: the files below moved because the user opened the one above them. The watch now ends a gesture's rendering once the page has also presented its current publication (`lfReadiness(null, "presented")`), widget preparations included, which is the declared completion `pageReadiness` already states. Deferred arrivals stay outside that credit, so a late arrival still fails as passive. New test: test_an_input_owns_a_widget_preparation_it_began_until_presented holds the Markdown grammar with page.route, so the loop settles while the preparation is pending, and checks that the press owns the growth and that a passive move after presentation still fails. With the old reading it fails with the same 49 px report the CI runs showed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The test check is red: test_phone_diff_headers_keep_distinguishing_parent_folder_readable reports a 49 px passive shift after the mobile diff headers are tapped. I reproduced the teardown error on this head; the same test passes on current main, and it passes on this head when the diff shadow styles are restored from main in an isolated worktree. The new focus styling in that file needs to preserve the header's position through the tap and fold transition.
CI test failed: mobile diff header tap causes a 49 px passive shift.
…readiness The previous commit kept a gesture's shift credit open until the page's `presented` readiness stage, so while any widget preparation was pending the gesture owned every movement on the page. Review showed the cost: with the diff's Markdown grammar held, moving an unrelated control 40 px went unreported. The runtime now publishes each widget preparation's lifecycle on its validation seam (`lfObserveWidgetPreparations`, owned by `attachWidgetPresentation` in semantic-state.js): "begin" when a widget declares it and "settle" in the task that settles its completion. The shift watch records a preparation declared while an input's rendering (or an earlier landing's) runs. When that preparation settles, the watch opens a rendering for the same input that runs until the loop settles again, as the input's own rendering does. A preparation's wait owns nothing, and the gesture's own rendering again ends on `lfRenderingSettled`. test_an_input_owns_the_landing_of_a_widget_preparation_it_began now holds the grammar and checks three things. A control moved while the preparation waits is reported (the reviewer's case, which the page-wide version missed). The landing's push on the files and control after it is the press's. A move after the landing is reported. With landings uncredited it fails at the landing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review of 3106d41 found the credit still too broad. A preparation took as its owner whichever input's rendering happened to be running, so a passive timer that opened a diff file during an unrelated button's counted work gave that file's landing to the button. Its 49 px push on a later control then went unreported. The runtime's preparation identity now names the declaring widget's element (`owner`). Every input rendering the shift watch opens records the node it was aimed at: the pointer or key event's composed target, or the typing field. A preparation belongs to an input only if that target lies inside the declaring widget in the rendered tree and the input's rendering, or a landing it owns, is still running. A preparation started by a timer, by news, or by input aimed at another widget lands passive. New test: test_a_preparation_no_input_aimed_at_lands_passive opens a diff file from a held response the page requested before an unrelated press, while the press's counted work runs. The landing must be reported. With the overlap-only watch from 3106d41 it is not. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…d it Containment still guessed the cause. A passive response opened a diff file while a click on the diff's own filter field ran, and because that click was aimed inside the widget it received the file's landing. Its 49 px push on a later control went unreported. A preparation now belongs to an input only by provenance. The shift watch reads `lfInputWork.current()` as the widget declares the preparation and carries that input to the landing through the preparation's identity, which spans lf-diff's native awaits. A timer, news, or script with no input on the stack leaves the landing passive. Containment, the target recorded on each rendering, and the runtime identity's `owner` field are gone. `input_work_watch.js` makes the opening of a <details> explicit by extending its native activation seam. A summary activation that opens its details records the activating input, and the toggle the browser later dispatches for that opening runs its listeners under that input (unless the click was cancelled). That covers the input's own trusted click (keyboard, mouse) and a click its work dispatches. Leaf's held-word release on pointerup dispatches the summary's click, so the pointerup owns the opening. A script-opened details, or one clicked by a passive timer, opens for no input. test_a_preparation_no_input_began_lands_passive gains the same-widget arm (the click lands on the diff's filter field). The containment watch (0eb1e1d) fails it. The landing-owned test, the elsewhere arm, the phone tap with the grammar held, and Codex's scratch reproductions all pass. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/shift_watch.js # tests/test_render_shift_watch.py
Main's vulture hook, which arrived beside #2345, flags it; pluggy passes a hook implementation only the arguments it names. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… says The input-work watch consumed a recorded summary activation only on a toggle announcing "open". When Enter's click listener opened a file and its native activation then shut it, the one coalesced toggle announced "closed" and left the activation recorded. A script opening the file later inherited the keydown as its cause, so that file's landing moved a control 49 px with no report. The first trusted toggle after an activation now settles it, open or closed. Its listeners answer to the input only for an opening the activation did not cancel. Any other toggle expires the record. The watch listens for toggles on each recorded details itself, so expiry no longer depends on the page having a toggle listener. New test: test_an_activation_that_opens_nothing_leaves_a_later_open_passive, with a cancelled arm and a closed-again arm, requires a later scripted opening to land passive. The closed-again arm fails on 9be86e2. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The new passive-open regression times out before it can check the shift.
A request event precedes route-handler admission. Use the existing holding helper before reading each held retry, preserving the native recovery, duplicate activation, and focus assertions.
After #2375 made Leaf's focus ring follow the logical input destination across pointer and keyboard arrivals, tests in [main CI run 38159211604](https://github.com/max-sixty/leaf/actions/runs/38159211604) still treated pointer-returned focus as absent. Sending a reaction returns focus to its target, releasing a held diff header leaves focus on that header, and a mouse drag leaves the focused resize handle in place. The tests check each focus-owned outline or path reveal while focus stands there, then verify what disappears when focus leaves. The handle case also checks that pointer input clears Chromium's native `:focus-visible` while Leaf's retained focus ring remains. Verification: `uv run pytest -q tests/test_render_gate.py::test_dragging_an_edge_preserves_user_state` (3 passed); the reaction and diff-path cases passed locally after their assertion changes. The branch also includes the served-wait deadline test alignment in #2440, which is being checked separately. --------- Co-authored-by: leaf-agent <[email protected]>
Clicking an anchored thread gave it keyboard focus but hid its ring because the paint depended on input modality. Show the same focus treatment after pointer, touch, and keyboard arrival throughout Leaf.
The shared focus owner now marks the logical input destination and its composed ancestry. Runtime, package, example, and site themes consume that reading; public shadow parts let compound controls select their precise carrier. Disable the vendor's competing native focus paint so an open select rings its current option once, then returns the ring to the field when closed. Held label presses preserve the existing input destination, and retained DOM moves refresh its derived ancestry without another focus event. Paint uses the destination left at the end of each script, so nested dialog transitions and focus forwarding do not remove and restore unchanged markers.
Validation includes the runtime suite, focused browser regressions, source checks, the macOS thread snapshot suite (11 passed, one platform-specific skip, no baseline changes), and independent interaction review in light and dark themes. The browser regression counts every visible outline, including unnamed vendor outlines, through select opening, navigation, selection, cancellation, clearing, and departure. Nested native dialogs, sample departures in Chromium and WebKit, retained reparenting, and held-label arrivals pass. Microphone and Send controls keep one ring through keyboard, pointer, and typing transitions in light and dark. Trace capture coverage includes native viewport changes, checking a stable evidence viewport and each image's native proportions. Main's newer shadow-tree protections and control typography are retained. A served startup comparison against main at
5d95f6079adds one code module and about 1.6 KB before presentation, with no errors or initial shifts; the shared structural ancestry must be available immediately so initial focus, keyboard scopes, and shadow controls agree.