Skip to content

Let a template's command rows take the element they stand on, and declare the draft history toggle in its template - #2516

Merged
max-sixty merged 7 commits into
mainfrom
agent-ad46c7d0c1c3511cd
Oct 12, 2026
Merged

max-sixty merged 7 commits into
mainfrom
agent-ad46c7d0c1c3511cd

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

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 accepts rows as 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 as commandsOn(title, (summary) => [{ keys: () => DISCLOSE(summary), … }]) on the <summary> it renders. Imperative commands() callers already hold their element, so they keep plain rows.

The review suggested passing the element to each row cell instead (keys: (el) => … through word(cell)). I passed the element to the declaration instead. Most readers of a row (declaredBindings, titleOf, commandAvailable, labelOf) receive the row without its scope, and run already 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, when and run alike.

Converted:

  • lf-draft: the history toggle is commandsOn on its <summary>. The after-render lookup, the identity check and the #historySummary field are gone. The focus hold reads the history <details> before render. The editor's readOnly is painted in #paintFooter from the same availability reading as the footer's controls, which replaces the #paintAvailability wrapper.
  • lf-visual-review: Let lf-visual-review declare radio keys with commandsOn, hold its shots by ref, and repaint only the pairs on an inspection choice #2527 already moved its radios to commandsOn, with run: () => 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 in skills/leaf looks 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 commandsOn scope 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).

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits October 11, 2026 23:29
…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
leaf-agent previously approved these changes Oct 12, 2026
@max-sixty max-sixty changed the title Let a template's command rows take the element they stand on, and declare draft and visual-review scopes in their templates Let a template's command rows take the element they stand on, and declare the draft history toggle in its template Oct 12, 2026
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
# Conflicts:
#	skills/leaf/assets/runtime/keyboard/scopes.js
@max-sixty
max-sixty merged commit dbefda6 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-ad46c7d0c1c3511cd branch October 12, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants