Repository navigation
Let lf-visual-review declare radio keys with commandsOn, hold its shots by ref, and repaint only the pairs on an inspection choice - #2527
Merged
Conversation
…ts by ref, and repaint only the pairs on an inspection choice Follow-up to the Lit conversion (#2374), from the review of the Lit survey PRs (item #35 in that review's numbering, not a GitHub issue). - The inspector's radios declare their Enter/Space command with `commandsOn` in the template, in place of 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 refs the template already binds, so the post-render `querySelector` loop and the six `shotHost.querySelector("lf-shot")` lookups are gone, as is unobserving removed cases. - Only the selected case's head, toolbar slot and stage are size-observed, since hidden cases measure nothing; observation moves when the selection does. - 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 instead of once per case, and the selected pair is inspected with its allocation alone after the shared choices. - The focus-crop availability test has one home, `#focusAvailable()`. - `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 the `said` directive so the static markers are the one documented form. Tests: `test_visual_review_controls_keep_keyboard_navigation_local` now presses Enter on a radio and expects its mode (it fails with the command's `run` emptied). `test_visual_review_ignores_a_late_load_from_detached_evidence` replaces the evidence through `data set`, as a new run would, rather than swapping the `lf-shot` by hand behind Lit. The reorder test drops its `node === old` identity check, which its value, selection and focus assertions already cover. Behaviour changes: none a reader sees. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… the late-load test on the shown pair After failSoft resets the Lit part, each entry's refs read null, so the next-remaining control threw inside every page-wide key reflection. A failed source now discards its cases; the next good commit rebuilds them, keeping the selection. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…oad layout once updates settle Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…lare the draft history toggle in its template (#2516) 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**: #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_ --------- 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 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.
commandsOnin the template, replacing the widget's own path: a cache of ref callbacks, adatasetre-entry check andcommands(radio, …). The radios no longer carrydata-mode/data-scope/data-scale; the one control archetype that selected ondata-modenow selects on the radio'svalue.lf-shotand article through therefs the template binds, so the post-renderquerySelectorloop, the sixshotHost.querySelector("lf-shot")lookups and the unobserve-on-removal loop are gone.#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.failSoftview 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.#focusAvailable(), andtype="button"is dropped whereofferedalready writes it.data-lf-gen="1" data-lf-saidmarkers stay as static attributes. Lit cannot interpolate attribute names without a directive, and Build element directives from one factory, attach commandsOn once per connection, and choose Page Map receipts in the model #2504 removedsaidso 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
runis emptied.#41 (this widget's part).
test_visual_review_recovers_from_rejected_casesno longer exists: #2487 deleted it when thevisual-runcontract began refusing repeated case ids, so no data reaches the failure view now. The reorder test replaces itsnode === oldcheck 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_evidencenow replaces the evidence throughdata set, as a new run would, instead of swapping thelf-shotby 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
lf-visual-review.js940 → 917 (−23; +93/−116).