Repository navigation
Show what z takes before taking it back - #3603
Conversation
`z` no longer takes back a gesture the user cannot see. Where the gesture's
place is out of view, or the agent has already picked it up, the first press
(or the leaf's menu Undo) shows that place and says "Press again to undo:
resolved “Feeder” · 21d ago"; the second press withdraws it. This completes
the undo design the user chose on 21 October ("Show, then take", after "Say
what z takes" in #3586).
Behavior:
- Showing works as an `lf-activity` row's link does: a thread opens, and an
element is travelled to as its fragment and focused. A widget an agent sent
in a message opens its message.
- The arm clears on any other key, a press on the page, or a scroll taking
what was shown out of view; the next press then shows again. A modifier
alone, a wheel that keeps it in view, and presses in Leaf's chrome keep it,
so the menu row (the touch route) works in two presses through the leaf.
- A target in view and not picked up is taken on the first press, as before.
So is a gesture this tab holds a reversal for (a thread settled from a
view), since taking it back already lands the user on it.
- Approvals and a to-do's Done have no place on the page; picked up, they
arm with the notice alone.
- A resolved thread's line in the panel now says a passing notice, on one
line, instead of always "Resolved · reopen to reply"; without this the
notice was unseen while the panel showed the thread `z` had opened.
Served state: each undo candidate a delivery handed into an agent's turn
carries `picked_up`, read from the opened pickups (`delivery.opened_input_ids`,
the Delivered stage the workflows read). It is an optional field, so no
protocol bump: a runtime vendored earlier reads the undo list's `event`,
`coordinate`, `newest` and `gesture` by name and ignores it (undo.js, the
widget Undo's coordinate filter). The build moved the baseline without
needing --accept-served.
Tests whose behavior changed: the fresh-tab naming test now presses the menu
row twice; the candidate-applying test and the tally's Next-then-z step press
`z` once to show the target (covered by the panel, or in a tab Next left) and
again to take it.
Evidence: four new browser tests (old resolve below the fold, a picked-up
choice in view, the arm clearing on a key and a scroll, the menu route) fail
on the base runtime and pass here; the in-view control passes on both. A
process test covers `picked_up`. Hand-checked in a review-a-plan preview,
light and dark.
The undo-reach note is deleted; its Redo and Changes panel analysis moves to
a TODO item pointing at `fa3aad5e0:notes/undo-reach/README.md`.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/kernel/kernel.json
leaf-agent
left a comment
There was a problem hiding this comment.
A quick second z can withdraw a gesture before the first press has shown it. arm() makes the next press eligible while show() is still awaiting the thread opening. I reproduced two keydowns in one browser task: the thread was outside the viewport after both presses, yet the undo was posted. Gate the second press on the destination actually being visible so the withdrawal follows the reveal.
…e applying test's showing A second z in the same task as the first could withdraw the gesture before the first press's reveal finished, so the user never saw it. The arm now takes only after the reveal resolves. The candidate-applying test relied on the panel covering the suggestion, which CI's layout didn't; it now marks the gesture picked up, so the first press shows it wherever it lies. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The fragment route can still take back a gesture before its destination is visible. show() calls location.assign() and resolves without waiting for the hash navigation to scroll. With an action on #picks below the fold, I dispatched z, awaited two microtasks, and dispatched z again in the same browser task: #picks was still outside the viewport before the second press, but an undo event was admitted. Check that the destination is visible when the armed press is taken. The new test covers the thread opening path, whose show() awaits its destination.
The fragment route assigned the hash and returned, so a second z in the same task could take the gesture back before the trip scrolled it into view. Showing now navigates through the Navigation API and waits for the trip to finish. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # dist/kernel/kernel.json # notes/undo-reach/README.md
# Conflicts: # dist/kernel/kernel.json
# Conflicts: # dist/kernel/kernel.json
# Conflicts: # dist/kernel/kernel.json
# Conflicts: # dist/kernel/kernel.json
`test_another_key_or_a_scroll_away_puts_the_shown_gesture_back_to_showing` pressed `z` on a choice already in view and scrolled the window away in the next breath. The arm starts watching what a press showed only once the press's fragment travel has finished, and clears on a scroll only after a pass has read it in view, so a scroll in that window leaves the arm standing and the next `z` takes the choice back. On a fast host (this Mac, the macOS runner) the test's scroll won that race every time; on the slower Linux runner the travel finished first. No user scrolls within the few milliseconds of that window. The test now waits for the press's travel to finish and for the pass after it, and for the pass after its own scroll, before pressing again. Introduced with the test in #3603. The behavior protected is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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](#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_
Undo now shows a gesture before taking it back whenever the user couldn't see what it would change. This completes the undo design the user chose on 21 October (the "Show, then take" half; "Say what z takes" landed in #3586), so
notes/undo-reach/is deleted.What the user sees.
z(or the menu's Undo row, its touch route) would take back is out of view, or the agent has already picked it up, the first press only shows it. It opens the thread, travels to the widget as its fragment so Back returns, or opens the message holding an agent-sent widget. It then says "Press again to undo: resolved “…” · 21d ago". The second press takes it back.How.
browser_undo_candidates(served_state/document.py) markspicked_upfromdelivery.opened_input_ids: the opened-pickup evidence the workflows read as Delivered, which had no callers until now.undo.jsholds the armed state.picked_upis optional, and earlier runtimes ignore it.Evidence.
test_render_outbox.pycover:pnpm run test:runtime(519), outbox-k "undo or z_"(23), the floating panel-k menu(15) and the process undo tests pass, andcheck:browseris clean. Three existing tests now press twice, as the new behavior asks.review-a-planpreview with a 21-day-old resolve below the fold, and with a picked-up one.events.md's Undo section, theundo.jsheader, thehistory.undodescription anddocs/how-it-works.html#undodescribe it. Redo and a Changes panel move to a TODO item that points at the deleted note.