Repository navigation
feat: undo leaves the user at what it takes back - #4303
Merged
Merged
Conversation
`z` now ends with the user at the place of the gesture it takes back, for every undoable gesture, and undo.js owns that rule. Before, each settlement surface (inline card, margin card, panel resolve, panel reopen) carried its own `reverse` landing with its own conditions, and the panel's deliberately left the user where a resolve had moved them: resolving a thread from the panel moved on to the next thread, and `z` reopened the first one without showing it. A press now reaches the gesture's place one of three ways: - the place is in view: the press takes it there; - the place is out of view, or the agent picked the gesture up: the press shows it and the next takes it (unchanged); - the gesture's own landing just carried the user from its place (a thread settlement made in this tab): the press takes it at once, then opens the thread once the log admits the withdrawal and the page presents it. The third replaces the per-surface reversals. A settlement with a landing arms `z` (`landedAway`) the way a showing press does, and the same inputs clear the arm, a wheel included, so after the user acts elsewhere the ordinary show-then-take rule applies. Presses of the undo key itself no longer clear an arm, so a `z` the page holds back while a change is in flight doesn't cost a second press. `returnToThread` lands on a thread already drawn in view on the page, so a seated thread keeps the user in its seat rather than opening a margin card for it. A refused settlement returns the user through the same `returnToThread`, while no input has come since the gesture; before, the panel returned them only if Threads was showing. This reverses the panel's recorded choice to leave the user where a resolve moved them, whose reason was that opening a view when the server's reading arrived would move the panel under no press. The return now runs under the undo press's own intent, so that reason no longer applies. Behavior changes, with the tests rewritten to match: - Taking back a panel resolve opens the resolved thread again, focused, instead of standing on its row in Threads or staying on the next thread (`test_one_field_starts_a_thread_takes_its_reply_and_settles_it`, `test_a_thread_s_keys_answer_in_its_view`, `test_resolving_a_thread_from_threads_moves_on_to_the_next`). - After the user closes the panel and presses on the page, `z` on that settlement shows the thread first and takes it on the second press, instead of changing the thread unseen (`test_z_shows_a_settlement_the_user_left_before_taking_it`). The undo.js header states the rule; folding.js, events.md's Undo section, browser/AGENTS.md, the glossary and how-it-works point at it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # dist/kernel/kernel.json
leaf-agent
previously approved these changes
Oct 27, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Oct 27, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
#4327) Undoing a resolve left the thread closed until the server's reading arrived. The browser's thread fold (`foldThreads`) dropped withdrawn messages but kept a closure whose event was being withdrawn, and a margin draws no card for a closed thread. So `z`'s return to the thread (#4303) had to wait for the log's answer; returning sooner fell back to the floating panel. The fold now treats a thread whose closing event the tab is withdrawing as open, as `localTodos` already does for a to-do whose Done is withdrawn; the log's answer restores any earlier closure. Undo's return no longer waits for the answer: it shows the thread once the page presents the withdrawal. **Behavior change:** after `z` on a resolve, the thread stands open (its margin card, the panel's Open list) before the server answers. **Evidence:** a `leaf-dev probe` journey holding the undo POST: with the change, the margin card opens and takes focus while the request is pending; without the fold change, the same return opens the floating panel. Panel, margin and refusal journeys from #4303 still land on the thread in Chromium and Firefox. The new assertion in `tests/runtime/thread-workflow.test.mjs` fails without the fix. `pnpm run check`, `pnpm run test:runtime` (668) and 71 targeted undo/resolve browser tests pass. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
znow ends with the user at the place of the gesture it takes back, for every undoable gesture, andundo.jsowns that rule. Before, each settlement surface (inline card, margin card, panel resolve, panel reopen) carried its ownreverselanding with its own conditions, and the panel's deliberately left the user where a resolve had moved them: resolving a thread from the panel moved on to the next thread, andzreopened the first one without showing it.A press now reaches the gesture's place one of three ways:
The third replaces the per-surface reversals. A settlement with a landing arms
z(landedAway) the way a showing press does, and the same inputs clear the arm, a wheel included, so after the user acts elsewhere the ordinary show-then-take rule applies. Presses of the undo key itself no longer clear an arm, so azthe page holds back while a change is in flight doesn't cost a second press.returnToThreadlands on a thread already drawn in view on the page, so a seated thread keeps the user in its seat rather than opening a margin card for it.A refused settlement returns the user through the same
returnToThread, while no input has come since the gesture; before, the panel returned them only if Threads was showing.This reverses the panel's recorded choice to leave the user where a resolve moved them, whose reason was that opening a view when the server's reading arrived would move the panel under no press. The return now runs under the undo press's own intent, so that reason no longer applies.
The return waits for the log's answer because, before it, a margin doesn't yet draw the reopened thread: returning at local presentation fell back to the floating panel.
Behavior changes, with the tests rewritten to match
test_one_field_starts_a_thread_takes_its_reply_and_settles_it,test_a_thread_s_keys_answer_in_its_view,test_resolving_a_thread_from_threads_moves_on_to_the_next).zon that settlement shows the thread first and takes it on the second press, instead of changing the thread unseen (test_z_shows_a_settlement_the_user_left_before_taking_it).test_inline_retirement_is_resolved_before_its_pixels_finishnow asserts a refused seated resolve returns focus to the seated thread.Where to read
The
undo.jsheader states the rule; thefolding.jsheader,events.md's Undo section,browser/AGENTS.md, the glossary's Undo entry and how-it-works#undopoint at it.Evidence
leaf-dev probejourneys on a copy ofship-reviewwith extra page threads, in Chromium and Firefox: panelt/r/zlands on the resolved thread (before: stayed on the next one); margin-cardt/r/zlands on its card; Escape betweenrandzgives show-then-take; a refused resolve returns to the thread in both the panel and margin cases.pnpm run check,pnpm run test:runtime(668), and 135 targeted browser tests across undo, resolving, seated, margin, panel and reactions pass.