Skip to content

test: wait for the closed panel to stop covering the suggestion before pressing undo - #6402

Closed
max-sixty wants to merge 1 commit into
mainfrom
agent-aba75c1f56e5eb04e
Closed

max-sixty wants to merge 1 commit into
mainfrom
agent-aba75c1f56e5eb04e

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

In the outbox undo test, z takes the suggestion only when the user can see it; otherwise it shows it first (needsShowing in browser/runtime/undo.js). After Escape the thread panel's element is gone but its box is still closing over the suggestion, so on a starved runner the press only showed it and sent no withdrawal. The test now waits until seenRect reports the suggestion seen before pressing z. No product code changes.

Pressing Escape right after the injected fault reproduces the nightly failure on every run (sends 2, acked 2, "never sent the withdrawal", a cover box over the suggestion); with the wait it passes 3 of 3 that way, and the unchanged flow passes 5 of 5 under six busy loops with --cpu-throttle 8. I could not make the unmodified test fail on this Mac under load, so the early-Escape timing is the reproduction, matching the nightly's counts exactly.

Refs #6392

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

…e pressing undo

`z` shows a gesture the user can't see before it takes it (`needsShowing`, browser/runtime/undo.js). In the outbox undo test, the thread panel's element is gone after Escape while its box still closes over the suggestion, so on a starved runner the press showed the suggestion and sent no withdrawal. Pressing Escape right after the injected fault reproduces it every time (sends 2, acked 2, "never sent the withdrawal"; cover box 138..886 over a suggestion at 164). The test now waits until `seenRect` reports the suggestion seen, the state a user would act from.
@max-sixty

Copy link
Copy Markdown
Owner Author

Replaced by #6429, which makes one press of z take the gesture and then go to it. Its visibility reading reads covers where they come to rest, so a z pressed as Escape closes a panel takes the gesture where it stands. This PR's test passes there as written, and #6429 adds one that presses z within frames of the Escape.

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

@max-sixty max-sixty closed this Nov 18, 2026
max-sixty added a commit that referenced this pull request Nov 19, 2026
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_
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