Skip to content

Leave a thread summary standing when the user edits or takes back a message it folds - #6947

Merged
max-sixty merged 2 commits into
mainfrom
agent-writes-stand
Nov 24, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-writes-stand

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

When the user edits or takes back a message under a thread summary, the summary now stays as written, and the agent decides whether it still holds. Before, Leaf's code retired the summary, so the thread unfolded. The agent's own edit already worked this way. events.active_summaries loses its tracking of the user's edits and take-backs, and the summary fork's fence follows without its own change.

The agent learns of the edit through the delivery: the replaced words (was), the thread's summaries in force with the messages each folds (covers), and a new handling clause on the user's edit in a thread that holds a summary, which says the summary shows in the message's place and asks the agent to summarize its range again if the change alters what it reports. threads.md states the same rule for edits from either side. A summary still drops when a message bounding its range is taken back, since its range no longer resolves.

The clause is scored by a new eval case, thread-summary-after-a-rewrite: a summary saying the user picked beta, over the user's rewrite to stable. A session acting an hour in without rereading the references summarized again 0/3 without the clause and 5/5 with it; a session reading cold did 3/3 and 5/5. The typo controls left a still-correct summary standing 10/10.

What to weigh: if an agent misses the clause, the fold shows its earlier account of words the user changed until it rewrites it. Across the 424 page logs on Max's machine, none of the 24 user edits touched a summarized message.

Max asked for this on a Leaf page, on the condition that it simplifies. Code: −21 net in src/leaf/, +12 in the kernel registry for the clause; tests −75 net, of which +59 is a regenerated snapshot; the eval case is +743, almost all frozen deliveries.

Tests: focused model tests for folds, hints, forks, delivery and the layer contract, and the two changed browser tests by node id.

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

…essage it folds

Before, the user's edit of a message under a summary, an undo of that edit, or a
take-back of any message the thread held when the summary was written retired the
summary, so the thread showed the originals again. The agent's own edit already
left its summary standing, with `thread edit` naming the summary. Now every edit
and take-back leaves the summary as written, and the agent judges whether it still
holds. The edit reaches the agent with the words it replaced (`was`), beside the
thread's summaries in force and the messages each folds, and `threads.md` asks the
agent to summarize the range again where the change alters what the summary
reports. A summary still drops when a message bounding its range leaves the
thread, since its range no longer resolves.

`events.active_summaries` loses its tracking of the user's edits and take-backs.
The summary fork's fence keeps working through it, now refusing only a fork whose
summary a later one replaced.

Max asked for this on the judgment-survey-misses Leaf page, on the condition that
it simplifies. Across the 424 page logs on his machine, 80 summaries and 24 user
edits never met, and no user took back a message, so the rule had never fired.

Tests: the fold tests now check that a summary stands through the user's rewrite,
and the test of a reaction's take-back retiring a summary is gone. The hint tests
that used a retired summary to leave a run in full now have the agent keep that run
in full. The fork test of an edit dropping its summary is gone. The browser test of a
root checkpoint retracted under the reader now retracts it with a replacing summary,
and the overlap test no longer ends with a rewrite.
leaf-agent
leaf-agent previously approved these changes Nov 24, 2026
Now that the user's rewrite or deletion of a folded message leaves its summary
standing, the edit's handling says so: where a summary in the thread's
`summaries` lists the message in its `covers`, the thread shows that summary in
the message's place, and the agent summarizes the range again if the change
alters what the summary reports. The clause rides every user edit in a thread
that holds a summary, and the agent reads `covers` to tell whether it applies.
The rewrite clause's "the thread shows only the new" stays true of an unfolded
message.

Without it, only the closing paragraph of threads.md, "Summarize a long
discussion", carried the rule. Scored on a new eval case, a summary saying the
user picked beta over the user's rewrite to stable: a session reading the
delivery cold summarized again in every run, 3 of 3 without the clause and 5 of
5 with it, but a session acting an hour in without rereading the references
summarized again 0 of 3 times without the clause, saying in its reply only that
the summary was out of date, and 5 of 5 with it. The controls, a typo fix the
summary still reports, left the summary standing 10 of 10 with the clause,
cold and mid-session.

The case `thread-summary-after-a-rewrite` holds the primary context, the
mid-session one and both typo controls; its envelopes are frozen deliveries
built through the admission door. The layer contract's table gains a
summarized-thread rewrite, so the new clause reaches a case.
@max-sixty
max-sixty merged commit 481e140 into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-writes-stand branch November 24, 2026 06:05
max-sixty added a commit that referenced this pull request Nov 24, 2026
…t by its source text (#6987)

`test_sample_browser_boundary_contains_focus_scroll_and_parent_access`
has failed on main since #6951 (`fb8b0cc1e7`): it passes at that
commit's parent and fails from it on. #6951 made
`Element.prototype.scrollIntoView` Leaf's wrap around the browser's
method in every Leaf document, a live sample's included, and the test
asserted that the method's source text reads `[native code]`.

What that assertion stood for still holds: a reveal a sample's script
makes itself does what the browser's does. The test now makes that call
and checks what it moves, which is the sample's own page and, through
the sample's frame, the page around it. Leaf's own `scrollIntoView`
leaves the page around the sample still, as the test already checked.
`focus` keeps its source-text check, since nothing wraps it. No runtime
code changes.

To weigh: the new check relies on the browser scrolling the host page
for a reveal made inside a sandboxed frame, as Chromium and Firefox both
do today. `module-scroll-and-motion.md` already says that Leaf's
`scrollIntoView`, unlike the native one, stays inside a live sample.

The session running the package-interface redesign asked for this, after
an agent found six browser tests failing on main. This is the only one
of the six that a pull request of the redesign caused; the others trace
to #6796, #6947 and #6009 and are left alone. Max hasn't read the diff.

Tests: the test by node id in Chromium, also under `--cpu-throttle 8`,
and its body in Firefox with the fixture swapped by hand. It fails when
the wrap drops the browser's call, and when the script's call is swapped
for Leaf's contained one.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 24, 2026
…essage it folds (#6991)

`test_a_summary_folds_its_messages_where_they_stand` has failed on main
in Chromium and WebKit since #6947 (`481e14069`), which made a user's
edit of a message under a thread summary leave the summary standing,
with the agent deciding whether to summarize again. #6947 updated two
other browser tests for that rule but not this one, whose last step
still expected the user's rewrite to retract the checkpoint (`Locator
expected to have count '0'`, actual 1, in [run
45337874948](https://github.com/max-sixty/leaf/actions/runs/45337874948)).

This keeps #6947's intent and changes only the test. The step now checks
what the rewrite still owes a user standing on the summary's toggle: the
new words draw at once, no notice holds them back, the message's frame
keeps its loaded document, and the checkpoint stays. The docstring drops
the retraction. No product code changes.

Both parametrizations fail on main at `a0d859a5b` and pass with this
change.

Refs #6989 — automated triage

Co-authored-by: leaf-agent <[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