Repository navigation
Let a widget's own key listener go first for every key, letters included - #6816
Merged
Merged
Conversation
Prototype for the shortcut-contract question: a page widget that answers a key with its own keydown listener and prevents it now keeps the key while focus is in it, letters included, and Leaf's page command for that letter takes no step. Before, Leaf read printed letters in capture, so a film's `k`, `j`, `l` and `.` ran Leaf's scroll, Design mode and fold instead of the film. Capture keeps only the unseen-focus let-go and an armed Go-to's or reactions' keys. Declaring `lfCommands` stays the way to get the command reference, tooltips, `aria-keyshortcuts`, `contextKeys` and the interaction log's command record. The typeahead claim stays: Web Awesome's dropdown prevents only a letter an item's name starts with, and a hand-written menu may prevent none. > _This was written by Claude Code on behalf of max-sixty_
…ver acts beside Leaf With nothing focused, a key is aimed at `body`. Since the previous commit moved printed letters to the root element, a `body` listener that prevented one of Leaf's letters there ran, and then Leaf's command ran too: the root listener's `pages` test excludes `target === document.body`, and dispatch doesn't read `defaultPrevented`. Before that commit Leaf took the letter in capture and stopped it, so only Leaf acted. Now Leaf reads every key aimed at `body` itself in its capture listener on the document, as it reads a key that lets go: no element of the page's has the user's focus to answer it, so Leaf's command runs first and, having prevented the key, stops it before any page listener. The root listener skips those keys, so nothing is pressed twice. A key aimed inside an element still goes to the element's listeners first. This also ends the same double action for a non-letter Leaf binds over the page, such as Escape leaving Design mode, which a `body` listener heard and acted on before Leaf did. A `waits` row, Escape's let-go, still runs last on the window. `page-behavior.md` no longer says a `body` listener keeps a letter from Leaf whatever is focused: it keeps a key aimed inside it, and a page-wide shortcut belongs on the document, which hears only keys Leaf leaves. The keyboard contract's "Scope resolution" says the same. Tests: `test_a_key_the_page_answers_takes_no_step_of_leaf_s` adds the case: nothing focused, a `body` listener preventing `k` neither hears it nor acts beside Leaf's `scroll.up` (failed on the previous commit with the listener's count at 1). `test_a_thread_walk_starts_one_page_trip_and_reveals_its_nested_passage` read the press's task from a listener on the root element, after Leaf's; it now reads it from a capture listener on the document registered after Leaf's, since the walk's key, pressed with nothing focused, stops there. `pnpm run test:runtime` (1,083 pass); `test_key_scopes.py`, `drafts/test_keys.py`, `test_threads.py` and `test_interact_layer.py` pass; `pnpm run check:browser` passes. > _This was written by Claude Code on behalf of max-sixty_
… order in one place A key a listener prevents is now its author's inside any authored document, the page's body or a thread message's body, where before only the page's body counted. So a widget in a message the panel shows keeps a letter it answers, and Leaf's page command no longer acts beside it; the rest of Leaf's chrome keeps its keys whatever a page listener prevents. The root listener reads where the key was aimed from the event's path, fixed at dispatch, so a widget whose answer redraws or removes the element it was aimed at keeps the key too. An independent Codex review found both cases; test_a_widget_in_a_message_keeps_a_key_it_answers covers them (on the parent commit it reports ['scroll.up'] beside the widget's own action). module-input.md, "How scopes compose", now states the whole order an author's listener meets, with the states in which Leaf hears a key first (armed Go-to and reactions, nothing focused, focus scrolled out of sight); page-behavior.md points there and keeps the page-script facts it alone states (typeahead roles, Leaf's own boxes stopping keys). The new advice in page-behavior.md to put a page-wide shortcut on the document is dropped. The eval case added here, page-wide-keys-take-no-leaf-keys, asks for deck shortcuts that work anywhere on the page: on main's text and on the branch's, 4 of 4 runs each passed, every one declaring lfCommands on body, so the sentence changed nothing. Four runs on the consolidated text also passed 4 of 4.
leaf-agent
previously approved these changes
Nov 23, 2026
leaf-agent
reviewed
Nov 23, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
test fails at its pre-commit step: oxfmt rejects the narrower wrapping of three statements in controller.js, which it joins back onto one line each (run). The suggestions below are its output; the behavior is unchanged, and the tests the run executed passed. I can push this if you'd like.
leaf-agent
dismissed
their stale review
November 23, 2026 04:03
CI failed — oxfmt formatting in controller.js
leaf-agent
approved these changes
Nov 23, 2026
This was referenced Nov 23, 2026
This was referenced Nov 23, 2026
leaf-agent
pushed a commit
that referenced
this pull request
Nov 23, 2026
`main` fails `test_every_skill_file_reads_in_one_command`: `skills/leaf/references/module-input.md` is 30,004 characters, 4 over the 30,000 a skill file may be. #6777 left it 7 under and #6816 added to it; each passed its own checks, and they merged ten minutes apart. Every pull request's `test` job fails on it until this lands. This cuts one sentence from the `onPress` paragraph, "Keep press-local work in these callbacks.", which gave a rule with no reason beside the two callbacks it names. The file is 29,962 characters. The file has sat at the limit since #6777, so the next addition breaks it again. Max hasn't read this. Tests: `tests/model/test_interact_layer.py -k reads_in_one_command`, which fails on `main` and passes here. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 23, 2026
#6773 stated a rule in `browser/AGENTS.md`: a box inside a frame either meets its edge, taking the frame's rounding at the corners they share, or stands clear of it. A survey of every box Leaf draws inside a frame found 57 that meet or nearly meet an edge with the wrong corners. This fixes 49 of them, and the defects of the same kind two fresh reviews found; #6803 fixed two more. - Leaf's word and symbol presses and its reactions draw their focus ring inside their edge, set once per role, so a frame's edge no longer cuts it; the panel's leaf keeps its ring on its edge, where its badges would otherwise cover it. A code block's lone Copy, which takes the focus on its own toolbar, rings inside that toolbar's edge rather than 3px outside it, where the ring ran onto the block's edge. - A holder whose presses join into one control declares `data-lf-joined`, as a block's toolbar and a question's Done cell do: each press is square at the seams and takes the holder's rounding at its corners. The press-face guard allows only a declared variant, and a clip would cut a finger's reach past the toolbar, so the corners are per-corner radii from a holder token. - In a question's joined options, every cell standing in one of the group's corners takes its rounding there, in a stack and laid across, so a pick's ring and the keyboard's stay whole round the corner instead of thinning where the group's clip cut their square corners. Done joins as a cell: no edge of its own, where it drew a second one inside the group's, and its cell wears its ring, as a row wears its mark's. Done's digit and Add's stand in the column every card's digit shares. - `--lf-clear` (4px at every density) is the least room that reads as standing clear, and the toolbars, a board card's grip, Add, a suggestion's contents and a diff filter's fold-all stand that far from their frame. `--lf-r-in`, a frame's rounding inside its hairline, replaces five copies of that length. A pane clips to its rounding, and a comment box's key badge stands centred on its line, clear of the box's foot. - In the panel, the search's scope chip and its steps stand `--lf-clear` inside the field, the steps' faces a line tall less that room above and below, and the match count `--lf-clear` before the first step. On Me's Reply no longer hangs its word into the card's margin, where its face crossed the ring a walked card wears; controls.css now says a seat hangs a press only into a margin that leaves `--lf-clear` at the frame's edge. Worth a look in use: a bordered button's focus ring now lies over its border (Max may revise this; the square-corner rule itself is on trial). On Me's Reply now lines up its face with the card's text edge, where its word used to stand, so the word sits 13px further in. A lone titled option laid `across` now counts as stacked, since it shares its row with no sibling; its chips no longer float beside its state mark. The other six findings are measurement artifacts, an example page's own button, and the diff gutter's +, left 2px inside its line. Max asked for the survey and the fixes; the before/after pairs are on the decision page. Part of #4125: rings on Leaf's presses keep inside a scroller's clip; rings on other boxes, and scrollers that keep no room, remain. Model tests for faces, rings and tokens pass, apart from the skill-file size check, which main fails too (`module-input.md`, from #6816), as do focused browser tests for Done, drafts, code Copy, boards, Add, diff controls, panes, the file tree, rings, workspaces and reactions. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 23, 2026
…two full module references have room (#6895) `module-input.md` was 40 characters under the 30,000 a skill file may be and `module-authoring.md` 312 under, so the next sentence added to either fails `test_every_skill_file_reads_in_one_command`, as #6816 did on main (#6826). This moves "Previews" to `module-previews.md` and "Generated controls" to `module-controls.md`, each word for word, and points every reference to either section at its new file, code comments included. `module-input.md` is now 22,941 characters and `module-authoring.md` 24,907. `SKILL.md` and `module-authoring.md`'s list route to the two new files. What the diff doesn't show: - **Scores**, main against this branch, Claude Code, 4 runs each: `widget-interface-serves-the-task` 4 of 4 each, and all 4 branch runs opened `module-controls.md`; `widget-list-keeps-focus` 4 of 4 each. No case covers previews. - **The limit is on a command's whole output**, so `wc -l … && cat module-input.md` was already over it on main. In `widget-owned-context-keys`, all 4 branch runs read the file with that one command; on main one run tried it, and all 4 read the file with a second call. - **One eval case changes.** `widget-owned-context-keys` failed 4 of 4 on both arms: its prompt's "also works standalone" predates the section on a widget that runs off Leaf, and all 8 answers read it as that, for which the reference asks the opposite of the rubric. The prompt now says the classifier is also used with no thread or margin representative, and 3 of 4 pass. max-sixty chose to merge this from the session's Leaf page, which carries this account; it follows from a hazard listed there. Tests: `tests/model/test_interact_layer.py`, `test_product_page.py`, `test_theme_tokens.py` and `tests/runtime/widget-api.test.mjs`. > _This was written by Claude Code on behalf of max-sixty_
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.
Leaf read printed letters in a capture listener ahead of page code, so a widget that wanted one of Leaf's letters had to register it through
lfCommands. This moves letters to where Leaf already reads every other key, after the listeners on the focused element and around it: with focus inside an element, its own listener hears every key first, andpreventDefault()claims it. Leaf hears first only in states of its own: armed Go-to or reactions, focus scrolled out of sight, and a key aimed at the page itself with nothing focused. Registering keys stays the route to the?reference, hints,aria-keyshortcutsandcontextKeysforwarding. A prevented key counts as its author's inside any authored document, the page's body or a thread message's body, read from the event's path, so a widget in a message, or one that redraws on its key, keeps it.To weigh: SOUL's "Leaf's keys work the same on every page" now bends inside a widget that takes a key, as #6469 bent it for menus, and
?still lists Leaf's meaning for a key a widget takes without registering it.module-input.md, "How scopes compose", now holds the order an author's listener meets;page-behavior.mdpoints there. A new eval case,page-wide-keys-take-no-leaf-keys, passes 4 of 4 on main's text and on this branch's.max-sixty chose this contract on the review page; Codex reviewed it over three rounds, and each finding is fixed here.
Tests: runtime suite (1,083), plus the key-scope, draft-key, interaction-layer, On view and Versions key tests (234), including a new test for a widget in a thread message.