Skip to content

feat: undo leaves the user at what it takes back - #4303

Merged
max-sixty merged 3 commits into
mainfrom
undo-returns-to-place
Oct 27, 2026
Merged

max-sixty merged 3 commits into
mainfrom
undo-returns-to-place

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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 the gesture 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 returns the user to 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.

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

  • 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).
  • test_inline_retirement_is_resolved_before_its_pixels_finish now asserts a refused seated resolve returns focus to the seated thread.

Where to read

The undo.js header states the rule; the folding.js header, events.md's Undo section, browser/AGENTS.md, the glossary's Undo entry and how-it-works #undo point at it.

Evidence

leaf-dev probe journeys on a copy of ship-review with extra page threads, in Chromium and Firefox: panel t/r/z lands on the resolved thread (before: stayed on the next one); margin-card t/r/z lands on its card; Escape between r and z gives 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.

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

max-sixty and others added 2 commits October 26, 2026 16:21
`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]>
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
@max-sixty
max-sixty merged commit e0054e5 into main Oct 27, 2026
4 checks passed
@max-sixty
max-sixty deleted the undo-returns-to-place branch October 27, 2026 00:27
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]>
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