Repository navigation
Let z take back a sent message or reaction, whatever the agent has done with it - #5320
Conversation
Undo depended on how far delivery had got, which the user can't see happen: `z` showed a gesture first if the agent had picked it up, even with the gesture in front of the user, and the door refused to take back a rewrite the agent had answered. The user's position (3 November 2026) is that the page's behavior shouldn't turn on the backend. - `z` shows a gesture first only when its place is out of view. The served undo list no longer carries `picked_up`. This reverses that part of the undo design chosen on 21 October; undo.js records it. - A rewrite is taken back however far the agent has got with it (`answered-edit` is gone). - The refusal guarded a real gap: undoing a deletion the agent had already acted on changed nothing the agent owed, so its `attention` stayed false and the agent never heard. An undo now carries attention whenever the gesture it withdraws did, and its clause tells the agent to undo or redo work it already did on that gesture. This also reaches undoing an answered pick, which had the same gap. Tests: the rewrite test answers both rewrites, so the undo changes nothing owed, and checks it still carries attention (fails without the rule). The in-view `z` test now holds a pickup and takes in one press; the picked-up show-first test and the served `picked_up` test are gone. The applying- candidate test puts the thread away so nothing covers the suggestion, rather than forcing `picked_up` to make `z` show it.
The log refused to withdraw a reaction once anything answered it, or once its thread was resolved, so `z` and the reaction chip did nothing after the agent replied. The refusal protected the fold, not the user: an undo drops its gesture from every reading, so a reply standing on the reaction would have had no parent and a thread opened by it no root. A deleted message has no such problem because its deletion is an edit that keeps it in place. Now a reaction is the user's to take back at any time, as every other gesture of theirs is. A withdrawn message that a message or to-do still in force stands on keeps its place in its thread with no words and no mark, `withdrawn` naming the undo and the token it said, and the browser draws it Deleted, as it draws a message rewritten to no words. It is no turn, so nothing is owed it, and the undo reaches the agent as the reaction did. One nothing stands on still leaves every reading. - events.py: `UndoReading` loses `answered-reaction`, `resolved-reaction` and the thread fold they needed; `standing_withdrawn` finds the withdrawn messages something stands on, which `build_threads` keeps in place and `_parent_error` still lets a reply name. - Browser: `foldThreads` draws the place Deleted in the press, before the log answers; `deleted` reads `withdrawn`. - Served state, delivery and `page state` carry `withdrawn`. - Protocol 40: a Leaf at 39 drops the withdrawn reaction and fails to place the reply that names it. Tests: the door admits the undo of an answered reaction and a later reply in its thread; the model test checks the kept places, that nothing is owed and that `page state` lists no reaction; the runtime parity test folds the undo over Python's reading and matches Python's reading after it; a browser test takes an answered reaction back by `z` and sees Deleted in the press and after a reload. The pinned-containment undo test is deleted, since undo no longer reads thread state.
Two readings went wrong once any reaction could be taken back: - The agent closes a thread by the reaction it acted on (`leaf thread resolve <page> <reaction>`), and taking that reaction back dropped the resolve with it, silently reopening the thread. A reaction taken back from a thread now still names that thread for a resolve or reopen. - A summary in words that reported a reaction kept standing after the reaction was taken back, though rewriting a message in its range retires it. Taking back a reaction on a covered message, made before the summary, now retires it too. The browser's fold also treats a reaction the log has already taken back as gone, so taking back the mark that kept its place removes the thread in the press, as the log's answer does.
A second review found readers that still treated every withdrawn message as gone, each deciding for itself, where a reaction something stands on now keeps its place: - A thread whose opening reaction was taken back refused a new to-do, though it still stood and took replies. `events.unshown` now answers which withdrawn ids no reading shows, and both the parent check and the to-do check ask it. - The browser's fold re-decided a place the log had kept from the messages alone, so any unrelated gesture dropped a thread a to-do held. It now keeps a place the log kept that no message explains. - Held news drew a reaction taken back from another tab as a new Deleted row beside its old chip. It keeps the mark as drawn until the news is let in. - A summary's prose was retired only for a reaction on a covered message; a reaction made within its range on an earlier message retires it too.
…he press A third review found two cases the last fixes still got wrong: - Summary prose was retired by where a taken-back reaction stood among the surviving messages, so taking back the reaction another one was on brought a retired summary back. A summary in words is now retired when the user takes back any reaction its thread held when the summary was written, read from the log rather than from what survives. - The browser inferred a to-do from a place no message explained, so taking back a reaction a to-do also held, or the to-do's own thread opening, dropped the thread in the press. `foldThreads` now takes the threads a to-do is attached to from the served to-dos, as the log's reading does.
# Conflicts: # dist/kernel/kernel.json
…read's history
A comment or reply with words is now the user's to take back as a reaction
is, however far the agent has got with it (the user's decision, 3 November
2026). This reverses the 26 August rule that a message with words is "said
rather than unsaid". `comment` and `reply` are `undoable` in the kernel
registry, so `UndoReading` has no message case left.
- Where something stands on the message, it keeps its place and reads
Deleted, `withdrawn.was` holding the words it was sent with; otherwise it
leaves every reading, and a comment takes its thread with it. It reopens,
names and moves nothing, its rewrites ask for nothing, and an edit of it is
refused (`withdrawn-message`).
- `z` names it ("replied “…”", "commented “…”") and shows it on the message
itself. The press draws the withdrawal before the log answers, and held
news keeps any message taken back elsewhere as it was drawn.
- The editor's empty save stays the way to delete an older message, since
`z` reaches only the newest gesture and can take a deletion back
(message-edit.js records the decision).
Settlement no longer reads which messages a thread still shows. Every turn
said in a thread, and each undo of one, stays in a server-only history
(`turns`), and `settled_through` replays it: an answer to the newest turn
of its batch settles the batch, a turn taken back before the answer leaves
the batch with its rewrites, and one taken back after it leaves the batch
settled. `unanswered_turns` and the failed-answer rule in workflows read
that floor. This also fixes undoing an answered rewrite, or a reaction an
answer stands on, which made the turns before it owed again.
Tests changed with the behavior: the said-message refusals are gone, the
undo walk test ends at an action this document doesn't paint, and the
browser walk test now takes back a sent reply.
# Conflicts: # browser/runtime/framework/application.js # browser/runtime/thread/model.js # browser/runtime/undo.js # browser/types/contract.d.ts # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js # dist/kernel/runtime/bundle-errors.js # dist/kernel/runtime/bundle-page-layout.js # src/leaf/events.py # src/leaf/served_state/state.schema.json # src/leaf/workflows.py # tests/browser/test_render_outbox.py # tests/served_records.py
# Conflicts: # src/leaf/agent_state.py
leaf-agent
left a comment
There was a problem hiding this comment.
Every comment and reply the user has sent now goes into the served undo list. Removing said-message means UndoReading.error refuses no user message, so browser_undo_candidates (src/leaf/served_state/document.py) lists each one with its full record: text, drawing strokes and suggestion. On main a message entered the list only as an unanswered reaction. This costs two things:
- The list ships on the startup path and grows with every message the user writes. AGENTS.md's Working on the repository asks such an addition to say what the user gains.
answerGestureinfloating-panel.jsrunsruntime.undo.find(...)once per answered obligation row. That lookup now grows with the user's message count, so drawing the panel grows with obligations × messages. That is the square-of-the-page walk Responsiveness rules out.
It also changes behavior the description doesn't mention. An obligation the user answered with a reply now finds that reply in the list, so the panel's control can take back an older reply. The description says only z reaches a message, and only while it is the newest gesture. If that is the rule, listing a non-reaction message only at the newest head fixes the cost and the extra reach together. If the panel is meant to reach older replies, the list still needs an index by id rather than a scan per row.
The browser keeps a second copy of the server's rule for what still stands on a message. standingIn and takenBack in browser/runtime/thread/model.js repeat events.standing_withdrawn and message_reading. Whether a message taken back stays as Deleted or leaves depends on the rest of the log, which Responsiveness says the browser shouldn't predict. The two copies already disagree. The served thread appends the agent's streaming reply (stream:<turn>, carrying parent) to msgs (served_state/thread.py). standingIn counts that reply as something standing on the message, but standing_withdrawn reads only logged events. So if the user presses z on their newest reply while the agent streams an answer to it, the tab draws a Deleted placeholder. Then the reading arrives, removes the message, and the stream goes with it.
What the press decides by itself is that the message's words go. A cheaper fold would draw only that and let the server's reading decide whether the place stays. That drops standingIn, the attached set threaded into foldThreads, and the mismatch.
…reaming reply hold no place From the automated review of #5320: - Every message the user had sent went into each view's undo list, so the list grew with the conversation, the panel's answered rows searched it once each, and their Undo could take back an older reply. A message with words is now listed only while it is the user's newest gesture, which is all `z` reaches; an older one is deleted by rewriting it to no words. - The press's fold counted a reply still streaming as something standing on the message it answers, which the log can't, so taking that message back drew Deleted where the server's reading then removed it. `standingIn` skips provisional replies. The candidate test now fetches the whole reading: since #5307 the held request names the tab's reading and gets only the changes, which has no `browser` key, and the test fails the same way on main.
…vents.md From the automated review of #5320. Held news kept a message with words taken back elsewhere as it was drawn only where something stood on it, and dropped it at once otherwise. A message the user took back is their own act and no news, as one the log took back already goes, so both now show at once: held news keeps only a reaction's mark as drawn, as before this PR. events.md's Undo section had lost "browser" from "the browser draws it as Deleted".
# Conflicts: # browser/runtime/kernel-registry.json # browser/runtime/thread/model.js # browser/runtime/undo.js # browser/types/contract.d.ts # src/leaf/events.md # tests/served_records.py
…in removed Main took the protocol to 40 for its own log change (#5331), so this branch's message withdrawals, which a Leaf at main's 40 would refuse or crash on, need 41. The answered-reaction fixture's to-do loses the `owner` field main dropped from to-do records.
leaf-agent
left a comment
There was a problem hiding this comment.
c5c8cb0 fixes the streaming case by adding a second exception to standingIn (!message.provisional), but the browser still keeps its own copy of events.standing_withdrawn. That is the underlying problem the earlier review raised, and Responsiveness in AGENTS.md rules it out: "a prediction is a second copy of the server's rules, and each case it misses shows the wrong state until the reading arrives". The browser's copy reads the served msgs and the attached set, while the server's reads the log. So every message the served thread adds, drops or hides that the log doesn't is another case the copy has to special-case. The stream was the first such case, and this guard won't be the last. Fix the underlying issue asks not to stack patches like this.
The press itself decides only that the message's words go. If the fold draws just that, with the words gone and the message kept in place, and leaves the server's reading to decide whether the place stays, then standingIn, the attached parameter threaded into foldThreads, and this guard all go.
…ys to the log From the automated review of #5320: the press's fold kept its own copy of `events.standing_withdrawn`, reading the served messages and the to-dos where the server reads the log, and each message the served thread holds and the log doesn't (a streaming reply was the first) needed an exception. AGENTS.md, "Responsiveness", rules such a prediction out. The press now draws only what taking a message back decides by itself: its words or mark go. A message with words, or a reaction that opened a thread with words in it, keeps its place as Deleted, and the server's reading takes the place away where nothing stands on it. A mark drawn as a chip, or alone on the page, has no place of its own and comes off. `standingIn` and the `attached` set threaded into `foldThreads` are gone. The cost: taking back a message nothing answered reads Deleted until the server's reading arrives, then goes.
Conflicts, resolved: - Thread to-dos: main took a thread's to-dos and their Done away (#5331), and this branch had moved them into ThreadView. They go from ThreadView, its commands and surfaces.css, with the panel's inset rule for them; the quote stays. - The panel's ✓: main gave its own Resolve button a disc and a tone (#5329); the panel's ✓ is ThreadView's on this branch, which already has them. - floating-panel.css: main renamed the reply's outlet to `.lf-fp-reply-outlet` and dropped the Threads row's mark wash; this branch dropped the panel's quote rules and the reply part's wrapper. Both removals stand. - Tests: main's new held-news test and rewritten `z` reply test stand beside this branch's renamed drawn-commit test and selectors. `test_a_resolve_s_notice_stands_for_that_resolve_alone` expected the notice's Undo to show a gesture the agent had picked up before taking it back, the rule #5320 removed; main never reached that step, since its Resolve went back to Threads there (fixed on this branch). It now expects the press to take the Resolve back.
…rd does (#5390) The margin card drew a thread with `ThreadView`, and the floating panel built its own from three parts the primary reader lent it (the transcript, the held-news notice and the reply box), with its own quote, ✓, to-dos and rewrite wiring around them. The two copies had drifted: the panel's ✓ lacked the card's "Resolved by <agent>" label and its key command. Now both surfaces hand the whole thread to `ThreadView` and say where its parts stand through one contract: the panel stands the notice and ✓ on its head line and the reply box in its field, and the card stands them on its row of presses. `ThreadView` no longer asks which surface it is on. Each surface keeps its own placement, the edge it holds still, its scroller, its navigation and Close. ## What the user sees change, all in the panel - A thread the agent resolved names the agent on ✓ ("✓ Resolved by Codex · Reopen"), and ✓ declares `thread.resolve` and `thread.reopen`, so Enter on it runs the command, as a card's does. - An agent's Resolve that arrives while the user reads the thread waits behind "1 new", as in a card: ✓, the notice and the field's words change together when the user shows the news. Before, ✓ and the field flipped at once beside a notice still saying "1 new". Pressing ✓ while it waits shows the news and sends nothing. - Fixed: Resolve on a thread opened from Threads went back to Threads, where the user chose that it moves on to the next open thread, whenever the thread's record had been replaced since the panel drew it, as after `t` then Enter on ✓ or after the user's own reply. The thread is found by key now; `test_resolve_opens_the_next_thread_as_tall_as_it_holds` gives its threads replies and fails on main. - Fixed, from #5361: the panel's open view counted as covering the thread it shows, so the panel stopped holding news at all. `shownWindow` now takes the node it reads for and leaves out the cover of the surface holding it, as `coverBoxes` already did. On main, `test_held_news_reads_whole_among_the_thread_s_controls`, `test_on_a_phone_held_news_gives_way_before_close` and `test_threads_grow_in_place_and_hold_news_until_asked` fail; here they pass. ## Package API `parts.transcript` and `parts.news` are gone; only the panel used them. `parts.thread` takes optional `{head, reply, quote, landing, drawn}`, documented in `module-annotations.md`, "Owning the primary conversation presentation". Every place a nomination names is checked and slotted as its outlet is, so a place outside the widget refuses the update and a place in its shadow tree takes its part through slots. The primary reader forwards only those options, so the card's own (`CardOutlets`) never reach a package's thread. A package's whole thread with `quote: true` draws the quote as the panel does; its rules moved from the chrome's scope to `surfaces.css`. ## Where to look - `browser/runtime/thread/thread-card.js`: `ThreadOutlets`, `CardOutlets` and `ViewOutlets`; the boxes a thread draws apart; `#settle`, whose landing and reader each container states; `#createReply`, which hands the reply's words `{resolved, attention}` of the thread as drawn; `#drawQuote`. - `browser/runtime/thread/primary-reader.js`: one path for every place a nomination names (`placesOf`), placing each part before drawing it. - `browser/runtime/floating-panel.js`: the panel's outlets and landings; its quote, ✓, to-dos and settlement wiring are deleted. - `browser/runtime/annotation-overlay/thread-preview.js` and `thread/inline.js`: the card's and the seat's outlets. - `browser/runtime/geometry.js`: the cover fix above. ## Size 49 files, +1229 −893. Runtime JS is about +28 lines of code and +116 of comments: `floating-panel.js` −81, `thread-card.js` +227. What this buys is one owner for each part of a thread, not fewer lines. ## Checks - Firefox stills of 45 card, seat and panel states show 0 px change; Chromium's `retained-quote` and `retained-quote-full` are unchanged. An independent review of each commit's code and the held-Resolve captures found nothing left to fix. - `pnpm run check:browser` and `pnpm run test:runtime` pass, as do the focused browser tests for panel threads, held news, Resolve, Reopen, Undo, quotes, seats and package threads. - `test_a_resolve_s_notice_stands_for_that_resolve_alone` now expects the notice's Undo to take back a Resolve the agent picked up at once, the rule #5320 set; main never reaches that step, since it stops at the Resolve bug fixed here. - Inherited, failing on main too: `tests/browser/test_render_outbox.py::test_z_takes_back_the_thread_the_user_just_resolved` (main's push runs, #3985), `tests/journeys/test_render_anchors.py::test_a_data_bound_diff_aims_and_selects_one_source_line` (a comment's anchor now carries `prefix` and `suffix`; it fails at that assertion on main, before the lines this branch changes) and `tests/browser/drafts/test_reply_sessions.py` `[margin-accepted]`. > _This was written by Claude Code on behalf of max-sixty_
…owever far the agent has got (#5418) The kernel registry's `$reactions` description, which agents and package authors read, still told them a reaction can be withdrawn only "while nothing answers it". #5320 removed that limit: the user can take back a sent message or reaction however far the agent has got with it, and `src/leaf/events.md` ("Undo") was rewritten to say so. This brings the registry description into line and points it at that section. The same "Undo" section said a withdrawn message keeps its place where "a message or to-do still in force" stands on it. `events.standing_withdrawn` counts every to-do on the thread the message opened, ended ones included, which is what its docstring and #5320's commit message say it should do (a completed to-do keeps its discussion for the Done list). The prose now reads "a message still in force, or any to-do on the thread it opened". This is prose only, and no behavior changes. `uv run pytest tests/model -k "registry or reaction"` passes (166 tests). Co-authored-by: leaf-agent <[email protected]>
…ages (#5538) Three browser tests have failed on main since #5320 ("Let z take back a sent message or reaction"). #5320 made two changes they didn't account for. The user's newest comment or reply became a gesture `z` takes back, and the menu's Undo row names it by its words. Also, a gesture the agent has picked up no longer makes `z` show it first. All three tests expected the behavior #5320 replaced, so this updates the tests and leaves the code alone. - **`test_z_takes_back_the_thread_the_user_just_resolved`** asserted that `z` was offered nothing before and after the undo. The page's fixture comments are the user's own, so the newest of them is now an undoable gesture. The two offer checks go. The test still checks that `z` writes an `undo` naming the user's resolve and no `unresolve`, and that the agent's resolve stays closed (the open count is 2). - **`test_another_key_or_a_scroll_away_puts_the_shown_gesture_back_to_showing`** wrote a pickup so that, after `j`, a press on the choice in view would show it again. Under #5320 that press takes it, so the pickup and the key steps go, and the test becomes `test_a_scroll_away_puts_the_shown_gesture_back_to_showing`. Another key ending the arm is still covered by `test_a_key_between_ends_what_the_shown_gesture_promised`, where the difference is visible: the newer gesture is taken, not the shown one. - **`test_the_menu_s_search_finds_rows_threads_and_commands`** searched for "window long". The first row found was now `Undo: commented “Is the window long enough?”`, so Enter took the comment back instead of opening the thread, and the Back button read "Back to Threads". The thread is now the agent's, so the search finds the thread row first and Enter opens it. This also clears the teardown's `unchanged write: hidden on div.lf-fp-quick`, which came from that path. - **`test_a_modifier_between_keeps_what_the_shown_gesture_promised`** is new. The scroll test's `Shift` press was the only check that a modifier alone keeps the arm (`KEYS_HELD` in `browser/runtime/undo.js`), and with the choice in view it could no longer show that. The new test uses the setup of `test_a_key_between_ends_what_the_shown_gesture_promised` and presses `Shift` where that test presses `ArrowRight`, so the next `z` takes the shown old resolve and not the newer one. It fails with `Shift` removed from `KEYS_HELD`. All three fail on `479914c4b` (main when this branch was cut) and pass with this change: `uv run pytest --run-main` on the three node ids, plus `test_a_key_between_ends_what_the_shown_gesture_promised`. The new test passes. Closes #5484 — automated triage --------- Co-authored-by: leaf-agent <[email protected]>
Undo no longer depends on whether the agent has seen a gesture or answered it, and it now reaches the messages the user sends (the user's decisions, 3 November 2026).
zworks the same before and after the agent reads a gesture. Before this change, once a delivery had handed a gesture to the agent, the first press only showed it, wherever it stood. Now only whether the user can see the gesture's place decides that.zreaches a message only while it is the user's newest gesture, which is also the only time the served undo list holds one, so no other control can take back an older message. To delete an older message, the user still saves it empty in the editor, andzcan take that deletion back.What taking a message back leaves
withdrawn.washolds the words or mark it was sent with. Otherwise the message leaves every reading, and a comment takes its thread with it.withdrawn-message).build_threadskeeps a server-only history of every turn said in a thread and every undo of one, andevents.settled_throughreplays it. A turn taken back before the answer drops out of the answer's batch, along with its rewrites. One taken back after the answer leaves the batch settled.unanswered_turnsand the failed-answer rule inworkflowsboth read this. It also fixes an older bug: taking back an answered rewrite, or a reaction an answer stands on, used to make the turns before it owed again.$events.protocolgoes to 41, one above main's 40, since a Leaf at 40 would refuse or crash on the new log.Where to look
src/leaf/events.py:UndoReading(comments and replies are nowundoablein the kernel registry, so it has no special case for messages),build_threads,message_reading,settled_through,unanswered_turns.browser/runtime/thread/model.js: on the press, draws only that the message's words or mark go. A message with words keeps its place as Deleted until the server's reading says whether anything stands on it, so one nothing answered reads Deleted for that moment and then goes.browser/runtime/undo.js: names a message ("replied “…”", "commented “…”") and shows it on the message itself.src/leaf/events.md, "Undo": the contract.Testing
ztakes back a sent reply, and an answered reaction, including the Deleted row in the press.test_undo_waits_while_the_candidate_is_applying_then_reads_accepted_truthnow fetches the whole reading. Since Send a click only the records it changed, and read again only what changed #5307, its held request gets only the changes, which have nobrowserkey, and the test fails the same way on main.leaf-dev journey. Nothing yet checks that a real agent undoes its own work when the user takes back a message it acted on.