Repository navigation
Build element directives from one factory, attach commandsOn once per connection, and choose Page Map receipts in the model - #2504
Merged
Conversation
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…ts by ref, and repaint only the pairs on an inspection choice (#2527) Follow-up to the Lit conversion of `lf-visual-review` (#2374), covering item #35 of the Lit-survey review (that review's numbering, not GitHub issues) and the part of item #41 that touches this widget's tests. **#35: cuts left by the conversion.** - The inspector's radios declare their Enter/Space command with `commandsOn` in the template, replacing the widget's own path: a cache of ref callbacks, a `dataset` re-entry check and `commands(radio, …)`. The radios no longer carry `data-mode`/`data-scope`/`data-scale`; the one control archetype that selected on `data-mode` now selects on the radio's `value`. - Each case entry holds its `lf-shot` and article through the `ref`s the template binds, so the post-render `querySelector` loop, the six `shotHost.querySelector("lf-shot")` lookups and the unobserve-on-removal loop are gone. - Only the selected case's head, toolbar slot and stage are size-observed, since hidden cases measure zero; observation moves with the selection. - An opacity tick repaints only the inspector and the pairs. A mode, scope or size choice repaints the inspector, the pairs and the selected pair's allocation, without re-rendering every case. `#remaining()` runs once per render rather than once per case (it was quadratic in case count), and the selected pair gets its allocation alone after the shared choices instead of a second full inspection. - A failed source (the `failSoft` view in `#show`) now discards its cases, and the next good commit rebuilds them with the selection kept. With entries held by ref, a failure left each entry's article null, and the next-remaining control threw inside every page-wide key reflection. - The focus-crop availability test has one home, `#focusAvailable()`, and `type="button"` is dropped where `offered` already writes it. - The `data-lf-gen="1" data-lf-said` markers stay as static attributes. Lit cannot interpolate attribute names without a directive, and #2504 removed `said` so that the static markers are the one documented form. Behaviour changed: none a reader sees. Enter on an inspector radio now has a test; that test fails when the command's `run` is emptied. **#41 (this widget's part).** `test_visual_review_recovers_from_rejected_cases` no longer exists: #2487 deleted it when the `visual-run` contract began refusing repeated case ids, so no data reaches the failure view now. The reorder test replaces its `node === old` check with what that identity gives the user: after the reorder, Cmd/Ctrl+Z still undoes the typed draft (the assertion fails when the editor is swapped for a copy with the same value). `test_visual_review_ignores_a_late_load_from_detached_evidence` now replaces the evidence through `data set`, as a new run would, instead of swapping the `lf-shot` by hand behind Lit, and it now asserts that the shown pair's box does not move when the detached evidence finally loads. Its old assertion read the new shot's own image width, which the old shot could never change; the new one fails when the layout reads the detached shot's geometry. **Line deltas** - Hand-written source: `lf-visual-review.js` 940 → 917 (−23; +93/−116). - Tests: +23/−27 (−4). > _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 12, 2026
… pages and exports (#2549) From the review of the Lit survey PRs (item #51 in that review's numbering, not a GitHub issue). **#51: a command scope's attachment reads its own element only.** An imperative `keys()` attach called `paintKeys()`, which made the next frame re-read the `aria-keyshortcuts` of every scoped element on the page. A declaration changes no other element's shortcuts, and the attached element was already read on its own at the head of the next frame (`unpainted`, drained by `reflectFirstScopes`). So `attachScope` now only schedules that frame, the same rule #2504 gave a `commandsOn` re-render. `commandsOn`'s two attach branches become one `attachScope` call, `standScope` folds into `attachScope`, and the directive's withdrawal schedules a frame instead of a page-wide pass, since `detachScope` already re-reads the element. **Interactive exports now take that reading too.** An export's repaint frame mounted only `reflectKeys`, so it never drained `unpainted` or ran the head-of-frame button passes. Before this PR, the attach's own `paintKeys()` was what read a late scope there. Even then, a `commandsOn` re-render or withdrawal in an export was read only if another owner dirtied the frame. The export now mounts `reflectFirstScopes` as well (`leaf.js`), and `repaint.js` records that the two key slots go together. I found no shipped page where an export showed the gap: a test exporting a screenshot comparison, whose divider attaches after presentation, passed with and without this change, because another owner dirties that frame. So the PR adds no browser test for it. Behaviour that changed: an attach no longer marks the whole page's shortcuts for re-reading. A scope that a painter attaches mid-frame (the banner's touch controls, 18 per page) now gets its `aria-keyshortcuts` at the head of the next frame rather than at the tail of the current one. Measured: | | `paintKeys()` on attach (main) | this PR | |---|---|---| | happy-dom, one `keys()` attach beside 300 scoped elements: `getAttribute` calls | 1,813 | 7 | | happy-dom, same, time per attach | 1.4 ms | 0.19 ms | | Chrome, full `reflectKeys` passes over one key journey (review-a-plan / triage-board / pr-walkthrough / ship-review / command-hub) | 9 / 3 / 6 / 10 / 4 | 9 / 3 / 6 / 10 / 4 | On the shipped pages, the change saves no full passes: in each frame where an attach lands, another owner has already called `paintKeys()`. The saving is for an attach in an otherwise quiet frame on a page with many scoped elements. The case for the change is that both attachment paths now follow one rule, which removes a branch. History: `keys()` called `repaint()` until #1788 changed it to `paintKeys()`, the same commit that added the button-availability pass to `reflectFirstScopes`. That commit gives no reason for the switch, and that button pass now runs at the head of every frame either way. Line deltas: | | source | tests | |---|---|---| | #51 (`keyboard/scopes.js`, `repaint.js`, `leaf.js`) | −9 (+21 −30) | +8 (+9 −1) | Checks: all 361 runtime tests. The extended `command-controls` case attaches imperatively beside another scoped element and asserts that the other element isn't read; that assertion fails on `main`. Also 63 browser cases that assert `aria-keyshortcuts`, the shortcut bar or the command reference, run from `test_render_navigation`, `_controls`, `_anchors`, `_options`, `_widgets`, `_margin`, `_threads`, `_reactions`, `_drafts`, `_projection` and `_semantic_selection`, plus six interactive-export cases in `test_render_export`. > _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 12, 2026
…s controls once (#2522) The margin kept its own copy of the rule that picks a contribution control's workflow receipt. [#2504](#2504) moved the Page Map to a model-owned receipt, but the margin still painted the target's agent work over its primary control after the cluster rendered, and cleared that control to nothing once it stopped carrying the work. So a package control with its own `workflowReceipt` that gave up the primary seat showed its own receipt in the Page Map and none in the margin. Page annotation views (`data-annotations="page"`) built their control list a third way and painted only each control's own receipt. Because the inventory drops the target's workflow item once a control carries it, that view showed the target's agent work nowhere. One rule now decides it. `marginInventory` gives every control item a `receipt`: the target's receipt on the surviving primary and the control's own everywhere else. `entryControls(entry)` in `margin-model.js` is the one list of a target's controls, in canonical order. The Page Map and `view.controls(entry)` both read it. Receipts are seat state, so each seat paints what its projection chose on every pass through `presentContributionReceipts`, which the `contributionReceipts` template directive now wraps. The margin's clusters and readings, the inline Thread seats, page annotation views and the feature gallery all call it, and `widget-api.js` exports it. `presentContributionEntry` no longer paints a record's receipt or turn, and the margin's carrier bookkeeping is gone. **Review item 50, "the margin keeps its own copy of the contribution receipt rule"** - Behaviour change: a control that stops carrying its target's agent work goes back to its own receipt in the margin, as it already did in the Page Map. A page annotation view now shows the target's agent work on its primary control and lists controls in the canonical order its contract (`module-authoring.md`) names. - Hand-written source: +97 / −101 lines (net −4). That covers the runtime modules (`margin-model.js`, `margin-map-model.js`, `contribution-controls.js`, `annotation-view.js`, `inline-contributions.js`, `widget-api.js`, `margin-projection.js`, `margin-cluster-view.js`) and the feature gallery widget, and excludes the regenerated corpus copy. - Tests: +159 / −7 lines. `test_each_seat_agrees_with_the_page_map_on_a_controls_receipt` runs once with margin annotations and once with page annotations, and both fail on `main`. With the margin, `edit` shows no receipt where the Page Map shows `picked_up`. With page annotations, `edit` shows `picked_up` where `working` belongs. The `margin-model` runtime test checks that the cluster, its focused options and the Page Map read the same receipts, and the gallery atlas test now also checks the "On you" turn. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[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.
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:
saiddeleted; one factory for element directives.saidhad one caller, which passed the constantfalse. Every other template writes the label markers as static attributes, and that is now the only form: thread-card's resolved summary writesdata-lf-gen="1"again, andmodule-authoring.mdand therelabelcomment now describe the static markers. Thesaidexport, its test and its authoring line are gone.offered,contributionHostandcontributionReceiptseach repeated the same element-part skeleton;elementDirective(name, write)inwidget-elements.jsnow builds all three. Rendered markup is unchanged.#26:
commandsOnattaches once per connection. Before this change, every render re-attached the scope, which meant re-validating it, re-wiring its buttons and runningpaintKeys(). 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 whosewhenturns false loses itsaria-keyshortcutson 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 bugmainalready had: a declaration refused on re-render kept its stalearia-keyshortcuts, and because the element then left the reference's list, nothing ever cleared it.forgetScopedElementnow itself checks that nothing else declares on the element, which removes the same check from its three callers. The never-passedvalidateAtPaintoption is gone.#27: the Page Map's receipt choice moves into the model.
marginMapGroupsgives every row anaction.receipt(andawaitsUser). 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 bindcontributionReceipts(action.receipt, action.awaitsUser).contributionHost(source, surface, record, options)tracks the host on its surface itself, asmaterializeContributionControlsdoes for every host it presents, and thepaintcallback 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 newmargin-modelassertion covers which receipt each row gets.Line deltas (hand-written source excludes tests and Markdown):
widget-elements,thread-card,widget-api, the directive half ofcontribution-controls)keyboard/scopes.js)page-map-dialog,margin-map-model, the host half ofcontribution-controls)Checks: the
command-controls,margin-workflow,margin-model,passage-boundariesandindicationruntime tests. The two newcommand-controlscases fail onmain. In one, an unchanged re-render reads an unrelated scoped element 3 times. In the other, a refused re-render leavesaria-keyshortcutsbehind. 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 threecommandsOnjourneys (quoted passage, Questions panel, a thread Question's Done).