Skip to content

Regions follow what their reading and their paint read - #2815

Merged
max-sixty merged 36 commits into
mainfrom
tracked-region-readings
Oct 14, 2026
Merged

max-sixty merged 36 commits into
mainfrom
tracked-region-readings

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The four document-wide regions (projection, threads, asks, the Questions panel) no longer list their inputs by hand. applicationPresenter (skills/leaf/assets/runtime/semantic-state.js) collects the parts the region's reading reads and the parts its paint reads before its first await, the same way watchers already do, and claims a presentation inside any publication that moves one. This is the next step of cutting the browser runtime over to one reactivity model (notes/browser-reactivity.md).

What changed for each region. The Questions panel and the asks say in reading only whether they are mounted; their paints already read through readers. The projection's paint reads its parts through readers instead of the whole root. The thread presentation keeps naming phase, thread state and document in its reading, because its commit reads them again after it waits for package preparation, where collection can't see. Covering those continuation reads is the next change.

How a region decides to claim. Each region checks its recorded parts from one subscription to the publication, made when the region is created, so it claims at the same point in a publication as before. A first version subscribed to each part it read; that put the claim after the publication's other subscribers, and a send waiting for the page to be presented went on before the thread had claimed (test_a_source_replacement_preserves_the_focused_draft_and_its_original_anchor). A paint that moves a part it read paints again; a reading that does so is refused, since only the paint may publish.

Nested owners. A widget a region's paint mounts connects inside that paint. Its controller's connect and publish run outside the collection (untracked, build/browser/snapshot.ts), since what it draws is its own selection's to follow. Presentation proof reads the root's epoch the same way, so a paint that waits on proof subscribes to nothing by waiting.

Evidence. Region claims and paints on the corpus page's load, comment and card move are unchanged against main (instrumented counts). pnpm run check passes, with new tests/runtime/region-presenter.test.mjs; about 250 focused browser tests across the Questions panel, asks, projection marks, settlement, approval, frozen thread widgets, floating panel and startup pass. Two Codex reviews found the paint-publishes and reading-publishes cases, both fixed here with tests.

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

max-sixty and others added 30 commits October 12, 2026 15:01
…und trip

A Leaf process keeps the readings of the eight pages it read most recently, and a
sample is a page of its own. The corpus now opens sixteen, so a server's own page
was pushed out continually, and every state answer, the event POST's included,
checked and captured the whole source again: about 0.6-1.4 s per answer on the
corpus, where the same POST to an idle server takes 27 ms. Durable servers held
their page's memory already; temporary ones (`leaf server run --temporary`, plain
previews, the suite and the latency bench) and the website's multiplexed server
did not. A sample now holds its parent's memory beside its own, so a page is kept
while its samples live, whichever server serves it.

Work readings asked `layerFact("$work")` once per element walked, and `layerFact`
structured-clones the declaration for package modules. On the corpus that was
about 55 ms of every presentation. `work.js` reads `registry.$work` in place, as
it already reads `registry.$states`.

`leaf-dev bench-latency` narrows to a page, transition and run count, and `--tree`
times the working tree alone without building arms, so one corpus comment takes
under a minute. It reports when the answer to the gesture's own POST (matched by
attempt) arrived beside painted and Sent, and who held the main thread until the
last goal, from the page's long animation frames clipped to that window. `leaf-dev profile` now reads its window through the last goal,
so a gesture's profile covers the answer's application as well as the local draw.

Measured with `bench-latency --page corpus` against main (5 runs, load 9-13),
medians: comment Sent 1187 -> 409 ms, move Sent 1168 -> 335 ms, agent reply
1044 -> 227 ms, status 850 -> 210 ms, revision 2574 -> 1893 ms; painted within
noise (comment 238 -> 202 ms, move 126 -> 139 ms). The triage board, which has no
samples, was unchanged in an earlier full run.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nged

The publisher shares every subtree of a candidate that is deep-equal to the standing
reading's, and a selection shares its derived value against its previous one. A
selection of one part of the reading now hears only that part move, the epoch
advances by identity, and the JSON signatures that stood in for it (the epoch's,
selectWidget's memo, the traffic ledger's guard) are gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
applicationPresenter takes the region's reading as a selection of the semantic root
and claims inside each publication that changes it. A publication that leaves it
unchanged, such as a widget's own action for the thread, Questions and queue regions,
claims nothing, and the coordinator carries the region's standing commit into the new
epoch. Mechanical changes still claim through present.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
watchProjection selects its reading from the semantic root and paints when the
selection changes, a drag holds the projection, or PRESENTATION fires, instead of on
every semantic epoch. watchQuestions, watchQueues, watchThreads, watchHistory and
watchReports select the reading they are named for; the annotation inventory, the
reaction offer and the approval control name theirs. A return after an absence
compares the selection by identity. module-authoring.md states the narrower rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Shortcut reflection and native button availability ran over every scoped element
and every command button on any key paint, and every publication painted keys. On
the corpus that was ~550 elements and every button predicate per frame. Each scoped
element's reflection and each button's availability now runs as a Preact effect: a
publication that moves a signal it read marks that element or button alone. What a
predicate reads beyond signals is a mechanical change its writer reports:
paintKeys() for the page, and paintKeysWithin(root) where a renderer rewrote part of
it (a widget render or gesture resume, the composer's controls, a disclosure toggle).
Publication-driven paintKeys() calls are gone. Renderer-private state that command
predicates read is a signal: drag hands, a thread card's and the narrowing view's
models, the committed unread threads, lf-trace's cursor. widget-api exports
`signal` so a package can do the same; module-authoring.md says so.

The rest of the selection conversion:
- watchWork(owner, callback) follows what readWork reads (widget states, threads,
  asks, reports, publication time); widgets that count their children's work
  (lf-test-task, Atlas's plan) use it instead of watchReports, whose reading now
  includes the publication time saidAt answers with.
- The annotation inventory also selects the projection and waits for its chrome to
  commit, since it lists the marks that chrome paints.
- The thread region reads only its fold and the document; the margin's own watcher
  follows Questions and workflows.
- Banner status, the queue walk and the floating panel follow selections, not every
  epoch.
- Widget readings come from a per-publication index of each widget's entries, and a
  widget recomputes only when one of its inputs changed by identity.
- The visual "Respond to" plan is keyed on the page reading, presentDocument calls,
  the shown document, and visual-part layout signals rather than rebuilt on every
  thread pass.
- share() defines copied fields, so a JSON field named __proto__ stays an own field.

Behavior changes: a watcher callback that reads beyond its named reading must use
the watcher for what it reads (documented); module-authoring.md and the root
AGENTS.md invariant describe selection-keyed claims. Tests: the projection
subscription test uses the new watchProjection signature; the resolve-recovery test
also asserts the button is not aria-disabled; a sharing test covers __proto__.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	build/browser/application.ts
#	skills/leaf/assets/runtime/anchor-controls.js
#	skills/leaf/assets/runtime/application.js
#	skills/leaf/assets/runtime/asks/view.js
#	skills/leaf/assets/runtime/banner.js
#	skills/leaf/assets/runtime/floating-panel.js
#	skills/leaf/assets/runtime/keyboard/scopes.js
#	skills/leaf/assets/runtime/projection-watch.js
#	skills/leaf/assets/runtime/questions/model.js
#	skills/leaf/assets/runtime/queue-walk.js
#	skills/leaf/assets/runtime/thread/presentation.js
#	skills/leaf/assets/runtime/thread/thread-card.js
#	skills/leaf/assets/runtime/work.js
#	skills/leaf/assets/vendor/browser-runtime/application.js
#	skills/leaf/references/module-authoring.md
Key and button reflection track what they read, so an accessor that reads the whole
root (runtime's getters, readAsks, readQueues, threadState, currentProjection,
agentName, and main's new savedReadingSettled) made every reflection calling it read
again on every publication: after merging main, a card move re-reflected ~470 of the
corpus's scoped elements. readPart(derive) is a reader of one part through its own
selection; those accessors use it, and a move reflects 7-18 again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…g is a signal

After merging main, a comment's thread pass rebuilt the page outline from a whole-page
query and placed every thread under its heading again (~20 ms), and the annotation
inventory did the same. The outline is a reading of the page's own nodes, so it stands
until the page reading moves or presentDocument says the document changed; a thread's
section stands while its record, its place and the outline do.

Where the user stands is now a signal that focused() reads, so a command whose
liveness asks where the user stands is tracked like any other input, and button
availability no longer re-reads every button on each focus move.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ands under

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A comment's thread pass re-presented every card in the panel. A card now keeps its
drawing when the list hands it the reading it last drew, compared by content with
share, and its outside inputs (a reply being written, a held draft, its open state)
stand. Cards mid-fold, holding news or owing a release draw on every pass as before.
The card's recency moved into its reading, so a card that keeps its drawing still
ages on the clock's pass. share is exported from the browser facade.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	build/browser/application.ts
#	examples/command-hub.page/widgets/lf-atlas-plan.js
#	examples/corpus.page/widgets/lf-atlas-plan.js
#	skills/leaf/assets/runtime/anchor-controls.js
#	skills/leaf/assets/runtime/asks/model.js
#	skills/leaf/assets/runtime/reactions.js
#	skills/leaf/assets/runtime/thread/presentation.js
#	skills/leaf/assets/runtime/widget-elements.js
#	skills/leaf/assets/runtime/work.js
#	skills/leaf/assets/vendor/browser-runtime/application.js
#	skills/leaf/packages/playwright/widgets/lf-trace.js
#	tests/fixtures/packages/work/widgets/lf-test-task.js
# Conflicts:
#	skills/leaf/assets/runtime/keyboard/disclosure.js
canZoomIn read the scroller's clientWidth, so every reflection of the zoom command's
liveness forced a layout of the whole page (~18 ms on a corpus comment).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	build/browser/application.ts
#	examples/command-hub.page/widgets/lf-atlas-plan.js
#	examples/corpus.page/widgets/lf-atlas-plan.js
#	skills/leaf/assets/runtime/anchor-controls.js
#	skills/leaf/assets/runtime/asks/model.js
#	skills/leaf/assets/runtime/floating-panel.js
#	skills/leaf/assets/runtime/reactions.js
#	skills/leaf/assets/runtime/registry.js
#	skills/leaf/assets/runtime/thread/presentation.js
#	skills/leaf/assets/runtime/widget-elements.js
#	skills/leaf/assets/vendor/browser-runtime/application.js
#	skills/leaf/packages/playwright/widgets/lf-trace.js
#	tests/fixtures/packages/work/widgets/lf-test-task.js
Main's offline export sets the thread presentation unavailable, and its
`current` answers null there. This branch's presenter also claims from its
`reading` selection, which ignored `available`, so an offline export painted
the margin before the overlay mounted and failed presentation
(test_linked_images_zoom_and_return_to_the_report[True]). The reading is now
null where the presentation is unavailable.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`applicationPresenter` took a `current` beside `reading`: publications
claimed from `reading`, `present` from `current`. The thread region used it
to answer while its reading stood still at "waiting", and the two disagreed
when main's offline export switched the thread presentation off. A claim
always paints, so `present` now claims `reading(root)` too and the
override is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A timeline the size observer has not measured, such as one in a closed
disclosure, fell back to reading the scroller's clientWidth, so the zoom
command's liveness still forced a layout of the whole corpus page on every
reflection (~8 ms of forced style per comment). The observer's first report
clamps the zoom to the box, as it already did.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The forced-style table counted recalculations per call site and listed them by
count, so a site forcing many small recalcs outranked one forcing a few of the
whole page. Each site now reports its milliseconds per run, and the table is
ordered by them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	tests/browser/test_render_startup.py
Unbuilt and untested: the vendored bundle is not regenerated, and the browser
suite has not run against the collected-reads watcher. Paused while the host is
on battery.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/runtime/floating-panel.js
The collected-reads watcher (71269c0) subscribes a paint to every selection it reads,
so how narrowly a reader selects now decides how often its callers repaint. On the
corpus page a card move took Sent from 126 to 280 ms: each of seven lf-atlas-worker
paints (~10 ms) ran on every publication, because `HeldReading.hold` read the phase
from the whole root and `passages.js` derived settlements from every widget's state.

- `collectReads` throws on a read of the whole publication, the one reader that moves
  on every publication; the phase is read through `runtime.statePhase` everywhere it
  was read whole or through a second selection, and `authoredStates` is a selection.
- Settlements are a selection per registry, so they move only when a decision does.
- `readPart` is typed from the publisher's root.
- The ask-walk test waits for the walk's landing scroll before the next walk measures
  from the screen; it failed about one run in three on the base too.

The vendored runtime bundle is rebuilt, which the WIP commit left stale. The bench
against the declared-reading baseline is now at parity (corpus comment 135/205 vs
135/202, move 64/121 vs 67/126, at load 13). notes/browser-reactivity.md records why
an effect could not track paints (the annotation paint wrote the focus signal it read
and re-ran itself without end) and the rule both regressions broke.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…wn publication

Review of the collected-reads watcher found readers that select a broad part and
narrow it afterwards, so a paint calling them repaints for changes they never return,
and one that read the whole root on a paint path, which now throws:

- Answering a question in the floating panel threw: its undo lookup read the whole
  root inside the queues watcher's paint. The undo list, to-dos, receipts and
  revision labels are now runtime getters over their own selections, and undo.js,
  floating-panel.js, annotation-inventory.js and drafts.js read them there.
- `readThreads` selects the thread collection rather than all thread state.
- A watcher whose paint publishes a change to a part it already read now repaints:
  a part's first subscriber call is compared with the value the paint read instead of
  being skipped.

skills/leaf/assets/AGENTS.md states the rule for readers a paint can call.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ey return

Both read every ask and narrowed afterwards, so the banner's approval paint ran again
for a change to any ask, such as a nonblocking reply ask's prompt.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	dev/leaf_dev/bench_latency.py
#	skills/leaf/assets/runtime/annotation-inventory.js
Nothing outside snapshot.ts names SnapshotReading, and the unused-exports test refuses an export no other file reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty and others added 6 commits October 13, 2026 19:52
# Conflicts:
#	skills/leaf/assets/runtime/semantic-state.js
The four document regions (projection, threads, asks, the Questions panel) no
longer list their inputs by hand. `applicationPresenter` collects the parts the
region's `reading` reads and the parts its paint reads before its first
`await`, and claims a presentation inside any publication that moves one. The
Questions panel, the asks and the projection now read only through readers and
say in `reading` only whether they owe a paint; the projection no longer paints
from the whole root. The thread presentation keeps naming phase, thread state
and document in its reading, because its commit reads them again after it waits
for preparation, where collection cannot see.

A region checks its parts from one subscription to the publication, made when
the region is, so it claims at the same point in a publication as before.
Subscribing to each part it read put the claim after the publication's other
subscribers, and a send waiting for the page to be presented went on before the
thread had claimed (test_a_source_replacement_preserves_the_focused_draft_and_its_original_anchor).

A widget a paint mounts connects inside that paint. Its controller's connect and
publish now run outside the collection (`untracked`, snapshot.ts), since what it
draws is its own selection's to follow. Presentation proof compares against the
epoch the application last began, rather than reading the root's epoch, so a
paint that waits on proof subscribes to nothing by waiting.

Region claims and paints on the corpus page's load, comment and card move are
unchanged against main.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A publication a region's paint made after reading a part was checked against
the parts the previous paint read, so a part this paint read first, and moved
itself, left the region showing the value it read while presentation reported
it current. The presenter now rechecks the parts once the paint's synchronous
part returns. Presentation proof reads the root's epoch outside the collection
(`untracked`) rather than keeping its own copy from `begin`, which ran ahead of
the root during `begin`. Every region checks its parts against one shared
selection of the publication.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A reading decides whether a region owes a paint; only the paint may publish. A
reading that published after reading a part would have its stale value claimed
as current, so `applicationPresenter` throws instead, naming the region.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 28f4e8c into main Oct 14, 2026
3 checks passed
@max-sixty
max-sixty deleted the tracked-region-readings branch October 14, 2026 03:34
max-sixty added a commit that referenced this pull request Oct 14, 2026
Finishes cutting the four document regions over to collected reads
(#2815 did the projection, asks and Questions panel): the thread
presentation's `reading` no longer names phase, thread state and
document by hand, and says only whether the region owes a paint.

**Reads after a wait.** Collection sees only what runs synchronously,
and the thread paint reads state again after it waits for a package's
thread reader to prepare. `applicationPresenter`
(`skills/leaf/assets/runtime/semantic-state.js`) now hands a region
paint `resume`, which wraps a continuation (a `.then` callback, or a
function called after an `await`) so what it reads joins the paint's
parts while the paint is current. `renderReading`
(`thread/presentation.js`) resumes its commit, and `renderThreads`
(`thread/thread-list.js`) resumes the rows it derives again once frozen
widgets have connected.

**The margin is its own owner.** The commit refreshes the margin over
the targets it moved; that call now runs outside the collection
(`untracked`). Collected, it had the thread repaint on every widget
action, since the annotation inventory reads the whole projection, and
the margin already has its own watcher.

**Time readings after a wait.** `clocked` (`runtime/presence.js`) keeps
its own record of which paints read the time, and that record also
closed at the paint's first wait. With an asynchronous package thread
reader, the thread list's "Approved just now" never aged. `clocked` now
hands its paint the same kind of `resume`, which the thread presentation
composes with the region's; the approval age moves to "Approved 1m ago"
on the next tick.

**Evidence.** Region claims and paints on the corpus page's load,
comment and card move are unchanged against main (instrumented counts).
`pnpm run check` passes, with new tests in
`tests/runtime/region-presenter.test.mjs` and
`tests/runtime/elapsed-time.test.mjs` that fail without their fixes;
about 350 focused browser tests pass (thread reply, resolve, refusal and
package reader, frozen widgets, approval, queue, startup). Codex
reviewed the change and each fix; it reproduced the stale approval age
in Chromium on main and confirmed it ages with this change.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 14, 2026
First step of the full cutover to one reactive norm, where a paint
follows the parts of the publication it reads (#2815 and #2822 did the
four document regions). This does Leaf's chrome: none of its paints
names its inputs by hand or has a reading pushed at it any more.

**Chrome paints are watchers.** The banner's status, the floating panel,
the version picker, the pages drawer, approval and the `m` key repaint
each paint through one `watchProjection`. The floating panel had two
named watchers plus a hand-written selection of the undo list, asks,
document, active revision and agent; the status had
`renderStatus(state)` pushed by the state feed plus a hand selection of
the queues and agent; the picker and the pages drawer had
`renderVersions(state)` and `renderOthers(state)` pushed by state
application. Their own mechanical inputs (an open menu, a comparison, a
press in flight) call the same watcher's `refresh()`, which now draws
the first paint at once when none has run (`projection-watch.js`).

**The server's reach is in the publication.** How the server answered
the latest read is `reach` on the root (`waiting`, `reached`,
`unreachable`, `refused`, `broken`; `build/browser/application.ts`), set
by adoption, the state feed and a failed startup, and it starts no
semantic epoch. The status reads it with the reading the page adopted,
and `pageStatus` takes it in place of a null or an Error standing for
it.

**Derived where read.** The status, the versions and approval's words
are derived where they are read (`statusReading` and `approvalReading`
in `banner.js`, `versionsReading` in `version.js`) rather than read back
from what the banner and picker last painted, so the floating panel's
paint and the banner toolbar's Versions and latest rows follow their own
inputs; upgrade and a comparison, which are mechanical, still ask it to
paint. The ledger's readings (`entry`, `unpresented`, `releasable`)
select their parts instead of reading the whole publication; a handler
the pages drawer's paint ran synchronously released pending sends and
threw "a collected read took the whole publication".

**Evidence.** `pnpm run check` passes; the state feed's Node test now
asserts the `unreachable` and `broken` reach (and fails with the feed's
`setReach` removed). About 70 focused browser tests pass: banner status
(loading, offline, refused, broken, announcements, publication links),
floating panel (threads, On, approval, notices, status in the field),
version picker and menu, pages drawer, approval, On me counts and the
`m` walk.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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