Repository navigation
Let a template's command rows take the element they stand on, and declare the draft history toggle in its template - #2516
Merged
Merged
Conversation
…te scopes in their templates `commands(element, title, rows)` and `commandsOn(title, rows)` now accept rows as a function of the element the scope stands on, read once per declaration. A template can then declare a scope whose rows read its own element, such as a disclosure toggle's `DISCLOSE(summary)`, in the template that renders it. A `commandScope` capability refuses the function form, since each projection stands on its own control. lf-draft declares its history toggle with `commandsOn` on the `<summary>`, deleting the after-render lookup, node-identity check and `#historySummary` field. Its editor's read-only state is painted with the footer's availability, replacing the `#paintAvailability` wrapper. lf-visual-review's inspector radios declare their press with `commandsOn`, deleting the per-choice ref callbacks and the `data-scope`/`data-mode`/ `data-scale` markers they used as an identity check; the render case finds the Flip radio by its value. Behaviour: the history toggle's scope now leaves with its summary when the history disappears, rather than standing on a detached node. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ighten the docs Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 12, 2026
# Conflicts: # skills/leaf/packages/visual-review/widgets/lf-visual-review.js
leaf-agent
previously approved these changes
Oct 12, 2026
# Conflicts: # skills/leaf/assets/runtime/keyboard/scopes.js
leaf-agent
approved these changes
Oct 12, 2026
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.
Fixes item 37 of the Lit-survey review: a keyboard command scope declared in a Lit template had no way to name the element it stands on, so widgets declared those commands after rendering instead, by querying for the node, comparing its identity with the last one, and calling
commands().commandsOn(title, rows)now acceptsrowsas a function of the element the directive stands on, called on each render (skills/leaf/assets/runtime/keyboard/scopes.js). A template therefore declares a disclosure toggle ascommandsOn(title, (summary) => [{ keys: () => DISCLOSE(summary), … }])on the<summary>it renders. Imperativecommands()callers already hold their element, so they keep plain rows.The review suggested passing the element to each row cell instead (
keys: (el) => …throughword(cell)). I passed the element to the declaration instead. Most readers of a row (declaredBindings,titleOf,commandAvailable,labelOf) receive the row without its scope, andrunalready takes the binding as its argument. Threading the element through every cell would have touched all of those readers, while one closure at declaration covers keys, titles,whenandrunalike.Converted:
commandsOnon its<summary>. The after-render lookup, the identity check and the#historySummaryfield are gone. The focus hold reads the history<details>before render. The editor'sreadOnlyis painted in#paintFooterfrom the same availability reading as the footer's controls, which replaces the#paintAvailabilitywrapper.commandsOn, withrun: () => focused().click()standing in for the radio the row couldn't name. Each row now clicks its own radio, so a run that does not start from that radio's focus, such as one from the command reference, presses the radio the row names.lf-diff and lf-options-settled build their disclosure elements imperatively and close over them when they declare their commands. Neither looks an element up after render, so neither needed converting. No other
commands(/keys(call site inskills/leaflooks its element up after render.Behaviour that changed: the draft history toggle's scope now leaves when its summary leaves the page, where it used to stay on a detached node, and it re-declares on each render, as every
commandsOnscope does. A visual-review choice's command presses its own radio rather than whatever holds focus. Keys, titles and focus return are unchanged.Line deltas (hand-written source, excluding tests, vendored bundles and Markdown): +27 / −30 (net −3). Tests: +27 / −0 (a runtime case for template rows that read their element).