Repository navigation
Let commands own button activation and availability - #1788
Conversation
# Conflicts: # build/browser/generated/browser-runtime.js.map # build/browser/generated/browser-runtime.manifest.json # skills/leaf/assets/vendor/browser-runtime.js # skills/leaf/packages/default/widgets/lf-draft.js # skills/leaf/packages/playground/widgets/lf-playground.js # skills/leaf/packages/swipe/widgets/lf-swipe-deck.js # skills/leaf/packages/targeting/widgets/lf-targeting.js
leaf-agent
left a comment
There was a problem hiding this comment.
The committed browser output is stale at this head. The new noChange export in build/browser/index.ts changes the bundle, but npm run check:browser fails on the committed browser-runtime.js, source map, and manifest (failing test job). I reproduced the mismatch after npm ci; npm run build:browser changes those three tracked outputs. The regenerated outputs need to be committed for the test gate to pass.
leaf-agent
left a comment
There was a problem hiding this comment.
The test gate is red on the approved head: test_message_age_may_shift_metadata_but_leaves_the_thread_in_place fails for inline and panel because its native layout-shift list is empty (CI job). This PR reserves width for the root message’s workflow label, so those surfaces no longer produce the receipt movement the test requires. The test needs to check that the thread and controls remain in place without requiring a shift where the receipt is now stationary; its card case still passes. I can push that test repair if you’d like.
CI failed: message-age shift test expects movement after workflow-width reservation.
Chrome attributes inline and panel metadata shifts to the reserved workflow wrapper. Check updated ages, retained receipts, and stationary thread text and controls directly instead of requiring movement attributed to the receipt span. Existing deliberate passive-motion controls retain coverage of the watcher exemption. Validation: 14 focused age and watcher cases; all three age surfaces again after the final receipt assertion; all-file pre-commit.
After the version menu closes to open Command reference, its Tab-boundary commands are unavailable in the current scene but should remain listed there as unavailable. The catalog's first pass honors `commandReferenceWhen`, then `commandPresentations` filtered those rows again through live dispatch availability and removed them. Keep unavailable identities for the reference's catalog while dispatch and the shortcut bar retain their live-only projection. This fixes the remaining failure in the anchor browser file on current main and follows the command ownership change in #1788. The existing browser case failed before this change and passes after it. A new runtime assertion failed before the change and now passes for both a plain command and contextual routes. The full runtime suite passes (`222 passed`); the anchor browser file previously had 108 passing cases and this one failure. Co-authored-by: leaf-agent <[email protected]>
#1788 wraps the label in .lf-msg-workflow in the Threads panel, so the two startup tests that check it closes the message's meta row read the slot. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Keep a contribution's next reading together while its command checks a retained control. #1788 made command availability consult those controls; during draft projection, that lookup could settle a pending contribution update before normalization finished. The margin then painted an intermediate option state and reversed it in the same script. The new runtime test fails before the guard with a listener seeing the old `idle` entry during the read, then the final `engaged` entry. With the guard, it sees only the complete reading. The [failing render-gate case](https://github.com/max-sixty/leaf/actions/runs/37301484253) also passes locally; four draft cases, two margin cases, all 223 runtime tests, and the changed files' pre-commit checks pass. Refs #1592. The separate failures from that full run are being addressed through other changes; this PR fixes the contribution reentry cause. Co-authored-by: leaf-agent <[email protected]>
…#1968) A declared native button only began answering its clicks once the next repaint ran `reflectButtons`, which is where its click listener was attached. A press arriving between the declaration and that repaint did nothing. The margin card's thread step showed it (`test_a_shared_passage_steps_between_single_thread_cards`): - Next builds the second thread's card and focuses it. - `r`, pressed right away, runs the thread scope's resolution row, which clicks the new card's Resolve. - That button has no listener yet, so no `resolve` is sent and the card keeps both threads. On main the test failed 17 of 18 concurrent runs and every serial run. It passed when the test paused 300 ms before `r`. Bisecting puts the start at #1788, which moved button activation into the command owner. `attachScope` now wires each button a declaration names as an element when the declaration is made. A control named by a getter may not exist yet, so it is still wired at paint. The listener resolves its command at the press, as before, so availability, replacement and refusal keep their meaning. The margin test now passes 18 of 18 concurrent runs. A new runtime test in `tests/runtime/command-controls.test.mjs` clicks a button before any paint, and it fails without the change. These also pass: - `npm run test:runtime` (228 tests). - 133 browser tests selected by command, button, resolve, press and settle across the controls, navigation, widgets, margin and threads files. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
A selected screenshot caption still owns its Space action so the page cannot scroll when the user presses it. The nightly test expected its shortcut to disappear after selection and failed. It now checks the standing shortcut and verifies that Space keeps both the selected endpoint and the page's scroll position. The [main CI run](https://github.com/max-sixty/leaf/actions/runs/37929061293) and preceding run failed this test. I reproduced the assertion locally, then reran the exact node after the change: 1 passed. The widget's selected-caption behavior is declared in `lf-shot.js` and was established by #1788. --------- Co-authored-by: leaf-agent <[email protected]>
… 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]>
Widget authors currently coordinate click handlers, keyboard forwarding, disabled painting, and shortcut metadata for the same action. This moves native button activation and availability into the existing command owner: a declaration supplies its control, semantic callback, and availability predicate, and
paintKeys()refreshes availability and shortcut presentation after private state changes.The cutover covers widgets, thread controls, version controls, and projected contribution controls. Projected controls invoke the same declared command with their gesture context; native editing and selection-sensitive offers retain their existing event owners. Existing user interactions are preserved.
Caller wiring removes 43 net lines. The shared runtime grows to own that behavior and its lifetime, so this simplifies the caller contract rather than reducing total code. The authoring reference, feature-gallery example, and contextual-key eval now exercise direct semantic callbacks. The Worker bundle test retains its build inputs until completion. The CI repair also keeps a thread’s news control stationary when its workflow label disappears or its notice grows: the root message reserves canonical workflow labels, and a shared grid gives metadata, news, and trailing actions separate room. The website regression test waits for the accepted turn to be presented before resolving it, then checks the news button’s position through both transitions. Timestamp-aging checks now assert updated ages, retained receipt text, and stationary thread text and controls directly; the independent passive-motion controls cover permitted metadata movement without requiring Chrome to attribute it to a particular span.
Validation: the frozen implementation passed the full Python gate (2,182 passed, one Linux-only font check skipped on macOS). After integrating current main, 16 focused Chrome integration checks passed alongside 220 runtime tests, 76 browser-framework tests, 66 Worker tests, six eval assertions, bundle reproducibility, and all pre-commit checks. Chrome coverage includes native activation and form defaults, draft editing, swipe ordering, targeting submission, contextual aliases, refusal, and version-menu focus. The CI repair additionally passes all four hosted-turn variants, nine focused layout cases, a 320px touch case with 44px targets, and 14 timestamp-aging and passive-motion cases. Both authoring-eval candidates passed and both baselines failed, one run per host. Startup comparisons report no console errors or layout shifts; timings on the shared machine are diagnostic.