Repository navigation
Read every change where the user stands from onStanding - #1967
Merged
Merged
Conversation
A Tab between two controls inside one widget's shadow tree reaches the document as no focus event, so every reader listening for `focusin` on the document or on a light-DOM ancestor missed it. On pr-walkthrough, Tab from a diff's comment button to the next file's title left the shortcut bar naming the button's keys until a resize or the heartbeat repainted it. Each of those readers also decided for itself which moves were the runtime's own returns, or which were keyboard arrivals. focus.js now owns every focus event, and the readers read its publication: - `onStanding` calls `read(node, cause, left)`, adding the node the readers last heard the user stood on. A reader that moves focus itself starts a newer publication, and the older one goes to no later reader. Focus that leaves a node for another and comes back to it publishes again, as when the Threads list hands its focus on to the title the user stood on. - A `step` cause joins `return`, `press` and `move`: Tab or Shift+Tab, whether the browser moves the user or a Tab handler does in its place. `pressLed()` says whether the latest input was a press rather than a key. - `handBack` compares the placement count instead of a one-shot document `focusin`, so a move inside a shadow tree during its retry frame counts. - `handingBack` is exported for a box closing onto its thread; the unused `restoringFocus` and `placingChrome` exports are gone. Readers moved onto `onStanding`: the standing repaint (repaint.js), the keyboard controller's disarm, the response-options close, the covering surface's focus trap, reading continuity's edit record, the reading-region record, user-intent's place input, the More menu's opener, off-flow surfaces, the code-copy anchor refresh, the Threads list's landing and title choice, and the margin's reveal reset, labels, cluster arrival and `followStanding`. Behaviour that changed: - The Threads list skips landing on a `return` instead of reading `keepingPlace` and `restoringFocus()`, so a popover closing back into the list no longer re-lands its thread. A press held in the list still lands when it ends. `standOnThread` hands back through `handingBack`. - A panel card's title chooses its card on a `move` or `step`, replacing the `:not(:active)` guard; a press still chooses at its click, and a return chooses nothing. The list hands its own focus on to the open card's title under whatever cause gave the list focus, so `#passingFocus` is gone: a hold landing on the list while a failed candidate holds the user's card from it does not make the stand-in card their choice. keyboard/AGENTS.md says so. - A margin cluster unfolds on a `step` onto one of its controls, as its header says, rather than on any focus matching `:focus-visible`; focus put there by script no longer unfolds it. Three margin tests that put focus on a cluster's control by script now reach it by Tab or Shift+Tab. - The margin card and the standing unfold read a keyboard arrival from `pressLed()` instead of `:focus-visible`, so a press into a text field inside a commented target no longer opens its card. - Held news treats a `step` as an arrival, as it did a `move`. - An off-flow surface brings itself back for a move within it that is not a `return`. The lint rule `architecture/standing-listeners` refuses `focusin` and `focusout` anywhere in the layer and its packages (listeners, event-type lists, comparisons, Lit bindings) and `focus`/`blur` listeners on the document. Its config names each exception and why: focus.js, the interaction log's raw recorder, the reply row's entry, the margin cluster's and card reply row's `focusout`, lf-gloss and lf-toc, each asking about one element's own subtree in its own tree. It is a custom rule because flat config replaces `no-restricted-syntax` per config object rather than merging it. user-intent.js's place reading now registers its own `keydown`, which `test_the_register_is_the_only_way_a_key_enters_the_runtime` names as a fourth listener that answers no press. `test_tab_between_two_staged_controls_turns_the_shortcut_bar_over` covers the shadow-tree Tab. It fails on main and passes here. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…oring a pass later Follow-ups to the onStanding cutover, from its review and an A/B of its flakes. - A focused node hidden or removed under the user publishes `drop`, read as null and against the place readers last heard. On main a hide fired `focusout`, which repainted the shortcut bar; after the cutover the bar kept naming the keys of a control no longer there until the next input. Readers of where the user stands (held news, the More menu's opener, the margin's follow) let a drop pass, since its owner puts the user back, and that return is told against the dropped place. - Where the user stands is read again when a key's, a press's or a click's task ends (a tap focuses at its click), so a move between two nodes of a shadow tree no stage watches, as a component's own root makes, reaches the readers with the cause that input gave it, or `return` where it came out of a layer that closed (`test_a_tab_inside_a_shadow_tree_no_stage_watches_still_reaches_standing`, which timed out without it). - Each reader answers alone: one that throws is reported and the rest still hear, and a reader that moves focus ends the older reading by a counter, not a node compare. - The margin opens a cluster's options for the keyboard arriving on it again, a Tab or a route a key began, as `:focus-visible` did before the cutover; the cutover had narrowed it to Tab alone. A return opens nothing. The margin tests and the AGENTS.md wording go back to main's. - The lint also refuses `focus` or `blur` captured on any node. - user-place.js returns native anchoring at the rendering pass after a hold's release rather than at the release. Two thread renders back to back released one hold and took the next in the same script, writing `overflow-anchor` away and back, which the write watch reports. The cutover's timing made that 9 runs in 30 of `test_replaced_reply_compositions_keep_their_carets_and_leave_commands[send]` under load, against 0 in 30 on its base; with this change, 0 in 30 on both. The cost: a change made to that scroller with no hold of its own, and laid out between the release and that pass, gets no native anchoring. The window is the rest of the pass's round where the release falls inside a rendering pass, and up to a frame where it falls outside one; every thread-list render takes a hold. - keyboard/AGENTS.md says where a return choosing no title can leave focus on a closed title: a hold put back after the choice moved under it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 7, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 9, 2026
…2036) Every focus the runtime and the packages place now goes through `focusDestination(node, cause)`, with the cause `move`, `step`, `return` or `press`, and every reader of where the user stands (`onStanding`) hears that cause. Before, about a hundred plain `focus()` calls published as the user's own move, and owners marked their own returns with flags only their own listeners read, so a return released held news, opened a margin cluster's options or chose a panel card the user never went to. This is phase 2 of the focus overhaul, the first of three stacked PRs: this one against `main`, phase 3 against `focus-phase-2`, phase 4 against `focus-phase-3`. Phase 1 landed as #1967. - focus.js: `focusDestination` takes the cause; `returningFocus`, `placeChrome` and `handingBack`, and the `placing`/`handing` flags behind them, are gone. A placement inside another (a component's focus handler forwarding to its child, `forwardFocus`) keeps the outer cause; a placement made by a reader of standing names its own and counts as a placement. A closing layer's own hand-back, which the platform makes as a popover or dialog closes, is no newer word to a waiting hold. The cause `press` is a route landing on a control to press it, as a go-to does, which opens nothing on arrival, or a control focusing itself under the user's press, as lf-trace's timeline markers and image do. - A native layer's own opening and closing steps (`showModal`, `close`, `hidePopover`), which move focus the platform's way, run inside `nativeLayerSteps(steps)`: what they do with focus is the layer's return, and no newer word to a hold waiting across them. Main's native auxiliary dialog (#2006) re-seats its envelope and the layers above it this way, where it had used `returningFocus`. - A stop is lent only to a drawn element that is no control of its own, and landing is read as focus on the element or inside a shadow tree it hosts (`standsIn`), so a text field whose editor took focus is landed on and not focused twice. - The returns that published as moves now say `return`: the banner's refocus of its door and of the control after a removal, the thread panel's invoker, the reaction list's own return, surface.js's return to Threads, the margin's cluster repaint, card transfer and `restoreStanding`, and the carries across a re-render (RowFocus, the swipe deck, the board's grip, the thread card's hand-on, history and draft restores, a contribution activation's hand-on to the entry that replaced the pressed one, the Asks view's restore after a revision, the playground's return from a native range, lf-draft's return to the draft or its Edit control as its editor closes, and the covering surface's entry, which main had wrapped in `returningFocus`). - Flags deleted: auxiliary-surfaces' `placingFocus`, the margin's `settlingOptionsFocus` and `suppressingOptionsArrival`, and the page map's `closeOwnsFocus` (every way out of the map now places focus itself as it closes the dialog; the `close` event places nothing). The margin's two cluster `focusout` listeners and its card's reply-row `focusout` are `onStanding` readers, so switching windows no longer folds a margin entry's options. The fold reads the node the user left: a node hidden under the user folds what it opened, and a node removed from under them folds nothing, since the render that removed it hands them on to its replacement. - An auxiliary surface's `focus()` is `landing()`, the node a covering surface lands the user on, so `.focus()` means only the element's. - The lint `architecture/placements` refuses a plain `focus()` outside focus.js and the text field (whose own `focus()` hands on to its editor), requires a cause at every `focusDestination` call, and refuses passing the function on as a value. `focusForNavigation`, a contribution's `focus(entryKey, cause)` and `focusThread` take the cause too. Behavior that changed: - A go-to or a generated route that lands on a margin control and presses it no longer opens the cluster's options and folds them again under the press; a travel landing on a margin control is a `move`, which opens a folded cluster as the keyboard arriving does. - `lf-diff`'s hunk walk and `lf-sample`'s return borrow a stop that leaves with the user instead of leaving `tabindex="-1"` on the rows and the sample host. - Fallbacks that called `document.body.focus()`, which did nothing, are gone. Tests: tests/runtime/focus.test.mjs asks that a move, a return and a step each reach `onStanding` with the cause the placement names, and that a placement naming none is refused; it fails before `focusDestination` took a cause. `npm run test:runtime` (255) and eslint pass. The focus browser suites (chrome contracts, navigation, controls, threads, widgets, margin, anchors, drafts, reactions, aim, read state, interaction layer, send placement) fail 7 and pass 2164, the same 7 that fail on main (dc26922); `test_resume_reveals_an_open_draft_when_its_existing_subject_hides`, the Resume journey #2078 fixed, passes. > _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 14, 2026
…ve stale claims (#2897) A survey of Leaf's prose found one style hard to read throughout: a rule stated about a kind of thing ("a reader that never refuses") with the real case reduced to a paraphrase, Leaf-specific nouns used undefined, pronoun chains, negative predicates, and rule, mechanism and reason fused into one sentence. This is the first batch of rewrites, plus three passages the survey found wrong about the code. **Rewritten references** (29% shorter than main, rewritten from what the reader does, with an independent review for accuracy and lost guidance): `conversation-loop.md`, `event-batches.md`, `threads.md`, `harness-claude-code.md`. Each commit message lists every cut. The coined "take in hand" becomes "start", after `leaf task start`, including in the reply-handling clause in `registry.json`, the `progress-parent` and `todo-execution` findings, and `harness-codex-app-server.md`; two snapshots that quote the clause are regenerated. **Corrections to claims that were wrong on main:** - `event-batches.md` said a user-added option's words travel in `detail` instead of `says`; `GestureWords.says` gives them. - `/developing-leaf` said root `AGENTS.md`'s "Stage" has readers tolerate old state-home records; Stage calls them disposable. - `thread-list-view.js`'s header said focus and the open card never part; since #1967 a `holdFocus` restore chooses nothing, so they can (as `keyboard/AGENTS.md` says). - `threads.md` described a `page check` rule on anchored visual parts that #2020 removed. - `conversation-loop.md` described an ask as holding "the kind of answer it takes"; it holds `prompt`, `answer` and `status`. **Root `AGENTS.md`**: "Where instructions live" no longer asks prose to describe a set by what its members share, which pushed writers toward rules about kinds of things. It keeps the rule's job from #2318: don't copy a list the code keeps; point to it. **Kernel:** rebuilt. main's committed kernel already lagged its runtime sources (`check:browser` fails on main), and this branch's runtime header and registry edits change the kernel hash. No behavior changes beyond the reworded finding and handling text and the rebuilt kernel. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Oct 27, 2026
A component can accept a focus transfer and then leave the document body active without emitting a matching `focusin`. The shared focus reader returned early whenever `focusout.relatedTarget` named a destination, leaving command hints attached to the previous widget. This caused the trace's Previous and Next controls to retain arrow shortcuts after the zoom step in the review-a-fix sweep. Run the existing deferred departure reading for these transfers too. Successful arrivals still suppress it, and focus holds and drop classification retain their existing checks. This preserves the central focus publication model from #1967 instead of adding a trace-specific repaint. The new runtime regression fails before the change and passes afterward. The reported review-a-fix sweep likewise fails before and passes after; the nested-surface Escape journey also passes. Generated kernel files are rebuilt. Closes #4245 — automated triage 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 Tab between two controls inside one widget's shadow tree reaches the document as no focus event, so every reader listening for
focusinon the document or a light-DOM ancestor missed it. On pr-walkthrough, Tab from a diff's comment button to the next file's title left the shortcut bar naming the button's keys until a resize or the heartbeat repainted it. Each of those readers also decided for itself which moves were the runtime's own returns and which were keyboard arrivals.This is phase 1 of the focus overhaul: focus.js owns every focus event, and the readers read its publication.
onStandingcallsread(node, cause, left), whereleftis the node the readers last heard the user stood on. Causes arereturn,press,step(Tab or Shift+Tab, whether the browser or a Tab handler moves the user),move, anddrop(the focused node was hidden or removed under the user, read as null).pressLed()says whether the latest input was a press.handBackcompares the placement count instead of a one-shot documentfocusin, so a move inside a shadow tree during its retry frame counts.handingBackis exported; the unusedrestoringFocusandplacingChromeexports are gone.Readers moved onto
onStanding: the standing repaint, the keyboard controller's disarm, the response-options close, the covering surface's focus trap, reading continuity's edit record, the reading-region record, user-intent's place input, the More menu's opener, off-flow surfaces, the code-copy anchor refresh, the Threads list's landing and title choice, and the margin's reveal reset, labels, cluster arrival andfollowStanding.The lint rule
architecture/standing-listenersrefusesfocusin/focusoutanywhere in the layer and its packages, andfocus/blurlisteners on the document or captured on any node. Its config names each exception and why (the interaction log's raw recorder, the reply row's entry, the margin'sfocusouts, lf-gloss, lf-toc), each asking about one element's own subtree.Behaviour that changed:
return, so a popover closing back into the list no longer re-lands its thread. A press held in the list still lands when it ends.moveorstep; a press still chooses at its click, and a return chooses nothing, so#passingFocusis gone. keyboard/AGENTS.md names the one edge this leaves: a hold put back after the choice moved under it can leave focus on a closed title.:focus-visibledid, and a return opens nothing. The margin card reads a keyboard arrival frompressLed(), so a press into a text field inside a commented target no longer opens its card.stepas an arrival; held news, the More menu's opener and the margin's follow let adroppass, since its owner puts the user back.return.overflow-anchoraway and back, which the write watch reports: 9 runs in 30 oftest_replaced_reply_compositions_keep_their_carets_and_leave_commands[send]under load, against 0 in 30 on the base; with this change, 0 in 30 on both. The cost is a window of at most one frame where a change to that scroller with no hold of its own gets no native anchoring; every thread-list render takes a hold.Tests:
test_tab_between_two_staged_controls_turns_the_shortcut_bar_over(with its drop case) fails on main and passes here;test_a_tab_inside_a_shadow_tree_no_stage_watches_still_reaches_standingtimed out without the post-input re-read. The focus-touching browser files pass locally (1,754 passed); the five failures there also fail on the base.npm run test:runtimepasses 225/225.