Repository navigation
Cut Leaf UI over to Lit application state - #746
Conversation
# Conflicts: # TODO.md # skills/leaf/assets/runtime/banner-shelf.js # skills/leaf/assets/runtime/version.js # tests/test_render_controls.py
leaf-agent
left a comment
There was a problem hiding this comment.
The cutover reads coherently and the claimed path holds: I ran npm run check:browser, npm run test:browser (53 passed), and tests/test_render_projection.py (142), tests/test_render_conversations.py + tests/test_render_drafts.py (170), tests/test_render_gate.py + tests/test_render_options_settled.py (115), all green. Three things I'd like resolved before this lands.
The startup render count changed and the test stopped pinning it. test_waiting_projection_settles_before_ready_state_reopens_it went from asserting data-controller-renders == "1" to >= 1. I measured the actual value on this branch: a stable 2 across three consecutive runs, so the widget's renderState now runs twice during the waiting phase where it ran once. The + 1 delta below it is still exact, so what the loosening drops is precisely the count that moved. That count is the observable form of "publish that complete document contract once" — either the second publication is intended, in which case the test should pin 2, or it is an extra epoch the PR's own thesis says should not be there. tests/CLAUDE.md's A test cannot assert over noise it makes itself is the rule I'm reading this against.
Nothing reads the server's Ask projection any more. deriveAsks derives all, reader, unanswered, awaiting, and unansweredAwaiting entirely from descriptors and the effective projection, and asks/model.js now selects only from that. Grepping the runtime, lifecycle.page.asks and lifecycle.conversation.asks have no consumer left — yet this PR widens WireAsks with all, reader, and unanswered in the same change. That leaves a second, unread apparent authority for the Ask inventory sitting in the published root, which is the shape Keep the layer open and the one-writer table exist to prevent. If the wire fields are kept deliberately (export, page state parity, a future reader), it's worth saying so where the publisher builds lifecycle; otherwise the interface and both asks: entries can go.
The approve gate lost its transaction-boundary guard without a note. approvalBlockingAsks is now character-for-character unansweredAsks. The reading it replaced took the durable server list while projectionDeferred() held, on the stated ground that approval is irreversible enough to wait for that boundary while ordinary Ask surfaces narrate a local gesture immediately. projectionDeferred() still exists and still gates retryProjection, so the condition is live — a reader with an open draft editor now unlocks Approve on an optimistic answer that has not been admitted. If the guard is obsolete because the Ask reading no longer depends on the DOM, that reasoning should replace the deleted comment and the two names should collapse into one; if it isn't, the deferred branch needs to come back.
One dead symbol noted inline as well.
| controller_renders = int( | ||
| page.locator("#page-local").get_attribute("data-controller-renders") | ||
| ) | ||
| assert controller_renders >= 1 |
There was a problem hiding this comment.
Measured on this branch, the value here is a stable 2 (three consecutive -n0 runs), where it was 1 before. Pinning it keeps the test saying how many publications startup produces rather than only that there was at least one.
| controller_renders = int( | |
| page.locator("#page-local").get_attribute("data-controller-renders") | |
| ) | |
| assert controller_renders >= 1 | |
| controller_renders = int( | |
| page.locator("#page-local").get_attribute("data-controller-renders") | |
| ) | |
| assert controller_renders == 2 |
| const active = state?.browser.views[String(document.revision)]; | ||
| const lifecycle = { | ||
| page: { | ||
| asks: active?.document.asks ?? {}, |
There was a problem hiding this comment.
These two asks entries have no reader left after this PR: deriveAsks builds the whole inventory, and asks/model.js selects only from effective.asks. Grep for lifecycle.page.asks / lifecycle.conversation.asks and the runtime hits nothing. Dropping them takes the asks?: WireAsks fields on both AuthoritativeState branches and the WireAsks/WireAsk interfaces with them — which is why I haven't made this a one-click suggestion.
| export const allAsks = () => reading().all; | ||
| export const openAsks = () => reading().reader; | ||
| export const unansweredAsks = () => reading().unanswered; | ||
| export const approvalBlockingAsks = () => reading().unanswered; |
There was a problem hiding this comment.
This is now identical to unansweredAsks on line 16. The reading it replaced returned the durable server list while projectionDeferred() held, because approval is irreversible enough to wait for the transaction boundary. That condition still exists — state-feed.js gates retryProjection on it — so with an open draft editor deferring the projection, Approve now unlocks on an answer the log has not admitted. Either the deferred branch belongs back here, or the reason it is obsolete should replace the deleted comment and one of these two names should go.
| }); | ||
| } | ||
|
|
||
| export function commitWidgetDescriptors(stage, retired = new Set()) { |
There was a problem hiding this comment.
forgetWidgetDescriptors just below is now dead — version.js was its only caller, and the retire loop you added at the top of this function is its body verbatim. Its doc comment is also the only remaining statement of why the id-keyed readings are the ones that retire, so that paragraph is worth moving onto retired rather than deleted with the function. Happy to push that as a commit if you'd rather not carry it here.
The ESLint config enforces `no-undef` on every module — a lost import has to fail the hook rather than bind to `window.*` — but `no-unused-vars` was never configured, so a name nothing reads passed both hooks and stayed. Seventeen had collected: unused imports across the runtime and the boot entry, an uncalled composer helper, a destructured `registry`, and four locals, including a `for (const [key, marker] of rows)` whose second binding nothing used. The rule now runs over every module. Arguments and caught errors are left alone, since a signature says what a callback is handed, and rest siblings are ignored, which is how `lf-playground` drops one key from an object. This came out of an audit for unused keyboard bindings, which found none: the one candidate — three rows in the page-level response-options scope that can never fire, since the scope stands only while focus is in the comment field — turned out to be what teaches those keys in the command reference while the composer is closed. Removing them drops them from the reference, so they stay. Everyday suite green (1130). The browser files over the touched modules — navigation, margin, conversations, anchors, reactions, drafts — are green at 554, apart from `test_the_margin_groups_meanings_at_one_destination_without_moving_the_page`, which fails on main from bb80748 (#746) and is unrelated to this change. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…s a fault (#752) Both cases were red on main, and each failed on how it was arranged rather than on the behaviour it names. Neither runs on a pull request — they are nightly-marked — so the evidence here is local runs, noted below. **`test_the_margin_groups_meanings_at_one_destination_without_moving_the_page`** pressed ArrowDown from wherever the preview had left focus. The walk is over the markers the viewport holds and never scrolls to reach one, which is the contract this case is named for, so once #746 moved this fixture's third marker to 969 in a 900-pixel viewport the press landed on the last marker on screen, clamped, and the case read that clamp as a walk that had failed to move. It now presses Home to start at the first marker the walk offers and steps down from there, reading the count the walk itself publishes in `.lf-walk-position`. My first repair recomputed which markers the viewport holds inside the test; that is a second copy of `visibleRows`, and it drops the hidden, withheld and invisible rows that the runtime's copy also filters, so it could predict a neighbour the walk would skip. **`test_margin_layout_batches_the_composed_page_without_refolding_controls`** bounds the browser work of five margin layout passes that change nothing, but its count started before the page's first pass, which reconciles the contained frames it had just waited for. Measured on the corpus: | span | LayoutCount | RecalcStyleCount | |---|---|---| | first pass after the frames arrive | 4 | 21 | | every pass after it | 2 | 3 | | first pass after a resize | 2 | 3 | | five unchanged passes, warm | 10 | 11 | | ten unchanged passes, warm | 20 | 21 | A changed pass costs what an unchanged one costs, so the 21 is page startup rather than the price of a change. The budget of 30 was carrying an 18-recalculation constant it never named, and went red at 31 where that constant landed one higher. Spending that pass before the metrics snapshot leaves the five measured passes at 10 layouts and 11 style recalculations across the corpus's 39 clusters, so the same bound now states what the test names: work that follows the phases rather than the number of contributed controls. No product change: the margin layout's steady cost is 2 layouts and about 2.1 style recalculations per pass over 39 clusters. <details> <summary>Verification</summary> - Both cases pass, run together on a clean worktree at this change: `2 passed in 16.04s`. - `pre-commit run --files tests/test_render_margin.py` clean. - The whole `tests/test_render_margin.py` module on this change: `108 passed in 126.08s`. - The walk failure appeared in the scheduled nightlies of 2026-09-08 and 2026-09-13; the budget failure is macOS-only, since the constant lands under 30 on the hosted Linux runner. </details> > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…ened (#757) Three nightly cases have been red since #746 (bisected: green at 28554d3, red at bb80748). Main's Linux nightly for c20ecd1 (https://github.com/max-sixty/leaf/actions/runs/35183451662) fails on the same three, so every push run to main ends red and starts a `tend-ci-fix` session until they pass. **Asks published before the log was read (two cases).** Since #746 the application publisher derived the Ask inventory from authored descriptors while it was still waiting for the first server reading. `test_a_current_auxiliary_choice_replaces_a_persisted_tray_during_replay` saw the banner paint "Accept all (1)" for a suggestion the log had already accepted, and `test_the_room_is_measured_after_a_late_rail` saw the margin raise that suggestion's Ask marker and claim `--rail` before `lf-suggestion.js` was requested (a probe read phase `waiting`, no admitted reading, and `asks.all == ["sug-copy"]` at that moment). Before #746 the inventory stayed empty until the page was presented. The publisher now derives Asks only against an admitted reading, as it already did for threads. `application.test.mjs` asserts the empty inventory while waiting and offline, which fails against the unfixed publisher, so the PR gate covers what only the nightly suite caught; `packages.md` states it for `watchAsks`. **Approval stays shut without a reading.** An empty inventory before admission is absence of proof, not proof that every Ask is answered, and `paintApproval` read it as the latter: a page presented with no admitted reading (first state read refused, or pending past the presentation wait) offered sign-off over an unanswered Ask. `approvalBlockingAsks` now answers `null` in that case and the control stays disabled with its own title; `test_approval_waits_for_a_reading_of_the_log` fails against the previous gate. The Ask chip, `Accept all` and the ask walk stay absent on such a page, as they were before #746, because nothing there says which authored Asks still stand. **A test holding the contract #746 retired (one case).** #746 decodes authored state from source markup before modules upgrade. `test_a_stale_package_widget_uses_recursive_parent_eligibility`'s module moves `#quota` into `#destination` while upgrading, and the widget's own `renderState` then restores the authored placement under `#task`, at v1 and at v2 alike. The case expected the move to survive activation; it now expects `#task > #quota`. Reading authored facets off the live, moved node at activation (a fault injected into `version.js`) makes that assertion fail. Validation: the three cases pass, as do the approval, application-boundary, chrome-contract and startup modules (126); `npm run test:browser` (53) and `check:browser` pass; the full local nightly selection gave 2694 passed and 1 failed — `test_the_ask_walk_position_shares_the_shortcut_line` missing a 900 ms boundary flash under load, which passed 24/24 in paired runs of twelve concurrent processes on this branch and on main. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
The Lit application arc between 2026-09-13 and 2026-09-17 closed #1 and #3 without the list recording it: `semantic-state.js` is 77 lines over one publisher and `application.js` holds no DOM reference, while `version.js` activates through one door returning one result that `state-application.js` adopts atomically. Both leave for git history. The largest remaining duplication was not on the list. `scripts/browser/application.ts` re-derives the Ask inventory, the winner resolution and each thread's `awaits_reader` from a wire that already carries all three, roughly 750 lines that arrived in #746; the two copies of the `when` predicate already disagree on an attribute recorded as `null`, and nothing compares them. That inverts #4, which asked for a corpus proving parity between the two implementations — built first it would police one that should go — so #4 now names the deletion and the corpus follows it. Three items are new. #25 is the Worker's second App Server client, whose reconnect backoff is written four times and has already drifted. #26 is the generated-hint machine that `go-to-sequence.js` and `target-chooser.js` each build. #27 is admission: six of the nine `append_event` callers check no contract, and of the three that do, `cmd_receipt` uses a validator `requests.py` defines itself, so the rules sit in two homes and the gate in three against a stated boundary of validating once at the edge. They take ids above #23 because `notes/workspace-followups.md` numbers its research #1 to #23 and the workspace section here draws from it, so #9 and #10 were already spoken for. The section now says where its ids come from rather than leaving the next writer to rediscover it. The items that stay keep their numbers and gain what the survey measured: how much of `margin-projection.js` is already free of the DOM, what fraction of the render suite drives no input, and the 53 capabilities `page.js` and `leaf.js` both name. #8 stops waiting for a change to prove the need, which has happened. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The Asks drawer and a side-list queue's rows say what each answered Ask was answered with. Those words came from an `answer` reader each widget instance registered on its command scope as it rendered, over instance state, so semantic words lived on a renderer. On a settling revision the publication arrived before the widget re-registered its reader, and `watchAnswers` read a second time after `whenWidgetsPresented` to cover that race. `lf-tabs` caught a "more than one answer reader" TypeError per row, which only a module bug, or the test that injected a second reader by hand, could raise. Each `x-awaits` widget class now declares `static answerWords(state, element)`: words from the widget's state in the application publication and from its authored markup. `askAnswers` reads it synchronously from the publication that carries the Ask inventory, so: - `watchAnswers` is gone, and `lf-tabs` repaints its rows on `watchAsks`. - A tag has one class, so an Ask has one way to say its answer. The TypeError and its test, the per-row catch, the command scope's `answer` option, and `commandScopesWithin` are gone. - All six families cut over: lf-options, lf-draft, lf-suggestion, lf-playground, lf-targeting, and lf-swipe-deck. Where an old reader read instance or rendered state rather than what was answered, the words change: - A playground says the instruction its `choose` sent, not the one its controls show now. - A visual-targeting Ask counts the submitted configuration, not unsent local edits. - An option the user added is named by the rendered words its `add` carries, not read off the node the widget generated for it. lf-options also stops dispatching `lf-answered`, which nothing has listened to since #746. `test_an_answered_asks_words_are_its_widgets_semantic_state` covers the draft, playground, and added-option words, and a `multiple` group answered by Done with only its authored `chosen` option; its playground case fails on main. `answerWords` reads each verb's state without a fallback because every captured widget's state holds each declared verb from its authored markup (`initialState` in `projection/authored.js`). `test_a_queue_row_names_an_answer_whose_widget_module_arrives_last` holds lf-options' module until after lf-tabs upgrades and checks the row still names an answer recorded before load: startup imports every module the document names before the state feed starts, and the Ask inventory is empty until that first reading. Not fixed here: re-picking an option on a group a later version marked `settled` drops its Ask from the inventory, so the queue row loses its check (reproduced by extending `test_a_side_list_is_a_queue_beside_the_item_it_opens`). Admission stamps `meaning.answer` only while the group still asks (`answering_action` in `event_meaning.py` reads `x-awaits.when`, which `settled` turns off), and the inventory's interim "decided" reading (`_answered_by_user` in `asks.py`) keeps an Ask only while its standing action carries that stamp. The re-pick replaces the stamped action with an unstamped one. That is the Python Ask inventory, a separate mechanism from the words. It stays for the Tasks model, which replaces that interim reading; #1779 notes it in place. Verified locally: the Ask, queue, swipe, drawer, playground, targeting, draft, suggestion, and options browser tests (`-k` selections in `test_render_widgets.py`, `test_render_navigation.py`, and `test_render_controls.py`), `npm run test:runtime`, and pre-commit. `test_live_samples_keep_real_gestures_and_drafts_inside_the_child` fails the same way on this branch and on main. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Validation