Skip to content

Type in a settled thread's reply without a thread pass per key - #3893

Merged
max-sixty merged 11 commits into
mainfrom
grind/f-thread-dom-contract
Oct 27, 2026
Merged

max-sixty merged 11 commits into
mainfrom
grind/f-thread-dom-contract

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Follows #3864 (landed) and closes its two follow-ups.

A settled thread's reply no longer claims a thread pass per keystroke

Each keystroke in the reply box of a resolved thread scheduled a frame that repainted the card and then claimed a whole thread pass (reply.changed, which is application.js's refreshThread). That pass was there for two things a settled thread's box decides outside its own card: whether its seat keeps it among the open threads, and whether the margin keeps its entry. Both read replyIsEditing. #3864's sessions signal makes that a followed reading, and a session opens on focus and closes on dismissal, never on a keystroke. So the pass changed nothing. The card still repaints itself. reply.changed had no other caller, so it is removed too.

Measured with a temporary performance.mark at the start of each thread pass (renderReading), typing 11 characters 60 ms apart into a margin card's reply after the agent resolved the thread:

thread passes
before 11
after 0

The same journey on a page seat's resolved card ran 0 passes both before and after.

Obligations in late-mounted seats: the premise didn't hold

The follow-up said obligations/view.js takes after: PRESENTATION_DOM.thread, which resolves before the seats commit, and never repaints when they land. The first half is true. The second is not. An obligation's control is a widget, and a widget the seat commit mounts calls widgetMounted, which presents the whole document (invalidateDom). That claims the obligations region again, along with the thread region, and ticks documentChanged, which On me's cards read.

I traced it with temporary marks and a test x-thread-surface whose threadOutlets waits 300 ms. The thread is on its datum and an agent reply carries an lf-ask. The surface first returned no outlets, then returned outlets with the delay:

thread-pass@5:none  obligations-paint@6:none  location-frame@9:none
seats-commit@308:node  mounted-first-job@312:node
thread-pass@316:node  obligations-paint@316:node  location-frame@328:node

On me was open throughout. Its card had no answer buttons while the control stood nowhere, and showed "Put the mounts back / Install the camera" after the commit, without being reopened. With no delay the order was the same. So no code change is needed here. The comment on PRESENTATION_DOM now says how obligations find such a control (widgetMounted). It had previously named only the margin's readings.

The committed kernel is rebuilt as build/AGENTS.md requires.

Checks

  • pnpm run test:runtime: 675 passed after merging current main.
  • Browser: tests/browser/drafts/test_reply_sessions.py, threads/test_resolving.py, threads/test_summaries.py, threads/test_seated_threads.py, startup/test_thread_surfaces.py and drafts/test_revisions.py::test_live_executable_replacement_keeps_a_resolved_reply_session (102 passed). Also navigation/test_obligation_walk.py, both test_on_panel.py files and widgets/test_obligations.py with -k "thread or seat or reply or frozen or resolv or on_me or walk" (43 passed), and margin/test_entries.py, test_card_placement.py and test_opening_threads.py with -k "resolv or settl or reply or draft" (3 passed).

No test asserts the pass count. That would need a counting hook the harness doesn't have. The behavior the claim used to serve is covered by the resolved-reply session tests: the box stays while its session stands, and the margin entry goes once the session is dismissed.

Not verified: Firefox, and the leaf-dev profile timing. The count above comes from a scratch browser test with marks that were removed before committing.

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

max-sixty and others added 10 commits October 24, 2026 20:43
The margin's annotations drew twice per thread pass: once from their own
presenter, which waits only for the projection's chrome, and again when the
thread pass committed (`untracked(renderAnnotations)`). A comment gesture runs
two passes, so the margin drew four times; now two.

The thread pass paints no other owner's region. What it decides about a
thread reaches the margin as readings its paint follows: where the thread is
placed (`placedAt`, already followed), and now whether a widget seats or
holds it (`claimed`, `heldOut`, an `ownership` signal in thread/surfaces.js
that moves only when the claimed set or a hold's keys change) and whether its
reply is being edited (`replyIsEditing`, a `sessions` signal in
thread/replies.js that moves when a session opens or closes). A commit that
moves one has the margin's presenter claim again inside the same pass; one
that moves none leaves the margin drawn once. Reply continuity, whose route
may be a margin card, starts once `whenDocumentPresented()` settles, still in
the task that committed.

Measured with `leaf-dev profile triage-board comment` and a temporary mark in
`renderAnnotations`: margin paints between the keydown and Sent went from
4, 4, 4 to 2, 2, 2 over three runs; `renderAnnotations` (8.7 ms inclusive per
run) left the top-12 JS list.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
`anchorPlacement.read` bumped its version with `version.value += 1`, which
reads the signal before writing it. The read runs inside the thread pass's
tracked stretch (`readTargets`), so the pass subscribed to its own write and
`applicationPresenter` claimed the thread region again: every pass whose
placements changed ran twice.

`tick` in the new version-signal.js writes without reading, as
page-controls.js's `tell` did by hand, and is the one home for advancing a
version signal.

Measured with `leaf-dev profile triage-board comment` and a temporary mark at
the start of each thread pass: passes between the keydown and Sent went from
4, 4, 4 on main (each of the two publications started its pass twice, 1 ms
apart) to 2, 2, 2.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
`x.value += 1` reads a signal before writing it; run inside a paint, as an
owner's commit is, it subscribes that paint to its own write and the region
claims another pass. The `ownership` and `sessions` bumps this branch added in
thread/surfaces.js and thread/replies.js had that form, as did five sites on
main that happen to run outside paints. All of them now call `tick`, and
`no-restricted-syntax` in the private runtime's eslint block refuses `.value +=`
so the form can't come back. The exact closures in .dependency-cruiser.mjs
admit version-signal.js, which imports nothing.

`tests/runtime/region-presenter.test.mjs` pins the difference with the real
presenter: a paint that ticks a version paints once; one that reads the
version first paints twice.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Continuity waited on `whenDocumentPresented()`, the whole pass, which also
holds every widget's asynchronous preparation and any ticket a widget keeps
open through a drag. A displaced reply editor would then wait on an unrelated
widget before focus returned, and keys typed meanwhile would land on the page.

It now waits on the margin's own DOM commit, `PRESENTATION_DOM.annotations`,
the DOM its route may land in. The margin's claim for what the commit moved
lands when the commit's stretch ends its batch, so the commit is read a
microtask later; a margin owing no repaint has already committed, and
continuity runs in the task that committed the seats.

`tests/runtime/region-presenter.test.mjs` holds a widget's commit open through
a pass and shows the margin's commit settling while the pass does not.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Each keystroke in the reply box of a resolved thread scheduled a frame that
repainted the card and then claimed a whole thread pass
(`reply.changed`, application.js's `refreshThread`). The pass existed for
what a settled thread's box decides beyond its card: whether its seat keeps
it among the open threads and whether the margin keeps its entry. Both read
`replyIsEditing`, which #3864's `sessions` signal now makes a followed
reading, and a session opens on focus and closes on dismissal, never on a
keystroke. So the pass changed nothing; the card's own repaint stays.
`reply.changed` had no other caller and goes with it.

Measured with a temporary `performance.mark` at the start of each thread pass
(`renderReading`), typing 11 characters 60 ms apart into a margin card's reply
after the agent resolved its thread: 11 passes before, 0 after. A page seat's
resolved card ran 0 passes on both.

The comment on `PRESENTATION_DOM` now says how obligations locate a control a
seat mounts after the thread pass's DOM commit: the control is a widget, and
its connection presents the whole document (`widgetMounted`). Traced with a
test thread surface whose `threadOutlets` waits 300 ms: the obligations paint
and a location frame ran before the commit with no node; the commit mounted
the lf-ask, which started another thread and obligations pass, and the next
frame and On me's card found it. No code change was needed there.

The committed kernel is rebuilt, which also brings in this branch base's
runtime changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Takes main's TODO.md, whose backlog moved to GitHub issues in #4090.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`renderSurfaces`' commit runs inside the thread pass's paint, and filtered
a page registration's threads with `heldOut`, the followed reading. When
the same commit then changed the claimed set, its `tick(ownership)`
reached a signal the pass had just read, so the pass claimed a second
one: the self-subscription the branch's `holdsOut` split exists to
prevent, missed at this one site. The commit now reads `holdsOut`, as
preparation does. Only a page registration (`placePageThreads`, which no
bundled package uses) reaches that read, so bundled pages never took the
extra pass.

`tests/runtime/thread-surfaces.test.mjs` runs the first commit inside an
effect, as the pass's resumed stretch does: it ran twice before the
change and once after.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main moved the signals import to /runtime/framework.js and folded event-kinds
and passage-facts into kernel-facts.js; the PR's new version-signal imports and
closures follow it. Kernel rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@max-sixty
max-sixty marked this pull request as ready for review October 27, 2026 05:28
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026

@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.

The two margin cases selected from test_reply_sessions.py report the same metadata-action size change (92×28 → 139×30) on this head, its base 644925d3dbd78606cf5f47bdda5f19e2b4cc7797, and current main b0130cdd0. This is inherited and tracked in #4341; it does not withhold approval under the repository's test policy.

Base automatically changed from grind/g-margin-once to main October 27, 2026 06:54
@max-sixty
max-sixty dismissed leaf-agent’s stale review October 27, 2026 06:54

The base branch was changed.

#3864 landed as 95d241a; its commits resolve against the squashed copy, with
regionCommitted kept. Kernel rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@max-sixty
max-sixty merged commit 3412f7e into main Oct 27, 2026
4 checks passed
@max-sixty
max-sixty deleted the grind/f-thread-dom-contract branch October 27, 2026 07:13
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