Skip to content

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
max-sixty merged 6 commits into
mainfrom
visual-review-lit-cuts
Oct 12, 2026
Merged

max-sixty merged 6 commits into
mainfrom
visual-review-lit-cuts

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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 refs 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 Build element directives from one factory, attach commandsOn once per connection, and choose Page Map receipts in the model #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

max-sixty and others added 4 commits October 11, 2026 23:32
…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]>
@max-sixty
max-sixty merged commit 2c338ae into main Oct 12, 2026
2 checks passed
@max-sixty
max-sixty deleted the visual-review-lit-cuts branch October 12, 2026 07:54
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]>
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