Skip to content

Sample the panel's fold as a probe journey, and profile bench-latency's transitions with --profile - #5264

Merged
max-sixty merged 4 commits into
mainfrom
agent-a1aa485e8fc68a118
Nov 3, 2026
Merged

max-sixty merged 4 commits into
mainfrom
agent-a1aa485e8fc68a118

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Two leaf-dev commands become modes of the ones they duplicated: bench-panel-motion is now a probe journey, and profile is bench-latency --profile.

The panel's fold, as a probe journey

dev/leaf_dev/panel_paint.py already held the mark and ring readers that the floating-panel test uses. It now also defines run(page), so the sample runs as

uv run leaf-dev probe SOURCE --journey dev/leaf_dev/panel_paint.py [--base]

It returns the old command's readings for each of the four fold routes: frames, intermediate mark positions, frames missing the mark or the ring, and the greatest mark-to-ring separation, plus the load average before and after. Through probe it also takes --base and any SOURCE. The floating-panel test imports the journey's ROUTES rather than repeating them. Two things about the reading changed:

  • Each route reads only the frames its input painted. A screencast's first frame can show the page from before the screencast started, stamped with its start time. The old command started a screencast per route, so each route could read a stale first frame: the . fold reported missing_ring: 1 on every bare-page run, and on review-a-plan a stale frame showed a count in the panel's row drawn in the ring's accent, which read as a 488 px separation. One screencast now spans all four routes, and each route takes the frames swapped between its input and the end of its motion, after the setup has come to rest. The journey waits for late frames before the screencast stops.
  • The body is made transparent before sampling. The chrome stands beside the body, so the page's own ink can't pass for the mark or the ring. Leaf's chrome stays painted, so a margin marker near the window's foot in the ring's colour would still count, as the module header says.

Readings on one build, the merge base's runtime: the old command on the bare page it used, then the journey on that page and on review-a-plan. Each cell is frames / intermediate positions, plus missing ring and separation on the keyboard routes. No run missed the mark.

run load (1 min) fold by pointer unfold by pointer fold by . unfold by Enter
bench-panel-motion, bare page 13.4 12 / 1 24 / 10 9 / 5 / 1 / 1.5 17 / 13 / 0 / 1.5
bench-panel-motion, bare page 12.8 10 / 4 15 / 4 13 / 7 / 1 / 1.5 12 / 10 / 0 / 1.0
bench-panel-motion, bare page 12.6 8 / 2 7 / 3 7 / 3 / 1 / 1.5 3 / 1 / 0 / 0.5
journey, bare page 17.2 6 / 3 8 / 1 5 / 2 / 0 / 1.0 10 / 6 / 0 / 1.5
journey, bare page 16.7 7 / 2 7 / 2 5 / 3 / 0 / 1.0 3 / 2 / 0 / 1.0
journey, bare page 15.5 14 / 9 10 / 2 2 / 0 / 0 / 1.0 3 / 1 / 0 / 1.0
journey, review-a-plan 15.4 9 / 1 12 / 2 5 / 1 / 0 / 1.0 2 / 1 / 0 / 1.0
journey, review-a-plan 16.0 12 / 6 14 / 1 13 / 8 / 0 / 1.0 7 / 5 / 0 / 1.0

The Mac was heavily loaded (1-minute load 13–17 for these runs, up to 59 earlier in the session), and every run went through taskpolicy -b. Frame delivery depends on scheduling, so these runs show that the journey reads what the command read, less the stale frame's missing ring. They don't measure the motion.

profile as bench-latency --profile

--profile traces and CPU-profiles every transition the run selects, using the same pages, transitions, runs and arms as the timing. After the table it prints profile's attribution for each page, transition and arm, and with --base the arms side by side. The window is now the benchmark's own window: the transition's start is placed on the trace's clock through a goal's lf-bench: mark. profile began an agent write's window at the trace's first span, so its reading included the leaf command's startup: under that rule a reply the table timed at 271 ms read 1782 ms in the profile. On one run the two now agree: move 278 / 277.6 ms, reply 438 / 437.5, revision 1198 / 1197.8.

--marks is gone. The user-timing section always prints under --profile. The Session.recording hook, whose only other user was profile, became the profiling itself, and scaling imports Profile from bench_latency. browser/AGENTS.md, bench_check.py and the responsiveness note now name bench-latency --profile.

go_to_threads when Threads is already open

Completing g T again closes the view (keyboard/go-to-sequence.js). bench-latency's reply transition asks for Threads after open() has already opened it, so on main it timed out waiting for the Threads view, whether reply ran alone or after a move. profile SOURCE reply failed the same way. go_to_threads now returns when the panel already shows Threads.

Not changed

bench-latency --page corpus fails on main as it does here. The first settle() after the page loads, before anything this change touches, reports "the page never settled within 30s": main's bench_latency.py and this branch's each failed 2 of 2 alternating runs at load 6–16. Probe reads the corpus as ready, so the wait is probably in the request ledger that quiet() in bench_latency.js checks. That is left for a separate change.

Removed for whoever ran them: leaf-dev bench-panel-motion, leaf-dev profile and profile --marks.

This was written by Claude Code on behalf of max-sixty

…'s transitions with --profile

Two leaf-dev commands become modes of the ones they duplicated.

`bench-panel-motion` becomes `run(page)` in `dev/leaf_dev/panel_paint.py`, the module that already held the mark and ring readers, run as `leaf-dev probe SOURCE --journey dev/leaf_dev/panel_paint.py`. It returns the same readings and load averages, and now takes probe's `--base`, `--record` and any SOURCE. To read any page, it makes the body transparent before sampling: the chrome stands beside the body, so only the panel's pixels reach the crop. On review-a-plan without that, page ink matched the ring's grey and the keyboard fold read a 250 px ring separation.

`profile` becomes `bench-latency --profile`, which traces and CPU-profiles every transition the run selects and prints profile's attribution after the table, per page, transition and arm, with the arms side by side under `--base`. `--marks` is gone: the user-timing marks section always prints under `--profile`. The `Session.recording` hook, whose only other user was `profile`, becomes the profiling itself, and `scaling` imports `Profile` from `bench_latency`.

`go_to_threads` returns when Threads is already open. Completing `g T` again closes the view (keyboard/go-to-sequence.js), so `bench-latency`'s reply transition, which asks for Threads after `open()` has opened it, timed out on main, alone or after a move, and so did `profile SOURCE reply`.

Behaviour changes for whoever ran them: `leaf-dev bench-panel-motion`, `leaf-dev profile` and `profile --marks` no longer exist.
…the benchmark's window

A screencast's first frame can show the page from before it started, stamped with its start. The journey now runs one screencast across its four routes and gives each route the frames swapped between its input and the end of its motion, so no route reads a stale first frame: bench-panel-motion's `.` fold reported `missing_ring: 1` on every bare-page run from that frame, and on review-a-plan the stale frame's On me count, in the ring's accent, read as a 488 px ring separation.

`--profile` now reads the trace over the benchmark's own window, placing the transition's start on the trace's clock through a goal's mark, rather than from the last keydown or, for an agent write, the trace's first span, which counted the `leaf` command's startup.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overlaps #5244, which renames the panel's data-open to data-lf-open and edits go_to_threads's wait_for line. Git won't report a conflict between the two hunks, so if #5244 lands second it keeps this PR's new get_attribute("data-open") == "threads" early return. That check would then never match, and the reply transition would close Threads again and time out, as it does on main today. If this PR lands second, the rebase needs the same rename.

@max-sixty
max-sixty merged commit 4e3f31b into main Nov 3, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-a1aa485e8fc68a118 branch November 3, 2026 23:49
max-sixty added a commit that referenced this pull request Nov 4, 2026
… a page's CSS can't name (#5244)

Leaf wrote 84 data attributes on its own elements outside the `lf-`
namespace that `page check` reserves for it: the floating panel's state
(`data-open`, `data-rest`, `data-shown`, `data-expanded`, `data-tone`
and two dozen more), a thread's and a message's identity (`data-thread`,
`data-event`, `data-message`, `data-attempt`), the paint boxes'
`data-for`, the composer's `data-words` and send corner, and the parts
the bundled widgets draw: lf-code's line numbers and elided rows,
lf-tabs' scroll buttons, the trace timeline's marks, the timeline's
events, the deck's pips, the call diff's lines and the diff's file rows.
It also wrote the `scroll` class on its own scroll surfaces. A page's
own CSS for one of those names restyled Leaf. On a probe page whose
`<style>` held `[data-tone] { --warn: red }`, `[data-event] {
--lf-msg-text-end: 123px }`, `[data-line] { background: blue }` and
`.scroll { outline: 4px solid magenta }`, main painted the panel's away
leaf red (rgb(255, 0, 0)), gave a margin card's messages a 123px text
end, painted lf-code's lines blue (rgb(0, 0, 255)) over its highlight,
and outlined lf-tabs' strip and panel, lf-code's scroller and
lf-options' "Add another option" field in magenta (4px rgb(255, 0,
255)). The chrome's `all: revert-layer` guard stops a plain declaration
but not a custom property, and a widget's parts in the page have no
guard at all.

Each is now the same name under `data-lf-`, its values unchanged, except
where that name already meant something a document-wide reader or an
unscoped rule relies on:

- the panel view's `data-view` became `data-lf-route`, since prepaint.js
sweeps `[data-lf-view]`, a revision's view members;
- the panel status's `data-held` became `data-lf-held-lines`, since
thread/presentation.js strips `data-lf-held` from every node no thread
holds;
- an On me item's `data-obligation` became `data-lf-obligation-id`,
since obligations/view.js sweeps `data-lf-obligation`, the location
mark, and chrome.css gives every `[data-lf-obligation]` a landing
margin;
- the composer field's `data-scrolls` became `data-lf-overflows`, the
name the margin card's transcript already gives the same fact, since
reach.js writes `data-lf-scrolls` on that field too.

Where the prefixed name was already in use for the same kind of fact on
other elements (`data-lf-tone`, `data-lf-state`, `data-lf-open`,
`data-lf-unread`, `data-lf-place`, `data-lf-ready`, `data-lf-line`),
every selector and query names its element, so the uses share a word
without meeting. The video bar's `data-hovered` and `data-keyed`, built
from one template, are `data-lf-hovered` and `data-lf-keyed`.

The `scroll` class stays the page's: page-authoring.md tells an author
to add `class="scroll"` to a custom horizontal scroll box, and `page
check` would refuse `data-lf-scroll` in markup. Leaf's own surfaces, and
a package module's (module-scroll-and-motion.md now says so, as it
already did for `data-lf-track`), wear `data-lf-scroll`, and reach.js
and the shared containment rule in controls.css read both. Where the
runtime marks an element the page owns (a code block, a part beside the
Layout's views, a bounded block's body), the mark joins
`RUNTIME_PAINT_ATTRIBUTE`, so a reading of the author's attributes looks
past it, as it did past `class`.

Kept as they are: the attributes an author writes (`data-width`,
`data-height`, `data-bound`, `data-sample*`, `data-annotations`,
`data-rail`, and `data-room`, which Leaf's own controls also use, one
rule for both), the playground's `data-playground-*` on its host, which
the author's preview CSS reads by design, Pierre's attributes on the DOM
it renders (`data-line`, `data-line-type`, `data-code`, `data-content`,
`data-separator` and the rest), including the ones lf-diff copies onto
its own rows and `pre` so Pierre's vocabulary keeps reading them, and
the diagram's `data-id`, which pele writes.

On the same probe this change shows Leaf's own styling: the away leaf in
the theme's warn (rgb(180, 116, 26)), the message's own 13px text end,
lf-code's lines unpainted but for the highlight, and no outline on any
widget part. Nothing changes on a page that doesn't target the old
names, and specificity is unchanged: each `[data-x]` became
`[data-lf-x]`, and `:where(.scroll)` became `:where(.scroll,
[data-lf-scroll])`.

Tests and dev tools read the new names. Attributes a test gives its own
fixture, which only share a word with Leaf's, stay: the `data-row` key
test_focus.py, focus.test.mjs and an application-boundary widget hand to
`holdFocus`, a test widget's `data-words` and `data-ready`, the shift
watch test's `data-key` on `body`, the write watch test's `data-for`,
and the examples' own `data-state` and `data-status`. The shift and
words watches' expected node paths lose the `.scroll` class
(`leaf-text#field`, `lf-diff#patch.lf-rendered`), and reach.test.mjs
asks a native code block for `data-lf-scroll`.

### Checks

- Main is merged in, and with it three new readers of the old names,
which now read `data-lf-obligation-id` (the On card selector,
`ON_CARD`), `data-lf-key` (the queue walk), `data-lf-event` (undo's
message lookup) and `data-lf-number` (a text document's line number, in
#5226's lf-text-document code and test). #5249's change bars write
theirs as `data-lf-for`, `data-lf-gap` and `data-lf-kind`, the stills
drivers that moved to `dev/leaf_dev/states.py` in #5259 read the new
names, as do #5263's fold test (`data-lf-says`, `data-lf-rest`) and
#5264's dev browser helper (`data-lf-open`).
- The pull request's `test` job: its failures outside the journeys fail
on main too; of the journeys,
`test_the_feature_gallery_exercises_its_core_journeys` failed here
because the test read the gallery's own preset buttons as
`data-lf-route`, and now reads the author's `data-view`. The
pressed-controls sweep's 28 cases,
`test_an_aimed_comment_keeps_its_place_with_on_me_open`, and the
navigation, controls and website-server journeys that failed fail the
same way on main.

- `pnpm run check` and `pnpm run test:runtime` (753 pass), pre-commit
over the changed files, and the kernel rebuilt with `pnpm run
build:browser`.
- 67 browser tests, by node id, that read the renamed attributes: the
floating panel's status peek, passing notices, versions, menu lists and
Threads' New; thread summaries, attempts, failure receipts and message
obligations; reactions; the send corner; the shift and words watches'
field paths; reach for an authored `.scroll` box; the trace timeline and
overview; timeline steps; lf-code excerpts and text-document numbers;
the diff's cut path; the call diff; overflowing tabs; On me cards; rings
and aim; a board's lifecycle; the recording bar; the smoke tier's three
changed tests; and read state.
`test_a_pointer_folds_the_panel_from_its_corner` fails the same way on
main: the corner button calls `foldPanel` directly, so no
`lf-command-invoked` arrives for the test to read.
- `leaf-dev stills` over the 61 catalogue states that draw the renamed
attributes found no computed style that differs; the style lists only
re-key the elements that lost the `scroll` class. Stills differ only
where every run differs: About's fingerprint and port, a caret's blink,
an overlay scrollbar's fade, and a target trace one arm caught
mid-transition, in the other arm on a second run. The stills drivers
name the new attributes, so for this comparison 21 states drove the
merge base's runtime through a local patch that accepted either name.

> _This was written by Claude Code on behalf of max-sixty_
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