Skip to content

Delete a message by saving its rewrite with no words - #5057

Merged
max-sixty merged 5 commits into
mainfrom
empty-message-edit
Nov 2, 2026
Merged

max-sixty merged 5 commits into
mainfrom
empty-message-edit

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

  • Editor and composer (thread/message-edit.js, composing/input.js): a rewrite always has something to send; with no words it sends an empty edit. The composer's action may now follow the box, as sends already could, so the control's symbol and name change together. A new delete action and bin icon join icon-paths.js.
  • Drawing (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".
  • Agent: the deletion is a turn like any edit, with was holding the old words. A new $events.handling.edit clause 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 (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.
  • Served state: messages refer to the new leaf:message/<kind> resource, the record as a thread holds it, whose text may be empty.
  • Protocol 38: a Leaf at 37 refuses an edit with empty text and would draw a deleted message as an empty bubble, so 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.

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 with was and the deletion clause.
  • test_model_folds.py: deleting an answer reopens its question.
  • test_layer_contract.py snapshot: deleted message and deleted suggestion cases.
  • composing-input.test.mjs: the rewrite's control turns to Delete and stays live once emptied.

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

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
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
@max-sixty
max-sixty merged commit 5d7e533 into main Nov 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the empty-message-edit branch November 2, 2026 05:46
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_
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