Repository navigation
Take the server off the hook path, every :has() off html and body, and repaint on focus in exports - #1402
Merged
Conversation
Focusing an empty options-addition box in an interactive export left its placeholder without the send key until the first keystroke. Since #1324 the box's hint is painted by the standing paint, and the request for that paint on a focus move came from the keyboard controller, which an export does not mount. The request now belongs to the repaint owner: `mountRepaint` listens for focusin and focusout itself, so any document that mounts the paint repaints on a focus move. The keyboard controller keeps only the disarming of a go-to sequence or react mode on focus. A chrome placement that hands focus straight back is still not a move. `repaint.js` is a runtime primitive and cannot read `runtime.placingChrome` from context.js, so that flag moves to focus.js, the primitive that owns where the user stands: `placeChrome(move)` runs a placement, and `placingChrome()` answers readers. margin-projection's lane move runs through it. The export test now checks that focus alone repaints the placeholder with its send key. It fails without the repaint.js listener. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Three rules read a flag off a descendant from a document root: - `html[data-lf-live]:has(body[data-lf-covering-surface])` - `html:has(body[data-lf-draw-mode])` - `html[data-lf-live] body:has(> main[data-rail="right"])` Chrome re-checks an element a `:has()` stands on when something below it changes, as #1324 found for the chrome root. On a corpus comment, the shortcut bar's writes and Lit's re-checked both BODY and HTML about 85 times each ("Affected by :has()" in the invalidation trace). Each flag now stands on the element its rule styles: - The covering auxiliary surface writes `data-lf-covering-surface` on `html`, which is the element whose scroll it locks. - Draw mode writes `data-lf-draw-mode` on `html`, the element that takes the crosshair. body's rule and the shadow sheet's `:host-context()` key off it there. Design mode stays on body, since no rule reads it through a `:has()`. - A page declares its rail with `data-rail` on `body`, the shell it pads, instead of on `main`. `page check` now takes it only there, and page-authoring.md and the glossary say so. margin-layout reads it off `body`. `test_no_has_rule_stands_on_the_chrome_root` becomes `test_no_has_rule_stands_on_a_root`, which covers `html`, `:root` and `body`, and reads a `:has()` inside an `:is()` or `:where()` argument as standing on that argument's compound. That is how `:is(html:root lf-options…:has(…))` stands on `lf-options`, not on the root. assets/AGENTS.md states the widened rule. The test fails on the old sheets. Measured with `leaf-dev profile corpus comment`, 3 runs each, base and branch run back to back at load ~11: style work per comment fell from 21.2 ms to 10.1 ms, and no "Affected by :has()" invalidation remains. Median input to paint was 77.7 ms on base and 72.3 ms here. Behaviour that moved in tests: draw-mode and covering-surface assertions read `html` instead of `body`, and the rail cases declare `data-rail` on `body`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Every hook Leaf registers waits on `import leaf.hooks`, in every session the plugin is installed in, and that import pulled in the page servers and all of page reading: `session` imported `hosting` (uvicorn, asyncio, `http`) for the wait's server revival, and `delivery`, `served_state.page` and `service` imported markup parsing, registry schemas (jsonschema) and, through `event_contracts`, anchor capture. Most hook calls come from sessions holding no page, which need none of it. - `hooks` is now the hooks' entry and the part that reads no page: the mark, the tool hook's wait announcement, SessionEnd's release, and an early answer for a session holding no page. A session holding a page reaches the new `hook_carrier` (the prompt and Stop hooks as the session's carrier: `unattended_pages`, `compose`, `carry_turn`) through the one import at that branch, since reading a page genuinely parses its markup and registry. - Receipt moves from `session` to `delivery`, whose docstring already owned it: `pending_batches`, `receive_one`, `receive`, `receive_delivery`, `take_input`. `session` keeps status and the `leaf wait` watch, which alone needs `hosting`, so the carrier never imports a server. - `kernel_event_kinds` and `bookkeeping_kinds` move from `registry.layer` to a new `registry.kernel` that imports no schema validator, so `service` (which every hook uses to find the session's pages) no longer pulls jsonschema. `event_contracts` still imports `anchor_capture` at the top: the carrier writes pickups through the append door, and once a page has been read the capture module costs nothing more to import (measured ~0 ms marginal). Tests: the ones naming `session.take_input`/`receive_delivery` and `hooks.compose`/`unattended_pages`/`HOOK_CONTEXT_LIMIT` follow the functions to `delivery` and `hook_carrier`. New `test_a_hook_in_a_session_holding_no_page_imports_no_page_reading_or_server` imports `leaf.hooks` in a fresh interpreter and runs a prompt and a Stop hook for a session holding nothing, asserting no server, page-reading, schema or anchor module loads; it fails on the base. Measured paired against the base, seven interleaved runs each on a loaded machine (load average ~32): `leaf.hooks` cumulative import (`-X importtime`, after `leaf.cli`) went from a median 263ms to 25ms, and a warm `uv run --no-dev leaf hook` for a UserPromptSubmit in a session holding no page from 427ms to 153ms. A session holding a page imports `hook_carrier` on top, about 0.1s. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…d paragraphs 23f9f31 moved `receive` from `leaf.session` to `leaf.delivery`; the usability-eval harness's acknowledge step still imported the old path. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # dev/leaf_dev/record_demo.py
# Conflicts: # skills/leaf/scripts/leaf/hooks.py
leaf-agent
previously approved these changes
Sep 28, 2026
leaf-agent
approved these changes
Sep 28, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 1, 2026
… and show it each Ask as `a` meets it (#1532) A user review of a 21-item triage queue page found that its worst wording problems were one failure: nobody read the page from the user's side before handing it over. Each item's context sat above its Ask, so `a` showed "Merge #1402 as it is?" with #1402's explanation scrolled away; a heading read "The Codex PRs share a blocker, and it isn't #1397", answering a question the author had put to its own research subagent; and the header chips compressed research the user never saw. `page-authoring.md` already asked the author to read the page as the user will. The session looked at three screens and handed over 20 seconds later, and even done, that reading is the author's own: every name on the page resolves from notes the user never had. Given the original page's screens and told to work it as the user would, a subagent with only the user's request flagged all three, plus shorthand such as "clock-offset page sizes" and "the Pi harness". A second subagent that also had the author's research reports flagged the three but missed the shorthand. ### What changes - **Pre-handover review** (`page-authoring.md`): once the check is clean, the reading goes to a subagent given the user's request and the check's labelled screens and nothing else, which reads the page as the user would and reports where it could not follow or had to guess. The author fixes what it reports and still judges the design. - **Screens at each Ask** (`render_gate/screens.py`): on a page with Asks, the check presses `a` from the top and saves `{width}px-ask-{k}.png` at each of the first eight open Asks it reaches, suggestions included, reading which Ask it reached from the runtime's own `data-lf-ask` mark; one more press tells it whether the walk goes on, which the label then says. `command.py` ends the screen list by pointing at the subagent reading. - **`.tag` in a flex or grid row** (`assets/theme.css`): `align-self: center`, so a chip beside a larger link keeps its own height instead of stretching to the link's with its text at the top. - **Feature gallery**: the side-list queue example's item description moves inside its `lf-ask`. - **TODO.md**: a Queues theme (`a` from a row reaching that row's Ask, answers shown in the list, groups, the item first on a phone), measuring the fresh-reader review, and a Stop-hook item. The queue's layout failures were fixed separately on main (#1472); an earlier sticky, measured side list on this branch was dropped in favour of it. ### Evidence `evals/record-read-without-the-notes` hands a child a clean render check on a page written from research reports and asks what happens before handover: the reader grader passed 0 of 3 on main's guidance and 3 of 3 on this branch (one branch run skipped reading `page-authoring.md`, so the case scored 2 of 3); `record-asks-hold-their-premise` stayed 3 of 3. The case checks that an author says it will hand off the reading, not that it does; TODO.md records measuring that, and the cost (about 110k tokens and two minutes on the triage page), across real sessions. > _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.
Three performance and structure follow-ups from the latency survey. Each is its own commit.
leaf hookno longer imports the server or page readingEvery hook Leaf registers waits for Python to import
leaf.hooks. That import pulled in the web server (session→hosting→ uvicorn) and page reading (delivery→event_contracts→anchor_capture, plusfull_state's markup and registry parsers), even though most sessions that run the hook hold no page.hooks.pynow keeps only the work that reads no page:PostToolUseannouncement of a backgroundleaf wait;SessionEnd;hook_carrier.py.hooks.pyimports it only when the session holds a page.sessiontodelivery, whose docstring already described them:pending_batches,receive_one,receive,receive_deliveryandtake_input.sessionkeeps status and theleaf waitwatch, and is now the only module that needshosting.registry/kernel.py, which needs no schema validator.serviceandregistry.layerboth import them from there.Measured on a busy machine, base and head alternating, 7 runs each:
import leaf.hooks(-X importtime)uv run leaf hookA new test runs the hook in a fresh interpreter for a session holding no page. It asserts that uvicorn,
hosting,http,hook_carrier,served_state.page,event_contracts,anchor_capture, jsonschema, markdown_it and turbohtml stay unloaded. It fails on the base. TheTODO.mdentry "A cheapleaf hook" keeps only what remains.No
:has()onhtmlorbodyThree rules read a flag off a descendant from a document root: the covering auxiliary surface, draw mode, and a page's declared rail. Chrome re-checks the element a
:has()stands on when anything below it changes, the pattern #1324 removed from the chrome root. On a corpus comment the shortcut bar's and Lit's writes re-checked BODY and HTML about 85 times each.Each flag now stands on the element its rule styles:
data-lf-covering-surfaceanddata-lf-draw-modeare written onhtml.data-railonbody, the shell it pads, instead of onmain.page check,page-authoring.md, the glossary andmargin-layout.jsfollow.The static test for a
:has()on the chrome root becomestest_no_has_rule_stands_on_a_root. It now covershtml,:rootandbody, and it reads a:has()inside an:is()or:where()argument as standing on that argument's compound. It fails on the old sheets.leaf-dev profile corpus comment, base and branch run back to back: style work per comment fell from 21.2 ms to 10.1 ms, and no "Affected by :has()" invalidation remains.Exports repaint the standing on focus
In an interactive export, focusing an empty options-addition box showed its send-key hint only after the first keystroke. The repaint on a focus move came from the keyboard controller, which an export does not mount.
mountRepaintnow requests that repaint itself. The placement flag it checks,runtime.placingChrome, moves tofocus.jsasplaceChrome()/placingChrome(), sincerepaint.jsis a primitive and cannot readcontext.js. The export test now checks that focus alone repaints the placeholder, and it fails without the change.Verification
uv run pytest tests -n 4andnpm run test:runtimepass on the merged head.notes/usability-eval/harness.py, now fixed.leaf-dev verify-codex-taskwas not run. The hook logic moved without edits, and that script spends real Codex turns.🤖 Generated with Claude Code