Skip to content

Take a gesture back with one press of ⌘Z, then go to it - #6429

Merged
max-sixty merged 4 commits into
mainfrom
undo-take-at-once
Nov 19, 2026
Merged

max-sixty merged 4 commits into
mainfrom
undo-take-at-once

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Undo now takes back the user's newest gesture in one press of ⌘Z (Ctrl+Z off a Mac), and where its place was out of view, goes there once the page shows the withdrawal; Back returns to where the user pressed. This replaces "show, then take" from #3603, where a first press showed an out-of-view gesture and a second took it, and moves undo off bare z. max-sixty chose both today: taking at once, after a review found that the state behind showing had been patched seven times in four weeks and that a missed visibility reading cost a press that took nothing; and ⌘Z, after a word typed onto the page undid work.

What one press does, before and after (each row run with leaf-dev probe on this branch in Chromium, and each choice row in Firefox too):

When the user presses undo main (z) this PR (⌘Z)
The gesture is in view takes it takes it
It is out of view shows it, says "Press again to undo"; a second press takes it takes it, then goes to it
Right after the Escape that closes a panel over it reads the closing panel as covering it: scrolls 543 px, adds #near, takes nothing takes it, no scroll
The user's choice is still being sent does nothing, says nothing (10 ms at 1× CPU, over 100 ms at 8×, plus server time) takes it at once by its pending id, as the widget's Undo does
Two quick presses, a message or resolve still being sent, two choices still being sent, a held drag the press waits unchanged

Visibility is read with each cover where it comes to rest (seenRect's rest, which uncovered already took), and it now decides only whether the press travels. The armed state, its input and scroll watches, and landedAway are gone. The undo.js header, events.md "Undo" and how-it-works' Undo paragraph say what undo does now.

Undo moves from z to ⌘Z. Someone who thought they were typing in a box and typed onto the page undid work: on this branch zazu after a pick took the pick and an older comment, and zazu just after a passage's first comment took that comment back (main took one gesture in each). max-sixty picked the platform's undo chord over keeping z, ⇧Z and g Z, and kept Resolve on r. A text box keeps every letter with a modifier (keyboard/text-entry.js), so ⌘Z undoes typing inside a box and a gesture outside one. Probed in Firefox: zazu after a pick or a first comment now sends nothing, ⌘Z after each sends the undo, and ⌘Z in a reply box undoes its typing and sends nothing. A chord isn't a printed key, so the startup hold doesn't keep one: a ⌘Z pressed before the page's history arrives does nothing, where a held z waited for it. The docs, examples and tests name ⌘Z, and the notice's key chip spells it ⌘z, or Ctrl+z off a Mac.

Review found three more defects, fixed here, each with a test that fails without its fix:

  • An undo of an action whose POST had answered, before any reading held it, drew nothing until its own round trip: framework/application.js withdrew the action under the log's id while the page drew it under its pending id. This held for the widget's own Undo too.
  • Taking back a comment whose card was closed flashed the card open. A comment's place is now its passage.
  • The travel to an element ignored input made after the press; it now checks the press's intent, as the thread routes do.

The undo's notice. A survey of what the panel says after each press (#6439) found four defects in it, each on main too, fixed here:

  • "Undid: commented “…”" was a verb with its "I" left out, which the glossary's voice rule forbids; it now says "Undone: …".
  • "· 72d ago" after it read as when the undo happened. The age now follows the gesture's words with no separator, "Undone: resolved “Feeder” 21d ago", and the command reference's "Undo: …" line reads the same way.
  • In a thread open in the panel, a notice with no press of its own replaced "Reply…" and left c alone at the field's end. The field now ends it in "Reply…" and c, as the page's field ends one in "Comment…" and c. In a narrow panel the notice's age is then cut by the field's ellipsis; the live region still hears it whole.
  • Undoing a resolve announced a cut-off fragment of the agent's reply before the notice: the resolve had marked the reply read, so its undo made it unread again, and news counted a version the first time a tab saw it unread. A version a tab has already seen read is no longer news when it turns unread (semantic-news.js).

Taking at once also means undo takes an accepted action whose reading failed to commit, by its attempt, as that action's own Undo would. test_an_accepted_event_is_not_retried_when_its_state_cannot_render, written for main's hold, failed on this branch for that reason; it now checks that an older gesture's Undo still waits.

This replaces #6402, whose test waited out the Escape case; under this change that test passes as written.

Still open, found in review and not probed: an undo pressed inside the 140 ms scroll glide t starts reads the choice where the glide stands, not where it lands, so it may revert unseen. Covers are read at rest and glides aren't. The fix is to read both where they come to rest, in scroll-containers.js' seenLanded.

How loudly an undo shows what it took follows in its own PR: max-sixty picked an accent ring on what the undo changed, with the notice held until the next key.

Checks: the 85 browser and journey tests that press undo, call the harness's undo or read the words above (100 cases with parameters; all pass, the one above after its update), each new test failing without its fix; pnpm run test:runtime (1,052 pass) and pnpm run check:browser; pre-commit on every changed file.

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

`z` now withdraws the user's newest gesture in the press and, where its place
was out of view, travels there once the page presents the withdrawal, so Back
returns to where the user pressed. This reverses the "show, then take" rule
from #3603 (21–22 October), where a first press showed an out-of-view gesture
and only a second took it. Max chose taking at once on 18 November: the arm
behind showing had changed seven times in four weeks (#4303, #4327, #4895,
#5039, #5286, #5320, #5361), each time over how it met another surface, and a
visibility reading that missed cost a press that took nothing.

Two fast-user cases change with it:
- `z` within frames of the Escape that closes a panel read the closing panel
  as covering the gesture, scrolled 543 px, added a fragment and took nothing.
  Visibility is now read with covers where they come to rest (`seenRect`'s
  `rest`), and it decides only whether the press travels.
- `z` while a choice was still being sent did nothing and said nothing for
  10 ms at 1x CPU to over 100 ms at 8x, plus server time. It now takes the
  action by its pending id through the ledger, as the widget's own Undo does,
  and travels to it like any other gesture.
A message or resolve still being sent, an older action still being presented,
a held drag and the second press of `z z` still make `z` wait.

Review of the change found three more defects, fixed here:
- An undo of an action whose POST had answered, before any reading held it,
  drew nothing until the undo's own round trip: the local projection withdrew
  the action under the log's id while the page still drew it under its
  pending id. It now withdraws under the id it draws under. This was true of
  the widget's own Undo too.
- Taking back a comment whose card was closed opened the card for a frame or
  more, showing the thread the withdrawal removes. A comment's place is now
  its passage.
- A press that travelled to an element ignored input made after it; the
  fragment travel now checks the press's intent, as the thread routes do.

Deleted: the armed state, its input and scroll-away watches, the "shown"
flag, the promise that outlived a newer gesture, and `landedAway` with its
call in thread/folding.js.

Tests, by the behaviour they now protect:
- Removed, since they tested only the arm: the menu's two-step Undo, a key or
  modifier between presses, two quick presses before the show, a scroll away
  from the shown gesture, a second press during a fragment's trip.
- One press instead of two: a reply out of view, the fresh-tab row's age, an
  old resolve below the fold (now by the key and by the menu's row, opening
  in its card, as a route to an open thread does), the ways back from a
  settlement ("shown" is now "away"), and the tally's undo after Next On Me.
- New: a choice out of view is taken, then travelled to, and Back returns;
  `z` pressed as Escape closes a view over the choice takes it and moves
  nothing (fails with covers read where they stand); a second `z` while the
  first withdrawal is on its way takes nothing more; a comment taken back
  never opens its thread (fails with the comment's message as its place); an
  undo of an answered, unread action withdraws it at once (runtime; fails
  with the log's id).
- Changed: a move still being sent is taken by `z` rather than waited for,
  and the board shows it taken before the move's send returns.
leaf-agent
leaf-agent previously approved these changes Nov 18, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one red check, test's pnpm run check, is the browser type check failing in browser/runtime/anchor-placement.js (Cannot find name 'placement'). This PR doesn't touch that file. The errors come from this run's base (667b6c76), and #6420 fixed them on main. With the PR head merged onto current main, tsc --project browser/types/tsconfig.json passes.

A word typed onto the page by someone who thought they were in a box undid
work: on this branch, `zazu` after a pick took the pick and an older comment, and
`zazu` just after a passage's first comment took that comment back. max-sixty
picked the platform's undo chord over keeping `z`, ⇧Z and `g Z`, and kept
Resolve on `r`, since what it changes is the thread in front of the user.

A box keeps every letter with a modifier for its words (text-entry.js), so ⌘Z
undoes typing inside a box and a gesture outside one. Probed in Firefox: `zazu`
after a pick or a first comment now sends nothing; ⌘Z after each sends the undo;
⌘Z in a reply box undoes its typing and sends nothing.

Behavior changes the tests record:
- A chord isn't a printed key, so the startup hold doesn't keep one pressed
  before the page's history arrives; that ⌘Z does nothing. The cold-start test
  drops its Undo case.
- An accepted action whose reading failed to commit is the newest action in the
  ledger, so ⌘Z takes it by its attempt, as its own Undo would. This came with
  taking at once, and the test written for main's hold now checks that an older
  gesture's Undo still waits. It failed on this branch before this commit.

The notice's key chip says ⌘z (Ctrl+z off a Mac); docs, examples and comments
name ⌘Z.
@max-sixty max-sixty changed the title Take a gesture back with one press of z, then go to it Take a gesture back with one press of ⌘Z, then go to it Nov 18, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title and description still describe Undo on z. Since the squash merge uses them as main's commit message, main would record a binding this head no longer has. The latest commit makes ⌘Z (Ctrl+Z off a Mac) the undo key and states two behavior changes that the description doesn't mention:

  • a ⌘Z pressed before the page's history arrives isn't held and does nothing;
  • an accepted action whose reading failed to commit is taken back by its attempt.

Please update the title, the table header ("When the user presses z") and the paragraphs that name z, and add the reason for the move, since it reverses what the body argues for.

One mention was missed: browser_undo_candidates' docstring in src/leaf/served_state/document.py still says "so z names what it takes in every tab and after a reload". It's outside the diff, so it can't take an inline suggestion.

… hear no old reply as news

A review of what the panel says after each press (leaf-dev words, #6439) found four
defects in an undo's notice, each present on main too:

- "Undid: commented “…”" put a verb with its "I" left out in Leaf's voice, which the
  glossary's "Reader-facing words" forbids. The notice now says "Undone: …".
- "· 72d ago" after the undo's words read as when the undo happened. The age now
  follows the gesture's words with no separator ("Undone: resolved “Feeder” 21d ago"),
  in the notice and in the command reference's "Undo: …" line alike.
- In a thread open in the panel, a notice that offers no press of its own replaced
  "Reply…" and left the key `c` alone at the field's end. The thread's field now ends
  such a notice in "Reply…" and `c`, as the page's field ends one in "Comment…" and `c`.
- Undoing a resolve on ship-review announced a cut-off fragment of the agent's reply
  ("Both — it opens on the spinner and ends with the…") before the undo's notice. The
  resolve had marked the reply read (read_state.py), so its undo made it unread again,
  and the news rule counted a version as news the first time a tab saw it unread. A
  version the tab has already seen read is no longer news when it turns unread.

Behavior changed for tests: the notice's and the command reference's undo words
(test_render_outbox, test_tabs, test_render_reactions); a new panel test holds Reply
beside the key after a notice in a thread, and a new Node test holds the news rule.
Each new test fails without its fix. Probed in Chromium and Firefox on ship-review and
review-a-plan.
@max-sixty
max-sixty merged commit 2fac70a into main Nov 19, 2026
5 checks passed
@max-sixty
max-sixty deleted the undo-take-at-once branch November 19, 2026 00:25
max-sixty added a commit that referenced this pull request Nov 19, 2026
#6429 gave a thread's reply field Reply… and its key after a notice that offers
no press, through the panel's SAYS_ELSE. This branch moves the field's ends into
field-readings.js, so that rule now lives in `endOf`'s thread case, with a runtime
assertion beside the Go-to notice's. The field-readings header names ⌘Z, the key
#6429 gave undo.
max-sixty added a commit that referenced this pull request Nov 19, 2026
…#6447)

What ⌘Z, or a notice's Undo, takes back now takes a ring: an outline
twice the focus band's width, in the accent, held for about half a
second and faded by 1.2 s. It plays once the page shows the withdrawal,
and where the gesture was out of view, once the page has gone there. The
undo's notice now stands until the user's next key, press, wheel or
touch rather than for 4 s, which is the rule a notice with a press
already follows (`notice(…, {holds: true})`). max-sixty picked this on
the undo design page, after #6429, over keeping the 4 s notice, holding
it in ink, and darkening the panel's field.

The ring is the box's own outline at the box's `--lf-ring-at`, so it
stands where the box's other marks stand (`tokens.css` lists it among
them). A message the undo took away rings the thread that held it. An
exact control's withdrawal, such as a widget's Undo, rings nothing,
since the user pressed it where the gesture is drawn. Under reduced
motion `motion` plays nothing, and the held notice alone says what was
taken. Two weaknesses: a box that states no `--lf-ring-at` gets a
region's gap, even where it is a control, and a box drawn with `display:
contents` shows no ring.

`test_inline_retirement_is_resolved_before_its_pixels_finish` froze the
first animation on the thread once it went inert. After an undo of a
Resolve, that was the ring rather than the fold, so it now picks the
fold by its `blockSize` keyframes.

Checks: a new browser test checks the ring after an out-of-view undo,
and that the notice outlasts `NOTICE_MS` until a key; each half fails
without its change. The 117 browser tests that press undo or read
notices pass, as do `pnpm run test:runtime` and `check:browser`. Firefox
stills of the built ring are on max-sixty's page.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 19, 2026
⌘Z pressed during a scroll Leaf runs, such as the 140 ms scroll `t`
starts toward a thread, now reads whether the user saw its gesture where
that scroll will land rather than where it stands. Before, a choice
still in view at the press was taken without travel, and the scroll then
carried the user to the thread, away from what the undo changed:
pressing Shift+t then ⌘Z before the scroll's first frame left the choice
out of view in 3 of 3 runs. #6429's description named this as found in
review and not yet probed.

Undo's `seen` now calls `seenLanded`, the glide-aware reading the
reading place already uses, which gains the destination's box and the
at-rest reading of covers that #6429 gave undo for a panel closing over
its place. Its other callers pass neither and read as before.

To weigh: the reading place, the user's place and the current target
still read covers as drawn now while they read glides where they land,
so a key pressed as a panel closes is judged against the panel. Nothing
reported has hit that.

Checks: the new test presses ⌘Z before the walk's first frame and waits
for the travel to the choice; it times out against the old reading and
passes in Chromium and Firefox. The 27 undo tests in
`test_render_outbox.py` and `threads/test_resolving.py`, `pnpm run
test:runtime` and `check:browser` pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty pushed a commit that referenced this pull request Nov 19, 2026
)

#6429 moved undo from bare `z` to ⌘Z (Ctrl+Z off a Mac), so that typing
a word with a "z" in it onto the page no longer takes back the user's
last gesture. No test protected that move. This PR adds one, and renames
the 18 undo tests still named for `z`.

- **New test:** `test_bare_z_takes_nothing_back_and_undo_still_does` in
`tests/browser/test_render_outbox.py` makes a pick and waits until the
page offers ⌘Z. It then presses bare `z` and checks the pick stands.
Finally it presses ⌘Z and checks the pick is taken back, with exactly
one `undo` event in the log, naming the pick. With `z` temporarily bound
to undo again in `browser/runtime/undo.js`, the test fails at the "pick
still stands" check.
- **Renames:** `test_z_…` becomes `test_undo_…` and `test_a_second_z_…`
becomes `test_a_second_undo_…`. That covers 16 tests in
`test_render_outbox.py` and one each in
`projection/test_widget_actions.py` and `test_render_reactions.py`. No
assertion changes. Bare `z` now means "scroll the current item to the
top", so the old names pointed at a different command. Nothing else in
the tree refers to the old names.

**Verification:** the new test and a renamed one pass by node id, and
`ruff check` and `ruff format --check` are clean.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 27, 2026
Comment only. `undo.js`'s header now names the simpler design that is
open should undo's press-time reading of visibility keep needing fixes:
⌘Z returns the user to where they stood when they made the gesture in
this tab (`records/history.js`, `readPlace`) and otherwise moves nobody,
giving up travel to a gesture made far away.

That reading has needed three fixes (#6429, #6460, #7369), and #7396 is
a fourth case it misreads, a widget hidden in a closed disclosure. All
29 undos in this machine's page logs came within 33 s of their gesture,
so none needed the far travel.

Asked for by max-sixty after #7369.

> _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