Skip to content

Count every tab panel's and deck card's obligations in one pass - #6151

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-5722-obligations-by-region
Nov 16, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-5722-obligations-by-region

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

A side list of tabs asked obligationsIn once per panel to draw each tab's mark, and a deck asked it once per card, so every render cost the regions times the obligations. This adds obligationsByRegion(regions, items), which places each obligation once and climbs from its source through the composed tree, adding it to each region it passes; obligationsIn is now that for a single region, so the containment rule has one home. lf-tabs reads it once per render (lazily, so a tab set with no asks still reads no obligations) and lf-deck once per reading. The package API exports it beside obligationsIn, and module-reading.md says when a module should use it.

On a new bench collection, leaf-dev bench asktabs (n side tabs, each holding an ask), a click's main-thread CPU:

tabs 32 64 128 256
main 34.2 ms 35.3 ms 45.7 ms 78.9 ms
this PR 35.2 ms 33.2 ms 41.0 ms 55.3 ms

Before the change, --profile attributed the click's growth to obligationsIn (exponent 1.74 from 32 to 256 tabs); after it, no function in the click grows past exponent 1.5. A runtime test holds the number of id lookups per obligation level from 8 regions to 64, and checks obligationsByRegion against obligationsIn on nested regions. The deck, side-tab and obligation-walk browser tests (37) and pnpm run test:runtime pass.

This leaves two parts of #5722: work.js's interventions, which still calls obligationsIn once per goal (the user's open obligations only, inside a recursive stopped), and messageHolding.

Part of #5722 — automated triage

A side list of tabs asked `obligationsIn` once per panel, and a deck once per
card, so each render cost the regions times the obligations. On a generated page
of 256 side tabs each holding an ask, the profile of a click put the growth in
`obligationsIn` (exponent 1.74).

`obligationsByRegion(regions, items)` places each obligation once and climbs
from its source through the composed tree, adding it to every region it passes.
`obligationsIn` is that for one region, so both keep one rule. `lf-tabs` reads it
once per render, the first time a panel asks, and `lf-deck` once per reading.
The package API exports it beside `obligationsIn`, and module-reading.md says
when to read it.

`leaf-dev bench asktabs` (new collection, side tabs of asks) measured a click's
CPU at 256 tabs going from 78.9 ms on main to 55.3 ms, and a profile of the
click shows no function growing past exponent 1.5. A runtime test holds the
placement's lookups per obligation level from 8 regions to 64.

Refs #5722
The panel tally reads obligationsByRegion now; the import survived only in a JSDoc type, which eslint's no-unused-vars counts as unused.
@max-sixty
max-sixty merged commit fb31296 into main Nov 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-5722-obligations-by-region branch November 16, 2026 09:12
max-sixty added a commit that referenced this pull request Nov 16, 2026
main's #6151 files every card's obligations in one pass (obligationsByRegion),
where this branch asked obligationsIn once per card and kept each answer for the
life of a reading. Resolved to main's one pass with this branch's keeping: the
deck files the cards once per obligation reading and reads that map for every
mark, word and row until the inventory changes.
leaf-agent added a commit that referenced this pull request Nov 17, 2026
`readWork` grew faster than the page in three ways inside one reading,
and this PR removes each. It placed the open widget obligations once per
goal. `stopped()` re-placed a nested goal's obligations once per
ancestor. And `workEntries` ran `querySelectorAll("*")` over each goal's
subtree, with `goalView` running it again for every descendant to find
leaves. Now `readWork` calls `obligationsByRegion` once for every goal
and computes each goal's `stopped` once. It also walks the scope a
single time, indexing each goal's and worker's children and leaves, and
builds each worker's view once. The values a reader gets back are
unchanged.

`tests/browser/test_render_work.py` now also checks each goal's leaves,
including a goal held inside another role, and those assertions pass on
both the old code and the new. `pnpm run test:runtime`, `pnpm run
check:browser` and pre-commit pass. No `leaf-dev bench` collection
contains `$work` widgets. Timed by hand on a tree where every goal holds
three subgoals, one reading took 2.8 ms before and 1.2 ms after at 120
goals (four deep), and 33.8 ms before and 13.2 ms after at 1092 goals
(six deep). The obligation placement is the fix #6151 made for `lf-tabs`
and `lf-deck`.

The other half of #6277 is still open. Widgets such as `lf-test-task`
and `lf-atlas-worker` (`examples/command-hub.page`) call `readWork` over
the whole scope from each `render`, so a scope of N tasks still computes
the projection N times per paint. Fixing that means sharing one reading
per scope and publication. Such a memo would need to keep each reader's
selector and clock dependencies (`quietSince` reads the clock) and to
see DOM changes that no selector tracks, so it is left to its own
change.

Closes #5722 — automated triage
Part of #6277

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 18, 2026
…waiting row with On Me's tray (#6152)

A page of parts lists its parts down the window's left edge, each row
with its part's summary. A side list of tabs also shows, under each
summary, the state of the questions its panel holds: an open mark while
one waits on the user, "On <agent>" while it is the agent's, and a check
with the answer's words once answered. The parts list showed none of
that, so a page of parts with a question per part read the same
untouched, answered, sent back and reopened. This draws the side list's
state for parts too. On a phone, where the list is a one-line row of
names, it is hidden as the summary already is.

It also changes how both lists mark a question waiting on the user. That
mark was a lone open circle under the summary, which Max read as an
empty list bullet. A waiting row now ends its name's line with On Me's
tray, the panel's symbol for what waits on the user, and the line under
the summary holds only the answer or whose turn it is. The tray keeps
its room in every state, as the line does, so answering moves no row and
a long name wraps the same either way. An accent dot (Leaf's mark for an
unread reply) and a mark before the name were tried and dropped.

The gap was not a decision. Side lists got the line in #2633, before
parts existed; #3198 added parts and moved the summary's condition from
`side` to `down`, leaving the state line on `side` with no reason given.

To weigh:

- A page of parts is the page's navigation, and a side list is the
documented shape for one decision per item. This puts a second display
of what On Me already counts on a surface whose job is to say what each
part is. For a part holding many questions the tray stays until the last
is answered.
- Leaf's symbols otherwise mark controls; the tray here marks state, in
the summary's grey, and the row is pressed as before.
- Cost on a large page: #6151, now on `main` and merged into this
branch, files a reading's obligations under their regions in one pass
(`obligationsByRegion`), and the parts list takes that pass. Measured
before it landed, with the two combined locally: a part switch on 400
parts with a question each takes 5.7 ms in Chromium, against 3.7 ms with
no state line and 36.7 ms on the per-row path this change would
otherwise have joined; from 100 to 400 rows the time grows 1.8 times.

It came out of comparing the `visual-review` widget with a page of parts
for the same six cases, where this gap was most of the widget's lead.
Max didn't ask for it; he read the before/after captures, asked for the
lone circles to go, and accepted the tray.

Checked with `main` merged in, with a new browser test covering an
untouched part, one answered through its widget, one the user commented
on, one reopened by undo, a part that asks nothing, and the phone row;
each piece of the change has an assertion that fails without it. The
existing parts and side-list tests, the browser type check and
`pre-commit` pass. Before and after captures at three widths in light
and dark differ only inside the list column; the desktop pair is in a
comment below.

> _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