Skip to content

Keep refused words reachable and refuse what depends on a refused gesture - #2495

Merged
max-sixty merged 8 commits into
mainfrom
refused-events
Oct 12, 2026
Merged

max-sixty merged 8 commits into
mainfrom
refused-events

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A refused send could lose the user's words, or leave gestures stuck behind it. This makes a refusal give every word back somewhere the user can reach, say where, and take down exactly the gestures that depended on what was refused.

What a refusal now does with the words

  • An anchored comment refused while the user has done nothing since Send reopens its composer on its passage, with the words and focus, as the page comment card already did. Before, the thread the send drew was withdrawn, focus was handed to the banner, and the comment read as lost (seen on a real page whose comment was refused).
  • Words returned to a box out of view (the composer after the user moved on, the page comment card that closed with the send) make the notice read "Couldn't send — . Draft kept — g i resumes writing", and become the Resume writing destination so g i reaches them. Words back in a box on screen get no extra sentence.
  • A reply written under a refused comment's pending thread, sent behind it or still unsent, is kept as part of the comment's own draft record (held in drafts.js). The notice adds "Reply kept — it returns when its comment sends". Every edit of the comment keeps it, transferDraft carries it when the draft moves (Alt-click to another passage), and the comment's next send, edited or not, puts it in the reply box of the thread it opens. Before, it stayed keyed to the refused attempt and was unreachable.
  • The notice is composed by delivery after every refused gesture's own answer handlers have run. It is a reaction on the same answer promises, registered after the senders' handlers, rather than a microtask that happened to run later.

Which gestures a refusal takes down

pending/model.js now declares once the fields through which a command names another event (NAMING_FIELDS: parent, message, base, undoes). Two consumers read it:

  • applicationState.refuse drops every pending gesture that names a refused one in any of those fields, transitively. Before, it listed undoTarget and parent by hand and missed an edit's base. A second rewrite saved over a first one still sending was never refused and never sent when the first was refused: it stayed on the message as unsent words, and the delivery queue stalled behind it.
  • nameEvents replaces nameParent and nameUndo, renaming every naming field from a pending id to the admitted id before a send. It keeps namedParent for a reply's thread, and still drops an undo whose target the log never took.

Not changed: #2476 had already fixed the original "served page refuses events after an on-disk runtime change" report, so this branch does not touch admission.

Known edges left:

  • One reply box holds one draft generation. A reply sent and then a second typed in the same pending thread keeps only the second if the comment is refused.
  • The link from a first message's attempt to its draft (openedFrom) is in memory only, so a reload while the comment is in flight loses it.
  • Discarding a refused comment's draft discards the reply it holds.

Tests: new and tightened cases in tests/test_render_drafts.py and tests/test_render_threads.py, each shown failing on the commit before its fix. Focused runs over the refusal, undo, rewrite, reply, resume and carry selections pass on the merged tree (99), as does pnpm run test:browser.

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

max-sixty and others added 8 commits October 11, 2026 21:20
…ing since

A refused anchored comment kept its words only in the passage's draft store. The
thread the send drew was withdrawn, focus was handed on to the banner, and the one
sign left was a transient "Couldn't send" notice, so the comment read as lost: on
the floating-ui-chips page a refused comment could be recovered only by reselecting
that exact passage or knowing `g i`.

Behavior change: when the refusal lands and the user has made no input since Send,
the composer reopens on its passage with the words and focus, as the page comment
card already does for its box. Where focus stands is no reading of intent here,
because withdrawing the landed thread hands focus on (`handBack`); only whether the
user has acted since decides. After a later gesture the words still wait for
Resume writing, as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A refused send whose words went back to a box the user cannot see (the selection
composer after they moved on, the page comment card that closed with the send)
showed only "Couldn't send — <reason>", so the words read as lost.

Behavior change: the refusal notice now ends "Draft kept — g i resumes writing"
whenever the returned words sit in no box on screen, and those words become the
Resume writing destination, as any content change to a draft does, so the address
the notice names always reaches them. Words back in a box in front of the user
(a reopened card or composer) get no such sentence.

Delivery owns the notice and drafts.js owns where the words went
(`keepRefusedWords`, injected by application.js). The notice used to lean on its
afterScript microtask happening to run after the senders' answer reactions. It is
now a reaction on the same answer promise, registered after the senders'
reactions, which run first by registration order, so the reading follows every
restore and reopen by construction.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A refusal takes down more than the gesture delivery was sending: a reply written
into the parent's pending thread is refused with it (`applicationState.refuse`
returns those dependents). The refusal notice only asked about the drained
attempt, so with the parent's words back in a box on screen, the reply's words
went silently into a draft under a withdrawn thread.

The ledger, which owns that set, now returns each dependent's attempt and answer
from `refuse`; `settleRejected` passes them to delivery, which waits on every
refused answer (still after each sender's own reactions, by registration order)
and hands all the attempts to `keepRefusedWords`.

Behavior change: a reply to a message the same refusal withdrew adds "Reply kept
— it returns when its comment sends" to the notice. Its draft keys by that
thread (`reply:<attempt>`), and sending the comment again under the attempt a
refusal keeps brings the thread and the reply's words back. Such a reply is no
longer left as the Resume writing destination, since no box for it exists until
then. Other words returned out of view still get "Draft kept — g i resumes
writing", with the drained gesture's place first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e events

`applicationState.refuse` listed the dependencies it knew by hand, an undo's
target and a reply's parent, and missed a rewrite's `base`. A second rewrite
saved over a first still sending names the first by its pending id; when the log
refused the first, the second was never refused, never sent, and stood on the
message as unsent words with the delivery wait stuck behind it.

Behavior change: `pending/model.js` now declares, once, the fields through which
a command names another event (`parent`, `message`, `base`, `undoes`), and
`refuse` takes down every unresolved gesture naming a refused one in any of
them, transitively, since a third rewrite names only the second. The refused
rewrites' latest words go back to the message's rewrite draft and the message
shows its standing words again. A new event-naming field needs only that list.

The registry's `$events` kinds declare no event-reference fields (`meaning.depends`
names widget identities, not events), so the browser's declaration lives beside
the other readings of what a pending gesture carries.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`nameParent` renamed `parent` and an edit's `base` by hand, and `nameUndo`
renamed `undoes` through the undo's recorded target, so the fields a pending id
can stand in were listed in three places once `refuse` read `NAMING_FIELDS`.

`nameEvents` replaces both: just before a send it renames every naming field
holding a pending id the log has since admitted (`nameAdmitted` in
pending/model.js), keeps a renamed `parent` as `namedParent` for the thread the
reply was drawn in, and returns false for an undo that still names a gesture the
log never took, which delivery drops unsent as before. The ledger and delivery
call the one method. No field is excluded from renaming: each holds a pending id
only while the gesture it names is in flight, and the admitted id is what the log
reads there.

No behavior change intended; a rewrite's `message` is now renamed too, which no
current gesture exercises since a pending message cannot be rewritten.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A reply box under a thread this tab opened keys its draft by the first message's
attempt (`reply:<attempt>`). A refusal withdraws that thread, so every reply
draft under it, sent behind the comment or still unsent, was orphaned: an
unsent one got no word in the notice and Resume writing answered "That writing
place is unavailable on this version"; and editing the comment before sending
it again minted a new attempt, so the resent thread opened a different, empty
reply draft. (Both found by Codex review.)

Behavior change: until the log takes a first message, the draft it was sent
from owns what is written under its thread. On refusal, the reply's words move
to that draft's held reply (`reply-after:<context>`), the notice says "Reply
kept — it returns when its comment sends", and Resume writing standing in the
withdrawn box moves to the comment's draft. The comment's next send, edited or
not, moves the held reply into the thread it opens. This replaces the earlier
special case that only recognised a sent reply under the same attempt.

`transferDraft` gains `resume: false` for a destination that is no box to resume
in.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
c746042 parked the reply a refusal handed back under a context named after
the comment's draft (`reply-after:<context>`). A draft that then moved lost it:
reopen a refused anchored comment, Alt-click another passage to carry it, send,
and the new thread's reply box was empty, the reply still parked under the old
passage (found by Codex review). The parked reply could also attach to the next,
unrelated comment written in the same context, such as the page comment box.

Behavior change: the reply is now a field of the comment's draft record
(`held`). Every edit of the draft keeps it, `transferDraft` carries it to the
destination (folding it into the words where the destination is a reply box,
which opens no thread), sending or cancelling the draft settles it with the
record, and the comment's next send puts it in the box of the thread it opens.
A refusal writes the withdrawn box's words back as the held reply without
minting a new attempt, so a resend still re-evaluates the refused one. No mover
needs to know about it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit a891781 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the refused-events branch October 12, 2026 05:39
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