Skip to content

Keep a comment on the item its words stand in, and show and deliver the words a revision rewrote - #6573

Merged
max-sixty merged 12 commits into
mainfrom
thread-card-lost-passage
Nov 20, 2026
Merged

max-sixty merged 12 commits into
mainfrom
thread-card-lost-passage

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

A comment on an open item (number 54) on a working page lost what it was about once a revision reworded that item: the margin card showed only "sure, check this out", bracketed against the whole Open items list, and the agent's delivery for a reply there carried no old words either. Three fixes.

The comment named the list, not the item. The browser took a passage's section from the selection range's common ancestor. A Chromium triple-click on a list item, or a drag past an item's last word in either engine, ends the range at the next item's start, so the comment named open-items-list though <li id="item-54"> held every quoted word. When the rewrite removed the words, the reanchor fell back to the list. anchorForPassage now takes the holder from the first and last word-bearing segments, the innermost id around the quoted words, as file-side capture (anchor_capture.py) already does. Measured with leaf-dev probe: Chromium triple-click on an item gave open-items-list before and item-54 after; on a paragraph whose parent has no id, no section before and the paragraph's id after.

A margin card never drew the quote. Only the floating panel's view asked for it. Every thread view now quotes its words wherever the page leaves them unmarked (a status such as Changed, or words that only fell back to a place around them), and a margin card gives the quote a row at its top, above its actions. Where three lines cut the quote, its label ("Changed", and in the panel the place the words stood) is now the press that opens it whole, its disclosure arrow standing on the quote's rule; the separate Full quote line under the label is gone, after Max read the two as two labels, the second set in from the quote's edge. The press's accessible name and preview say "Full quote".

The agent got no old words. Each delivered thread digest now carries rewritten_from beside detached_from, and leaf page state prints it too. The delivery record moves to leaf-delivery/52; main already moved the page protocol to 52 (#6581), so this adds no bump. Eval fixtures and the fork journey capture carry the new format and a null field.

Worth weighing: the quote sits above the card's actions, so ✓ and × move down on a card that shows one; the alternative under the actions put the quote in the transcript, where every rule for the actions' line reads the first message. Merging main renamed this branch's first/last in anchorForPassage to firstText/lastText, since #6581 declares its own pair in the same scope.

Max asked how he'd know what the comment referenced, and picked changing the delivery format now; Codex reviewed the first two fixes. Tests: three new tests (a browser test each for the section and the card quote, which fail on main, and a delivery test that fails without the digest field), the runtime suite, check:browser, the focused browser tests on quotes, cards and selections, and the delivery, layer-contract, thread-reading and eval fixture tests.

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

…n card

A margin card never drew the words its thread quotes: its bracket marks
them on the page. Once a revision rewrites those words, activation moves
the thread to their surviving section (`reanchor`), the bracket spans the
whole section, and the card no longer shows what the comment was about.
Only the floating panel's view, behind Open in panel, still quoted them.

Every thread view now draws its quote wherever the page no longer reads
as the quote does (`quoteReading`'s status: Changed, Earlier data, Not
found, Not in the latest version), and also wherever its container asks,
as the panel does. A margin card gives the quote a row at its top, above
its actions, holding still while the messages scroll; its label names
only the status, since the bracket shows where. The card's accessible
name reads the rewritten words too (`threadPassage`).

`leaf page state` now carries each thread's `rewritten_from`, beside
`detached_from`, so a later session can read what a reanchored thread was
about without the log. The delivery's thread digest still lacks it: its
record is at `since` 51, the current protocol, so adding it needs a bump.

Behavior changes in tests: page state's thread lists gain the key; a new
browser test and a stills state (`rewritten-quote-card`) cover the card.
…d bound an opened quote in a card

Review of the first commit found two gaps. A quote opened whole with
Full quote grew the card's top row without bound, pushing its actions and
reply out of the card; the quote's row now shares the card's room with the
messages' row and scrolls inside its share. And visibility keyed on the
status label missed words that only fell back to a place around them, as
an unloaded diff line falls back to its file: `quoteReading` now says
`unmarked` for a status or for words without an exact placement, and every
container that didn't ask for the quote draws it then.

A quote that appears while the user reads a seat or a package's thread,
because a revision rewrote its words at that moment, moves the messages
below it without being held as news; that path is rare and takes in at a
glance, so it carries no hold of its own.
…ion's range

A comment's `section` was the nearest addressable element around the
range's common ancestor. A Chromium triple-click on a list item, or a
drag past an item's last word in either engine, ends the range at the
next item's start, so the common ancestor is the list: the comment on
open item #54 on the fork-messages page named `open-items-list` though
`<li id="item-54">` held all its words. When revision 59 reworded #54,
the reanchor fell back to that section, the whole list, though item-54
still stood. A triple-click on a paragraph whose parent has no id named no
section at all.

The capture now takes the holder from the first and last segments that
carry words, the same trimmed span the quote is read from, so the
section is the smallest addressable element holding the words, and a
rewording leaves the thread on the item that still stands.

Measured with `leaf-dev probe` on a list of id'd items and two id'd
paragraphs: before, Chromium triple-click gave `open-items-list` for an
item and null for a paragraph, and a drag into the next item gave
`open-items-list` in both engines; after, all give the element's own id.
leaf-agent
leaf-agent previously approved these changes Nov 20, 2026
…age, which main's datum first and last now share a scope with

Merging main's #6581 into thread-card-lost-passage leaves two `const first`
and two `const last` in `anchorForPassage`: the branch's text nodes that
find the passage's holder, and main's data that a run across lines names.
The module then fails to load. The branch's pair becomes `firstText` and
`lastText`; main's stays as it landed.
…tten_from` in each delivered thread digest

When a revision rewrites the words a thread quotes, activation moves the
thread onto their section with a `reanchor`, and `build_threads` keeps
the anchor it moved off as `rewritten_from`. `leaf page state` prints
that on each thread, but a delivery's thread digest carried only
`detached_from`, so an agent answering the user's next message in such a
thread saw an anchor naming only a section, and had to dig through the
page's history to learn what the thread was about. Each digest in a
batch's `threads` now carries `rewritten_from` beside `detached_from`,
null where no revision moved the thread, and its `quote` holds the old
words. `references/event-batches.md` says what the two fields hold.

The delivery record's format moves from `leaf-delivery/51` to
`leaf-delivery/52`. The page protocol was already 52, from #6581, so it
stays there: `layer-registry.md`, "Page protocol", has a record whose
`since` names an earlier number take the current one without a bump. A
delivery an earlier Leaf wrote at 51 reads as absent. The eval fixtures
and How it works' journey values now read as a delivery written today
would: `leaf-delivery/52`, and `"rewritten_from": null` on each digest.

Tests: a new delivery test rewrites the words a user's comment quotes,
delivers their reply, and finds the old quote under `rewritten_from`, the
same anchor `page state` shows; it fails without the digest field. Five
snapshots change only in the format and the new null field.
…l quote line

Where three lines cut a quote of words the page no longer shows, the label
over it ("Changed", and in the panel the place the words stood) is now the
press that opens the whole quote, in the label's quiet face with the
disclosure arrow standing before it on the quote's rule. The Full quote press
on its own line under the label is gone. The user read the two lines as two
labels, the second set in from the quote's edge ("we have both `changed` and
this misindented `> Full quote`"). The label's words keep the quote's edge
whether or not it takes a press, so the press arriving after the quote is
measured moves nothing.

Tests that pressed "Full quote" by name press the label's button.
The label's words say the quote's state ("Changed"), not what pressing it
does, so its accessible name adds "Full quote" after them, and its preview
says "Full quote" while the quote is shut and "Fold the quote" while it is
open, as a promise's word names where it opens. A first look at the new
head found nothing on it saying the label takes a press but its arrow.
# Conflicts:
#	dev/leaf_dev/fork-journey.json
#	evals/workflows/fork_eval.yaml
@max-sixty max-sixty changed the title Keep a comment on the item its words stand in, and quote words a revision rewrote at the top of its card Keep a comment on the item its words stand in, and show and deliver the words a revision rewrote Nov 20, 2026
@max-sixty
max-sixty merged commit 27e3eec into main Nov 20, 2026
6 checks passed
@max-sixty
max-sixty deleted the thread-card-lost-passage branch November 20, 2026 18:00
max-sixty added a commit that referenced this pull request Nov 20, 2026
… the thread state

test_an_agent_reply_can_remove_a_subject_and_detach_its_open_thread compared the
whole thread record, and #6573 added rewritten_from to it without updating this
expectation, so the test failed on main as on this branch.
max-sixty pushed a commit that referenced this pull request Nov 20, 2026
…livery 52 in the fork eval (#6621)

Both failures in `ci` run
[44799579467](https://github.com/max-sixty/leaf/actions/runs/44799579467)
on main come from #6573. The tests were left behind by that change. The
product behavior is fine.

- **Eleven browser tests in `test_render_anchors.py` and
`test_render_aim.py`.** #6573 gave the margin card its own thread quote
("Every thread view now quotes its words"), so an open thread now draws
`.lf-thread-quote-head` / `.lf-quote-label` in both the panel and the
card. These tests read the panel's quote with page-wide locators, and
Playwright's strict mode refuses the two matches. The `thread_head`
helper and the flowchart test now read inside the open panel view
(`PANEL_THREAD`), which is the view the helper's docstring already
names. Each test asserts what it did before.
- **`test_every_delivery_an_eval_pastes_is_the_envelope_leaf_writes`.**
#6573 moved deliveries to `leaf-delivery/52` with a `rewritten_from`
field on each thread digest and updated two of the three envelopes in
`evals/beside-work-goes-to-a-fork`. The `next-turn` variant came from
#6593, which merged first, and it kept `/51` (`'leaf-delivery/51' ==
'leaf-delivery/52'`). It now carries the format and the null field Leaf
writes.

Verification: all 12 tests fail on current main (`origin/main` at
da4e538) and pass on this branch, run locally with Chrome. `rg
'page.locator\(".lf-(thread-quote-head|quote-label|thread-quote)"'` over
`tests/` and `dev/` finds one other unscoped read, at
`test_render_aim.py:2195`. It passed in the failing run, because design
mode retires the margin card there.

Refs #6620 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 20, 2026
…de it (#6616)

A Claude Code thread message now reaches the main session at once,
delivered and nudged as any input is, as in Codex and Pi. The line fork
runs beside the delivery and posts the agent's working line when it
answers. Until now Leaf held the message from the session while the line
fork wrote, for up to 30 s.

Max chose this on 20 Nov 2026. The hold came with #6156, when the line
fork also judged whether a working fork should take the message, and the
session had to wait for that judgment. #6574 removed the judgment, which
left the hold buying only that the line went in before the session's own
words. This reverses the decision `forks.py`'s header recorded, and
deletes the hold and everything that existed only for it.

## What holds now

- **Which messages get a line fork.** The pages follower lists one for
each *round*: an open thread whose waiting messages have nothing of the
agent's after the oldest of them, read as the round stood when its
newest message arrived. A message that joins a round before its line
gets a line fork about all of them. One that joins after the agent spoke
in the thread gets none. The follower lists only rounds newer than its
first look at a page, and the module runs each id once, so a round gets
at most one line fork, across a module reload too.
- **When the line goes in.** Only while its round still awaits it: the
thread's waiting messages are the ones the line fork read, and the agent
has said nothing there since, by a message or a rewrite. Leaf checks
this under the lock the append takes (`thread.Receipt`'s `fence`), so a
line never lands after the session's words, nor speaks for a round a
later message joined. A line that fails the check is recorded as
`dropped`.
- **On it.** Waiting messages read On it once the line stands, until the
session answers, as before. Before the line lands they read as their
delivery does: Queued, then Delivered.
- **The summary fork** still runs beside each listed round, even where
the agent spoke first. A delivery leaves the summary hint to it by the
same reading.

## Deleted

`holding.py`, line turns (`state.AGENT_TURNS` and its helpers), the
`held` pickup phase, `activity.STARTING_GRACE` and the lapse, #6592's
lapse nudge, admission's keep-back, the hand-over, the follow-up that
replaced a line turn, delivery's branch for input a line turn kept past
the cursor, `fork-holds-thread`, and `leaf page state`'s `holder`.
Production code nets −1,079 lines, tests −874, `leaf-dev` −119.

## To weigh

- The page protocol moves to 53, because the pickup's phases lose
`held`.
- For the second or two before the line lands, a message reads Queued or
Delivered rather than On it.
- A message the user sends before the pages follower first reads the
page gets no line. As before, the session gets it anyway.
- Whether a delivery carries the summary hint now turns on whether the
follower holds the session's lane when the delivery is built
(`forks.lane_up`), rather than on a record in the log.
- `leaf-dev eval run 'line-fork*' --base` can't compare across this
change, since its scripts call the new `forks.look` under the base arm's
Leaf too.

How it works' Forks tab describes the new flow, and its "Anatomy of a
fork journey" is re-recorded from the journey run on this branch.

Also fixes two tests #6573 left failing on main: the third delivery that
`evals/beside-work-goes-to-a-fork` pastes moves to `leaf-delivery/52`,
and
`test_an_agent_reply_can_remove_a_subject_and_detach_its_open_thread`
expects the thread's new `rewritten_from`.

Tests: model and process suites for the touched modules pass. New tests
cover delivery at once, a joining message, the agent speaking first
(answer, message, progress, rewrite), the race under the lock, a
repeated step, and the summary fork's ownership. Each new guarantee has
a test that fails without its fix. `pnpm run check` passes. `leaf-dev
journey run claude-code` passed all 14 steps on the final code. The line
was in the thread 1.6–2.0 s after each message (the line fork itself
took 1.3–2.0 s), and an idle session's prompt took a message 0.2–0.4 s
after it was sent. Before this change it waited for the line. Codex
reviewed the change and then its fixes. It found three gaps, each fixed
with a test that fails without the fix: a rewrite of the agent's own
answer didn't stop a late line, the agent's progress could leave a long
thread's summary with no owner, and a second rewrite could list a round
again.

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