Skip to content

Keep a comment on words across lines of a diff on those words, at page protocol 52 - #6581

Merged
max-sixty merged 3 commits into
mainfrom
diff-cross-line-comments
Nov 20, 2026
Merged

max-sixty merged 3 commits into
mainfrom
diff-cross-line-comments

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A comment on words selected across two or more lines of an lf-diff was saved detached, so its thread said "Not found": each line is its own datum, and capture refused any passage that touched two. Now a passage that starts in one of a widget's data and ends in a later one drawn from the same value names both: datum is the last, which lf-diff already seats threads under, and the new from is the first, as GitHub's multi-line comments name start_line and line. The words are found again in a reading that runs from the first datum to the last (runReading), searched by findQuote like any other passage.

Before (main) After

To weigh:

  • The anchor schema gains from, so the page protocol moves from 51 to 52 and saved composer drafts reset.
  • The quote index keeps no copy of a passage across data, so such a thread is placed again when its widget draws, as a datum's revision already is. No bundled widget changes its data's words outside a reported draw.
  • The thread's place names both lines in full:
  • A selection from a line into an lf-diff-note, from prose into a widget, or across widgets is still detached.

Max asked for this from a comment on a Leaf page; Claude and Codex reviewed it. Tests: a browser test drags across two diff lines (fails on main), runtime tests for capture and resolution, and a model test for obligations.

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

…e protocol 52

Selecting words that run across two lines of an `lf-diff` and commenting
on them saved the comment detached, so its thread said "Not found": each
drawn line is a datum, each datum is read alone (#5570), and
`anchorForPassage` captured any selection touching two of them as
`{section, quote, detached: true}`. Max hit it on a page reviewing an
`AGENTS.md` diff, on "reach a reader who has only / that text and the
files it points to…".

A passage that starts in one datum and ends in a later one its widget
drew from the same value (same projection, source and revision) now
names both, as GitHub's multi-line comments name `start_line` and
`line`:

    {section, datum: <last>, from: <first>, quote, prefix?, suffix?}

`datum` is the last, so a widget that seats threads beside its data, as
`lf-diff` does, puts the card under the line the passage ends on with no
widget change, and the agent reads both lines' keys. The rule covers any
widget's data, not only diff lines.

- Capture and resolution read the words from the first datum to the
  last as one passage cell (`runReading` in passages.js) and search them
  with `findQuote`, so a run follows the same quote rules as every other
  passage (overlapping copies, spacing at element edges, code points).
- While a run's first datum isn't drawn, as in a closed file, the thread
  stands on its last datum; once the datum is gone it detaches. Travel
  to an anchor reveals every part it names (`revealAnchor`), so going to
  a run across two closed files opens both.
- Placement keeps no index copy of a run's quote, which stands across
  pieces of the reading, so a run is placed again when its widget draws,
  as a datum's revision already is. No bundled widget changes its data's
  words outside a reported draw.
- `segmentsIn` dropped the words of a part when the range ended at an
  offset of the part's own root; it now includes the end's part as it
  already included the start's.
- `obligations.discussed_by` narrows a run to the records it starts and
  ends in.
- A thread's place names a run "first label – last label".

Any other selection across a datum's edge, such as from a line into an
`lf-diff-note` or from prose into a widget, is still captured detached.

The anchor schema gains `from` (requiring `datum` and `quote`), so
`$events.protocol` moves from 51 to 52 and the composer draft's `since`
to 52; `contract.d.ts` and `protocol-baseline.json` were regenerated by
`pnpm run build:browser`.

Tests:
- `test_a_comment_on_words_across_diff_lines_stays_on_them` drags across
  two diff lines, sends, and checks the logged anchor, the marks on both
  lines' words and the thread under the last line. On main it fails with
  `from` and `datum` missing from the anchor.
- `datum-quotes.test.mjs`: a run captured and found again, and a run
  whose words repeat earlier in its first line found where it was
  selected.
- `test_data_record_feedback_hands_only_its_obligations_to_the_agent`
  now has three cases and a run across the first two, which hands both
  to the agent and leaves the third with the user.
- `tests/runtime/dom.mjs` adds a StaticRange, which happy-dom lacks.

Checked by hand through `leaf-dev probe` in Chromium and Firefox: the
composer opens under the last line, and the sent thread marks the exact
words on both lines. A scratch journey across two collapsed files showed
the thread on its last line after a reload and the exact passage once
`t` travelled to it.
leaf-agent
leaf-agent previously approved these changes Nov 20, 2026
Comment thread tests/runtime/dom.mjs Resolved
@max-sixty
max-sixty merged commit c6675c7 into main Nov 20, 2026
7 checks passed
@max-sixty
max-sixty deleted the diff-cross-line-comments branch November 20, 2026 07:06
max-sixty added a commit that referenced this pull request Nov 20, 2026
Main moved the page protocol to 52 (#6581), so the agent-turns and clerk
records this branch reshapes move their since to 52.
max-sixty added a commit that referenced this pull request Nov 20, 2026
…e protocol 53

#6581 took protocol 52 and #6574 removed the working forks. forks.py takes main's
version, since the working-fork code this branch had edited is gone; events.md keeps
main's pickup row and this branch's receipt row.
max-sixty added a commit that referenced this pull request 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.
max-sixty added a commit that referenced this pull request Nov 20, 2026
…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.
max-sixty added a commit that referenced this pull request Nov 20, 2026
…he words a revision rewrote (#6573)

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