Repository navigation
Declare commands and contribution hosts in Lit templates - #2349
Merged
Merged
Conversation
CommandsOn replaces and retires its own command attachment; said shares relabel markers while Lit retains content ownership. Questions, Leaves, quoted passages, and Page Map derive their registrations from each template reading. Source lines across the seven implementation files: 4344 to 4425 (+81), removing consumer wiring WeakSets and row-model expandos.
leaf-agent
reviewed
Oct 11, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The Page Map refactor removes lfMapAction, but two browser tests still read it. test_page_map_keyed_reconciliation_preserves_user_standing now gets [None, None] instead of the action keys, and both widths of test_margin_entry_order_and_page_map_actions_are_stable_at_both_widths throw while reading button.lfMapAction.entry. These tests protect action order and retained focus; update their readings to use the rendered action identity so those checks still exercise the behavior. I reproduced all three failures with focused uv run pytest selections.
leaf-agent
approved these changes
Oct 11, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
… connection, and choose Page Map receipts in the model (#2504) Follow-up to #2349, from the review of the Lit survey PRs (items #25, #26 and #27 in that review's numbering, not GitHub issues). **#25: `said` deleted; one factory for element directives.** `said` had one caller, which passed the constant `false`. Every other template writes the label markers as static attributes, and that is now the only form: thread-card's resolved summary writes `data-lf-gen="1"` again, and `module-authoring.md` and the `relabel` comment now describe the static markers. The `said` export, its test and its authoring line are gone. `offered`, `contributionHost` and `contributionReceipts` each repeated the same element-part skeleton; `elementDirective(name, write)` in `widget-elements.js` now builds all three. Rendered markup is unchanged. **#26: `commandsOn` attaches once per connection.** Before this change, every render re-attached the scope, which meant re-validating it, re-wiring its buttons and running `paintKeys()`. That made the next frame re-read the shortcut attributes of every scoped element on the page. Now a re-render puts a fresh scope with the latest declaration (title, rows, callbacks, `when`) in place of the last one (`standScope`). It then queues one reading of that element alone, the same reading any new declaration gets on its first paint, without the page-wide pass. As before, a row whose `when` turns false loses its `aria-keyshortcuts` on the next frame. The scope is replaced rather than changed because its contextual aliases are built from it once. Measured with the reviewer's probe (20 template rows beside 300 other scoped elements), an unchanged re-render now costs 120 attribute reads instead of 2,040. `detachScope(element, scope)` is now the one way an element's own declaration is withdrawn: when the directive leaves, and when a first reading refuses the declaration. It re-reads the element from whatever scopes remain. That also fixes a bug `main` already had: a declaration refused on re-render kept its stale `aria-keyshortcuts`, and because the element then left the reference's list, nothing ever cleared it. `forgetScopedElement` now itself checks that nothing else declares on the element, which removes the same check from its three callers. The never-passed `validateAtPaint` option is gone. **#27: the Page Map's receipt choice moves into the model.** `marginMapGroups` gives every row an `action.receipt` (and `awaitsUser`). A control row gets the target's receipt when the margin shows that receipt on the same control (`workflowCarrier`), and otherwise its own record's receipt. Item rows and control rows now both bind `contributionReceipts(action.receipt, action.awaitsUser)`. `contributionHost(source, surface, record, options)` tracks the host on its surface itself, as `materializeContributionControls` does for every host it presents, and the `paint` callback is gone. The test that asserted the callback received the control now asserts that the template host matches the imperative host and that the host is found on its surface. A new `margin-model` assertion covers which receipt each row gets. Line deltas (hand-written source excludes tests and Markdown): | | source | tests | |---|---|---| | #25 (`widget-elements`, `thread-card`, `widget-api`, the directive half of `contribution-controls`) | about −43 | −23 | | #26 (`keyboard/scopes.js`) | +20 | +89 | | #27 (`page-map-dialog`, `margin-map-model`, the host half of `contribution-controls`) | about −5 | +13 | | total | −28 (+132 −160) | +79 (+111 −32) | Checks: the `command-controls`, `margin-workflow`, `margin-model`, `passage-boundaries` and `indication` runtime tests. The two new `command-controls` cases fail on `main`. In one, an unchanged re-render reads an unrelated scoped element 3 times. In the other, a refused re-render leaves `aria-keyshortcuts` behind. Browser: two Page Map cases (`test_open_page_map_uses_the_canonical_margin_entry_record_and_live_state`, `test_unit_claim_arrivals_share_one_window_with_the_open_page_map`) and three `commandsOn` journeys (quoted passage, Questions panel, a thread Question's Done). > _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.
Questions, Leaves, and quoted passages now declare their keyboard commands in Lit templates. commandsOn updates the declaration on every render and retires its attachment when the directive leaves, while preserving projected commands. said shares relabel's passage markers without taking content ownership from Lit. Page Map declares contribution hosts and receipts in its templates, removing row-model expandos and the post-render DOM walk.
Survey item 3. Measured lines across the seven runtime implementation files: 4,344 → 4,425 (+81). By file: keyboard/scopes.js 778 → 822; widget-elements.js 595 → 618; contribution-controls.js 523 → 571; page-map-dialog.js 502 → 502; queue-list.js 227 → 210; live-leaves-list.js 207 → 202; thread/thread-card.js 1,512 → 1,500. Shared directives add code while removing per-consumer wiring WeakSets and stale callback ownership. Public API exports and authoring guidance are also updated. The contribution directives remain internal because the public contribution-entry API owns a complete entry, including its body. Existing Page Map regressions now read rendered action identity rather than the removed row-model expando, retaining their order, focus, query, scroll, and activation assertions.
Validation: 42 focused runtime tests and 12 browser cases passed for Questions, Leaves, quoted passages, and Page Map. Independent review exercised ordinary keyboard paths in Chromium; the complete runtime suite passed with 329 tests.