Repository navigation
Delete a message by saving its rewrite with no words - #5057
Merged
Merged
Conversation
Clearing a message's rewrite and pressing Save did nothing: the Save control still drew as live but was aria-disabled, and only a screen reader heard "Nothing to save — the box is empty". The log also refused an edit with empty text, and Leaf had no way to delete a message with words in it. Users typed a placeholder such as "[removed]" over their words instead. An edit whose text is empty now deletes the message. The message keeps its place in the thread, so answers to it still stand, and reads Deleted in Leaf's voice, with what it said in the tooltip. A deleted message offers no rewrite. Before the press, the emptied box reads "Delete message" and its Save turns into a Delete control with a bin icon, so there is no confirmation dialog. The agent hears the deletion as a turn, like any edit, with `was` holding the old words. A new handling clause tells it to treat what the message said as withdrawn. The rewrite clause and the suggestion clause now apply only to an edit that has words, so a deleted suggestion is not applied verbatim. Protocol 38: a Leaf at 37 refuses an edit with empty text and would draw a deleted message as an empty bubble. The page protocol, its baseline and the kernel move together. Rejected: withdrawing the message with `undo`. The log admits that only while nothing answers the message, so a message the agent had already answered could not be deleted.
A user's reply that answered a question asked in words kept the question answered after the user deleted it. An answer now needs words, so deleting the reply puts the question back on the user's On me list. The served state's message schema took each message as its logged record, whose `text` must be non-empty, so a thread holding a deleted message failed it. Messages now refer to `leaf:message/<kind>`: the record as a thread holds it, with its latest edit's words, which may be none.
# Conflicts: # dist/kernel/runtime/bundle-data.js # skills/leaf/references/event-batches.md
# Conflicts: # dist/kernel/kernel.json
# Conflicts: # dist/kernel/kernel.json
leaf-agent
previously approved these changes
Nov 2, 2026
leaf-agent
approved these changes
Nov 2, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 3, 2026
The generated Data structures reference linked nested served-state properties and message records to nonexistent anchors. Resolve a nested pointer to its owning definition and message records to their event-kind entry, preserving the reference label for nested properties. This keeps the schema changes from #4873 and #5057 while restoring navigation. Move the existing schema-entry/link invariant into the product suite so ordinary CI protects the published reference. It failed before the fix with twelve missing targets and passes afterward; all eleven product-page tests pass. Focused Ruff checks pass. An independent review found no issues. Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 3, 2026
A saved rewrite couldn't be taken back. `edit` was never among the kinds the log lets `undo` withdraw, and since a rewrite is the user's newest gesture it also ended `z`'s walk: after any rewrite `z` did nothing at all, silently, even over a resolve made before it. A deletion, the rewrite to no words that #5057 added, was therefore final. `z` now takes back a rewrite, a deletion included, until the agent answers it. Before, after a resolve and then a rewrite, `z` did nothing. Now the first press says "Press again to undo: edited “I do think green is nice”" (opening the thread on the message when it isn't on screen), and the second gives the message those words back. ## The rule A rewrite is a turn, so it follows the rule a reaction already follows: the user takes it back while no answer stands on it. Once the agent answers, it may have acted on the words the rewrite left. In the case an independent review reproduced, the user deleted "Build blue", the agent removed the blue work, and undoing the deletion would have brought the request back without the agent hearing of it. So the door refuses an undo of an answered rewrite (`answered-edit`), and the user says what changes in a new turn. Rejected: delivering that undo as a new turn the agent answers. Leaf would then have to count an undo as a turn wherever it decides whose turn a thread is. ## Changes - **Log** (`events.py`, `event_contracts.py`, kernel registry): `edit` is `undoable`, refused once answered. A rewrite's `base` is checked against the latest edit still in force, so the next rewrite after an undo lands on the restored words. An undone edit counts as a change to its message for summary staleness. The agent's `undo` clause says undoing an `edit` takes that rewrite back. - **Browser**: the restored words show in the press, before the log answers (`foldThreads`, `unedited`). `z` names a rewrite by the words it gives back. A rewrite's place is its message, not its thread's marker, so `z` shows the message before taking the rewrite when it's out of view. - **Protocol 39**: a Leaf at 38 checks `base` against the withdrawn edit, so it would refuse every later rewrite of that message. ## Tests - `test_a_rewrite_lands_only_on_the_words_it_was_written_over`: undoing a rewrite restores the words and the earlier `edited`, the next rewrite lands on the restored revision, and an answered rewrite is refused. - `test_an_emptied_rewrite_keeps_nothing_and_saved_deletes_its_message`: `z` on a deleted message, with the log's answer held back, brings the words back in the press; they stay after a reload. - `thread-workflow.test.mjs`: the browser's fold of an undo over Python's reading of two rewrites matches Python's reading after the undo (new readings in `served_records.py`). - The layer contract snapshot records the new `undo` clause. Each new assertion fails without its fix. > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clearing a message's rewrite and pressing Save did nothing. The Save control still drew as live but was
aria-disabled, and only a screen reader heard "Nothing to save — the box is empty". The log also refused an edit with empty text, and Leaf had no way to delete a message with words in it, so users typed a placeholder such as "[removed]" over their words instead.An edit whose text is empty now deletes the message. The message keeps its place in the thread, so answers to it still stand, and reads Deleted in Leaf's voice, with what it said in the tooltip. A deleted message offers no rewrite. Before the press, the emptied box reads "Delete message ⏎" and its Save control turns into Delete with a bin icon, which stands in for a confirmation dialog.
Changes
thread/message-edit.js,composing/input.js): a rewrite always has something to send; with no words it sends an empty edit. The composer'sactionmay now follow the box, assendsalready could, so the control's symbol and name change together. A newdeleteaction and bin icon joinicon-paths.js.thread/model.js,thread/messages.js):deleted(message)is an edited message with no words and no drawing. Its body reads Deleted, the "edited" mark gives way to it, and a thread opened by a deleted comment with no title is named "Deleted message".washolding the old words. A new$events.handling.editclause tells the agent to treat what the message said as withdrawn. The rewrite and suggestion clauses now apply only to an edit with words, so a deleted suggestion is not applied verbatim.obligations.py): an answer to a question asked in words needs words, so deleting the reply that answered it puts the question back on On me.leaf:message/<kind>resource, the record as a thread holds it, whose text may be empty.Rejected: withdrawing the message with
undo. The log admits that only while nothing answers the message, so a message the agent had already answered could not be deleted.Tests
test_rewrites.py: the emptied-rewrite test now saves too, checking the Delete control, the placeholder, Deleted in place, no Edit control, the empty edit in the log, and the same after a reload.test_interact_product.py: a deletion is admitted, owed an answer and delivered withwasand the deletion clause.test_model_folds.py: deleting an answer reopens its question.test_layer_contract.pysnapshot: deleted message and deleted suggestion cases.composing-input.test.mjs: the rewrite's control turns to Delete and stays live once emptied.