Repository navigation
Paint composer state in the shared standing paint, and drop the chrome-root :has() - #1324
Merged
Merged
Conversation
…e-root :has()
A comment on the corpus page painted about 60 ms late because of two things on the
send path.
The composer kept its own paint beside the runtime's render loop. Every
`refresh()` in wireInput repainted the send button, placeholder and aria-disabled
synchronously and then called `layout()`, which for the floating composer was
`refreshFab` → `placeFab`: geometry reads right after DOM writes. One send ran
`refresh` three times (the sending flag, the settle's `load("")`, and
`syncSuggestMode`), each forcing a style recalculation of the whole chrome, and an
open ran it three times more. The standing paint already does all of this once per
frame: chrome layout's `syncLayout` places the response bar through `refreshFab`,
and `paintStandingGeometry` paints inputs through `paintInputs`. So `refresh()` now
marks its box stale and asks for that paint, and `paintInputs` paints every stale
box as well as the focus and hint boxes it already painted. The box's value and its
sending/uploading flags still change in the turn that changes them: the field's
caret and every reader after the writer depend on the value, and `submit()` guards
on the flags. The input module's own `focusin` paint goes too, since the keyboard
controller already asks for the standing paint on every focus move. The paint
writes through the identical-write rule (`keeps`, `keepsText`), because the old one
replaced the placeholder's text nodes on every call. The `layout` option becomes
`paint`, the caller's own rendering run inside the box's paint; only the options
addition widget uses it, for its empty-field flag.
Each of those recalculations cost about 4 ms because of one rule. The Page Map
toggle's `:scope:is(…, :has(> .lf-margin-projection > .lf-margin-toolbar[data-lf-pins]))`
put a `:has()` on the chrome root. Chrome re-reads such a rule on every insertion
below it and then restyled all ~800 chrome elements, so any text node written
anywhere in the chrome, including a Lit render of the thread list, made the next
geometry read expensive. The margin pass now writes `data-lf-pins` on the chrome
root, where chrome layout already writes `data-lf-rail-covered`, and the rule reads
both attributes. `test_no_has_rule_stands_on_the_chrome_root` keeps a `:has()` off
the root, and assets/AGENTS.md states the rule.
`responseAction` now returns early when the control already shows the requested
glyph and label. `syncSuggestMode` rebuilt the Suggest button's children on every
composer sync.
Measured on `corpus comment`, head against origin/main, paired and alternating on a
loaded shared machine: painted median 224 → 123 ms and 186 → 126 ms (two rounds of
8). Style recalculation in the input-to-paint window fell from 87.7 to 37.5 ms per
run (forced 86.4 → 35.1), and the send task from about 145 to about 85 ms
(scripts/profile_page.py, 3 runs each). `corpus reply` does not regress: 377 → 352
and 377 → 299 ms.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Sep 27, 2026
…fore Go-to An interactive export skipped `mountRepaint`, since it attaches no chrome. With text boxes now painting only in the standing paint, a choosable group's addition field in an export stood unpainted: no placeholder, Add visible and enabled, and typing repainted nothing. The export now mounts the standing paint with the one phase it has, the inputs' paint. `repaint.js` runs whichever phases a document supplies. `test_an_interactive_export_paints_a_widget_owned_text_box` asserts the field's placeholder, disabled Add and empty-field flag offline, and that typing clears the flag. It fails without the offline mount. `paintInputs` now runs first in `paintStandingGeometry` instead of last. The Go-to chips read each send button's aria-disabled to decide whether it is a destination, so they must follow the paint that writes it. The inputs' contextual hints read which box is shown, so they stay after chrome layout, and nothing a box paints changes geometry. standing.js states that order. `test_no_has_rule_stands_on_the_chrome_root` now reads every layer sheet. It catches `.lf-chrome` anywhere, and `:scope` or a top-level `&` inside the layer's one `@scope`, including inside `:is()`/`:where()`. It ignores what a `:has()` looks for, and asserts that the chrome's is the only `@scope`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 27, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 27, 2026
) Activating a revision took every authored attribute, class token and inline declaration off `html` and `body` and put the arriving revision's back on, including the ones both revisions write. A class taken off `body` and put back restyles the whole document, so every corpus revision paid a full restyle for attributes that hadn't changed. This came out of re-profiling revisions after the recent performance PRs (#1321, #1324, #1334). `replaceAuthoredAttributes` now takes off only what the outgoing revision wrote and the arriving one doesn't, and writes only what differs, through the layer's identical-write rule (`keeps`). Declarations are compared by name, so an empty custom property (`--x: ;`, which reads back as `""`) stays, and a newly declared empty one is written as the single space that parses to it, since `setProperty` with `""` removes; the old code dropped both. Runtime-owned attributes and inline properties survive, as before; the existing live-revision test covers adding, retiring and the runtime-owned `--lf-thread-panel-width`. Measured on the corpus with `scripts/profile_page.py corpus revision` (3 runs each, current main, load ~20): | | main | this branch | |---|---|---| | style per revision | 149.5 ms | 54.6 ms | | install task | 313–357 ms | 160–188 ms | Most of what's left in that task is `reachScrollers`, which #1340 takes down separately; the two together bring style per revision to about 15 ms. New test: a revision that changes only the title makes no authored attribute write on either root. It fails on the old code. > _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.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Sep 28, 2026
…t, the phone row inset and the overdue reading (#1400) Repairs the nightly failures in [run 36421522559](https://github.com/max-sixty/leaf/actions/runs/36421522559) that #1391 and #1392 left: thirteen failing node ids, one of which needed a product fix to the phone banner's menus. ## The phone banner's menus stand under their door On a phone the banner's action row puts More (and Versions after it) at the row's left inset, and More's menu and the Versions menu open under that door. Both menus clamped their left edge with `left: max(calc(8px + var(--lf-safe-left)), anchor(left))`. The `8px` restated the row's inset (10px then). #1338 cut that inset to 3px to fit three controls in 320px, so the clamp now binds and the menu stands 5px right of the control that opened it, which `test_the_versions_menu_uses_the_banner_panel_and_its_doors_edge` caught. The row's padding owns the inset, and the door already stands inside it, so the clamp can never be tighter than `anchor(left)`. Both menus now take `left: anchor(left)` in one rule; the second copy of the inset is deleted. The far edge is still bounded by the menus' existing `max-width: calc(100vw - 16px)`. Measured with `leaf-dev probe alert-review` (left, right edges in px): | viewport | surface | before (e730341) | after | |---|---|---|---| | 320×844 | More door | 3 – 27 | 3 – 27 | | 320×844 | Versions menu | 8 – 147.4 | 3 – 142.4 | | 320×844 | More menu | 8 – 206.1 | 3 – 183 | | 390×844 | More menu | 8 – 206.1 | 3 – 183 | | 1440×900 | More door | 1247.1 – 1283 | 1247.1 – 1283 | | 1440×900 | Versions menu | 1143.6 – 1283 | 1143.6 – 1283 | | 1440×900 | More menu, right edge | 1283 | 1283 | The More menu's width differs between the arms only because its build-identity row reads `Leaf sha256:…` on the base commit and `Leaf e730341+ · 9m ago` on the working tree; desktop placement is unchanged, since the change sits inside the `width <= 840px` block. ## Tests that read the address the bootstrap now rewrites (#1337) The bootstrap takes the host key `t` out of the address with `history.replaceState`. - `test_a_failed_preview_bootstrap_hears_the_replacement_server` (6 params) and `test_a_failed_bootstrap_hears_a_static_registry_generation` counted reloads with `framenavigated`, which also fires for that in-place rewrite (CI: `assert 2 == 1`; in the static-registry test the stub never answered because `len(navigations) > 1` held from the start). They now count the main frame's document requests (`requested_documents`), so a reload is exactly one more document and the rewrite counts as none. - `test_the_current_page_has_a_menu_local_key` read `pin` off the end of the address, which the rewrite turns into `?pin=`. It now asserts the address is the one it found before the press. - `test_a_draft_explains_its_change_and_restores_history_as_an_edit` opened its second tab at the keyless `page.url` and got a 403. It opens the handover URL `serve` returned. ## Other moved behavior - `test_a_thread_can_be_answered_in_the_margin_without_opening_threads` [1440, 1920]: since #1324 the reply placeholder paints in the standing paint on the next frame. The test read it in a microtask after `focusin`; it now reads it on the animation frame the focus asks for, after the runtime's own focus listener has queued that frame's paint. - `test_a_thread_says_what_the_agent_is_doing_about_it`: since #1331 a turn that ends with updates still the agent's to answer makes them overdue, so the banner says "Nothing is answering them, so nudge it in the terminal." The expectation follows. ## Checks All 13 node ids pass locally, and `leaf-dev flake` ran each changed test (one parameter of each parametrized one) as 18 concurrent copies: 126 of 126 passed. The banner and menu cases in `test_render_controls.py` also pass beside the CSS change, as do 54 phone, banner, menu and version cases across the anchors, aim, navigation, pages, widgets, threads and projection files. > _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.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Sep 28, 2026
…d repaint on focus in exports (#1402) Three performance and structure follow-ups from the latency survey. Each is its own commit. ## `leaf hook` no longer imports the server or page reading Every 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`, plus `full_state`'s markup and registry parsers), even though most sessions that run the hook hold no page. - `hooks.py` now keeps only the work that reads no page: - marking that the hook ran; - the `PostToolUse` announcement of a background `leaf wait`; - releasing claims at `SessionEnd`; - an early return for a session that holds no page, where every prompt and Stop step already did nothing. - The prompt and Stop logic moved unchanged into a new `hook_carrier.py`. `hooks.py` imports it only when the session holds a page. - The receipt functions moved from `session` to `delivery`, whose docstring already described them: `pending_batches`, `receive_one`, `receive`, `receive_delivery` and `take_input`. `session` keeps status and the `leaf wait` watch, and is now the only module that needs `hosting`. - The kernel event kinds moved to a new `registry/kernel.py`, which needs no schema validator. `service` and `registry.layer` both import them from there. Measured on a busy machine, base and head alternating, 7 runs each: | | base | head | |---|---|---| | `import leaf.hooks` (`-X importtime`) | 263 ms | 25 ms | | warm `uv run leaf hook` | 427 ms | 153 ms | A 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. The `TODO.md` entry "A cheap `leaf hook`" keeps only what remains. ## No `:has()` on `html` or `body` Three 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-surface` and `data-lf-draw-mode` are written on `html`. - A page declares its rail with `data-rail` on `body`, the shell it pads, instead of on `main`. `page check`, `page-authoring.md`, the glossary and `margin-layout.js` follow. The static test for a `:has()` on the chrome root becomes `test_no_has_rule_stands_on_a_root`. It now covers `html`, `:root` and `body`, 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. `mountRepaint` now requests that repaint itself. The placement flag it checks, `runtime.placingChrome`, moves to `focus.js` as `placeChrome()`/`placingChrome()`, since `repaint.js` is a primitive and cannot read `context.js`. The export test now checks that focus alone repaints the placeholder, and it fails without the change. ## Verification - `uv run pytest tests -n 4` and `npm run test:runtime` pass on the merged head. - An independent review of the three commits found one missed caller of the receipt move, in `notes/usability-eval/harness.py`, now fixed. - `leaf-dev verify-codex-task` was not run. The hook logic moved without edits, and that script spends real Codex turns. > _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.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.
A comment on the corpus page painted about 60 ms late because of two things on the send path: the composer ran its own paint beside the runtime's render loop, and a
:has()on the chrome root made each of that paint's geometry reads restyle the whole chrome.The composer paints in the standing paint
Every
refresh()inwireInputrepainted the send button, placeholder andaria-disabledsynchronously, then calledlayout(). For the floating composer that wasrefreshFab→placeFab, which reads geometry right after those writes. One send ranrefreshthree times (the sending flag, the settle'sload(""), andsyncSuggestMode), each forcing a chrome-wide style recalculation, and an open ran it three more times.The standing paint (
repaint.js) already does this work once per frame: chrome layout'ssyncLayoutplaces the response bar throughrefreshFab, andpaintStandingGeometrypaints inputs throughpaintInputs. Nowrefresh()marks its box stale and asks for that paint, andpaintInputspaints every stale box along with the focus and hint boxes it already painted. The paint writes throughkeeps/keepsText; the old one replaced the placeholder's text nodes on every call.What stays synchronous, and why:
hydrate): the field's caret and every reader after the writer (sync.value(), the draft save) depend on it.sending/uploadingflags:submit()guards on them against a second press in the same turn.showFab,showComposer):showFabdecides from geometry whether the bar fits at all, and focus landing waits on that placement.The standing paint now runs its text boxes first in
paintStandingGeometry. The Go-to chips that follow read each send button'saria-disabledto decide whether it is a destination. The boxes' contextual hints read which box is shown, so they stay after chrome layout, and nothing a box paints changes geometry.standing.jsstates that order. An interactive export, which attaches no chrome and used to mount no standing paint, now mounts it with the inputs' paint as its one phase (repaint.jsruns the phases a document supplies), so a choosable group's addition field paints offline as it does live.The input module's own
focusinpaint is gone, since the keyboard controller already asks for the standing paint on every focus move. Thelayoutoption becomespaint, the caller's own rendering run inside the box's paint. Only the options addition widget uses it, for its empty-field flag.The standing paint runs in the frame the change first shows in (a
nextRenderfrom an input handler runs before the next paint), so the button, placeholder and placement show up in the same frame as the words.No
:has()on the chrome rootThe Page Map toggle's
:scope:is(…, :has(> .lf-margin-projection > .lf-margin-toolbar[data-lf-pins]))put a:has()on.lf-chrome. Chrome re-reads such a rule on every insertion below it and then invalidated the whole chrome subtree (about 800 elements), so any text node written anywhere in the chrome, including a Lit render of the thread list, made the next forced recalculation cost about 4 ms. I confirmed it by dropping the arm: style in the input-to-paint window went from 115 to 34 ms. The margin pass now writesdata-lf-pinson the chrome root, where chrome layout already writesdata-lf-rail-covered.test_no_has_rule_stands_on_the_chrome_rootkeeps a:has()off the root in every layer sheet:.lf-chromeanywhere, and:scopeor a top-level&inside the chrome's@scope, including inside:is()/:where(). It fails on the old rule and on each of those planted shapes, andassets/AGENTS.mdstates the rule.responseActionnow returns early when the control already shows the requested glyph and label. Before,syncSuggestModerebuilt the Suggest button's children on every composer sync.Measurements
The machine was shared with other suites (load 35–90), so read the paired numbers.
corpus, head vs origin/maincommentpainted median, 8 paired runs, round 1commentpainted median, 8 paired runs, round 2replypainted median, round 1replypainted median, round 2commentstyle per run,scripts/profile_page.py, 3 runscommentsend task (keydown task)LEAF_INVALIDATIONS=1)Per-step, on a less-loaded run: the composer change alone took the send task from 119 to 87 ms by removing the three
refreshFabrecalculations and the key-scope one they set up. The:has()change then took it to 69 ms. The forced recalculations that remain (CodeMirror selection reads, thread-list scroll hold, focus return inletGo,pageSelectionin the send's reveal check) now touch at most about 120 elements each.Tests
npm run test:runtime: passes.test_render_export.pyandtest_render_options_addition.py(52): pass. The newtest_an_interactive_export_paints_a_widget_owned_text_boxfails without the offline mount.test_render_{navigation,threads,margin,controls,aim,anchors}.py(78 tests): 78 passed on the final code. An earlier concurrent pair at load ~70 failedtest_live_specimens_keep_real_gestures_and_drafts_inside_the_childon a 5 s wait for a child page to present. It passes alone and in two further concurrent runs.test_render_drafts.py,test_render_outbox.py,test_render_options_addition.py,test_render_semantic_selection.py(183): all pass excepttest_a_single_space_is_message_content_in_every_composer[reply], which fails the same way on the base runtime. Give packages independent Thread views and typed actions #1288 gave replieshasContent: raw.trim(), so a single space leaves Send disabled.🤖 Generated with Claude Code