Skip to content

Keep readings of the page by what they read, recorded as they read it - #6346

Merged
max-sixty merged 4 commits into
mainfrom
on-me-groups-once
Nov 18, 2026
Merged

max-sixty merged 4 commits into
mainfrom
on-me-groups-once

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

On Me's seats and stops, the conversations under each part, the visual-actions plan and each draft's place were cached against keys listed by hand, and the review rounds on #6342 kept finding inputs those keys missed (an id swap, an aria-label, a draft's section). This records the inputs as they are read instead: kept and keptEach in browser/runtime/kept.js are signals-core computeds, so every signal a reading reads is tracked, and the facts outside any signal (the page's reading, the threads' placement, the user's choices, a visual's parts, widgets' layout notices) record themselves through reads and are checked on each read. The four caches convert, and placementVersion leaves anchor placement's API.

To weigh: the page's reading and placement stay pull-checked rather than becoming signals, since a view drawn from them would then draw again at every change the page hears, as on each frame a widget redraws a counter; a moved version makes a fresh reading without notifying the old one's views. Two readers of attributes the page's watcher doesn't hear now follow their announcements where they read them: currentDatums reads documentChanged, and claimsVisualGesture reads documentChanged and the new layoutsChanged. That replaces the visual plan's hand-listed documentChanged, shown document and lf-layout reset, and fixes a draft on a datum missing its source's new revision.

Cost is unchanged: on 400 questions an m press takes 2.5–3.6 ms warm (2.4–3.4 before) and 5.5–6.3 ms after a word changes (5.2–6.5 before); the walk bench matches at 64–512 questions.

The user asked for this as a follow-up to #6342, and Codex reviewed it twice. Tests: pnpm run check:browser, the runtime suite with new kept.test.mjs and kept-unheard.test.mjs (each new assertion fails with its reader's recording removed), and 72 targeted browser tests (On Me, the walk, tabs, deck, threads, previews, aim, visual actions, draft entries).

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

On Me's seats and stops, the conversations under each part, the visual-actions
plan and each draft's place were cached against keys their authors listed by
hand, and three review rounds on #6342 found inputs those keys missed: an id
swap, an aria-label, a draft's section. Now each is kept by `kept`, or
`keptEach` for one value per key, in kept.js, and neither is told what the
reading reads:

- A kept reading is a signals-core `computed`, so every signal it reads makes
  it again: the application state (`readPart`), `documentChanged`, the drafts
  list, placement's version signal, and a widget module's own signals behind
  `lfWord()`. A view reading it hears them on a cache hit too.
- The facts outside any signal record themselves as they are read, with
  `reads` and a function answering which version stands, and the reading is
  made afresh once one answers otherwise: the page's reading
  (`catchUpReading`, which every reader of the page's words calls, and
  `elementById`, recording `pageReadingVersion`), the threads' placement
  (`placedAt`, `pendingAt`, a count that now moves with the draft's
  placement too), the user's choices (`userChoice`), a visual's parts
  (visual-parts.js, a count per source moved by `update()` and reveals) and
  widgets' layout notices (widget-upgrade.js `layoutsChanged`, which
  reading-place.js now reads in place of its own listener).

The page's reading and placement stay outside signals because a view drawn
from them would then draw again at every change the page heard, as on each
frame a widget redraws a counter. A moved version makes a new computed rather
than notifying the old one's views, so views still draw the page's changes
when the page is presented.

What a reading reads that the page's watcher doesn't hear now follows its
announcement where it is read: a datum's source, identity and revision
(anchor-resolution.js `currentDatums` reads `documentChanged`, which
`datumLabel` no longer needs to), and whether a picture's holder is a press
(`claimsVisualGesture` reads `documentChanged` and `layoutsChanged`). So the
visual plan no longer keys on `documentChanged` and the shown document or
resets on every `lf-layout`, and a draft on a datum follows a new revision of
its source, which the hand-keyed version missed.

`placementVersion` leaves anchor placement's API, since queue-walk no longer
names it. On Me's seats are made per item on first ask, as before. On a page of
400 questions an `m` press takes 2.5-3.6 ms of handler time warm (2.4-3.4
before) and 5.5-6.3 ms after a word changes (5.2-6.5 before); the walk bench
is unchanged at 64-512 questions.
leaf-agent
leaf-agent previously approved these changes Nov 18, 2026
`kept` had its own copy of what `keptEach` does for each key: a computed
recording its inputs, a generation an enclosing reading checks, and a
make that throws keeping nothing. It is now `keptEach` asked for one key.
`keptEach` gains the one thing `kept` did that it lacked: a key whose
make threw moves the generation, so a reading around it that caught the
throw is made again once it answers. kept.test.mjs checks that case,
which fails without the line.

`revealRegisteredVisualPart` counted a reveal as a redraw of the visual's
parts. A reveal that draws already calls the registration's `update()`,
as `registerVisualParts` asks of any rendering change and as lf-timeline
and lf-trace do, and `update()` moves the same count. The second count
is gone.

The kept.js header names `keptReadings` as the reader with given inputs,
and merges its paragraph on what a read costs into the one on `reads`,
dropping the list of `reads` callers the code already holds.

No behavior changes. Runtime suite 1022/1022; browser selections for
visual parts, their reveal and On Me pass.
leaf-agent
leaf-agent previously approved these changes Nov 18, 2026
@max-sixty
max-sixty merged commit 6353579 into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the on-me-groups-once branch November 18, 2026 18:40
max-sixty added a commit that referenced this pull request Nov 19, 2026
…n changes its block (#6527)

A comment's note (the "1 comment" control a block names as its details)
followed a block the page redrew or moved its words out of, or a block a
revision patched, only on the next thread pass, and nothing asked for
one; an unrelated later pass, such as the thread turning "Still queued"
after two minutes, moved it. So
`test_notes_of_one_passage_across_two_blocks_each_follow_their_block_redrawn`
took about 122 s of its 120 s wait on each nightly since Nov 16 and
failed the Nov 19 macOS nightly
([run](https://github.com/max-sixty/leaf/actions/runs/44509509454)); the
single-block redraw test took about 47 s, and the revision test about
120 s since #6346.

- The anchor controls keep each thread's seats (the blocks its note or
reaction stands on) from their last render. When placement names threads
it placed again, they work out those threads' seats by the render's own
rule and ask for a pass only where one differs.
- Placement settles after a script that replaces an element a section
anchor names.
- The controls' render reads the shown document again, a read #6346
dropped from the pass.

**To weigh:**
- A script that redraws a commented block asks for a whole thread pass
each time, as a widget's `lf-layout` does. At 303 threads, replacing one
commented block every frame took the median frame gap from 33 to 50 ms;
main is faster only because it leaves the note on the removed block.
Words rewritten inside a block ask for none.
- Left open, by reading: a script that redraws an uncommented picture
leaves its "Responses to …" group shelved on the removed picture, since
no thread moves.

Four tests now read the notes once after `rendered`, among them a new
one for words moved into another block while their block stays. Each
fails on main's runtime, and each fails when its own piece of the fix is
removed. Also ran the comment-mark and reaction modules, `test:runtime`
and `check:browser`.

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