Skip to content

Stop the playground submit flickering on each press - #4516

Merged
max-sixty merged 2 commits into
mainfrom
playground-submit-flicker
Oct 27, 2026
Merged

max-sixty merged 2 commits into
mainfrom
playground-submit-flicker

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Pressing a playground's submit ("Build this treatment", or Undo choice) flashed the button and the cursor for one delivery round trip. The widget set aria-busy, whose undelayed cursor: progress (browser/runtime/marks.css) swapped the cursor, and an in-flight flag made the command unavailable, so the button wore its disabled face until the server answered.

The press's result needs neither. The label already derives from the pending gesture (the module header says the face never derives from delivery timing), and the runtime withdraws a pending choice by its attempt. The submit now dispatches and keeps its face.

Per-frame readings of the submit in Firefox on motion-playground, from leaf-dev probe --browser firefox --base (label · aria-busy · aria-disabled · cursor · background):

ms before after
0 Use this timing · · · pointer · accent Use this timing · · · pointer · accent
33–36 Use this timing · busy · · progress · accent Undo choice · · · pointer · accent
37 Undo choice · busy · · progress · accent
45 Undo choice · busy · disabled · progress · grey
55 Undo choice · · disabled · default · grey
66 Undo choice · · · pointer · accent

Undo and a second choose showed the same sequence before, and a single label change after.

Behavior change: a second press while the first is still in flight used to be swallowed; it now does what the button says by then, withdrawing the pending choice. test_a_press_in_flight_does_what_the_playground_button_says replaces the test that pinned the swallowed press. On a local server delivery took ~30 ms, shorter than a double-click, so this already happened on base outside the in-flight window.

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

Pressing a playground's submit (choose or Undo choice) flashed the
button and cursor for one delivery round trip: the widget set
`aria-busy`, whose undelayed `cursor: progress` swapped the cursor, and
an in-flight flag made the command unavailable, so the button wore its
disabled face (grey, default cursor) until the server answered. Measured
in Firefox on motion-playground, every press went pointer → progress →
default → pointer and accent → grey → accent within 30–70 ms.

The press's result needs neither: the button's label already derives
from the pending gesture, as the header says, and the runtime withdraws
a pending choice by its attempt. The submit now dispatches and keeps its
face, so the cursor and button stay put.

Behavior change: a second press while the first is still in flight used
to be swallowed; it now does what the button says by then, withdrawing
the pending choice. `test_a_press_in_flight_does_what_the_playground_button_says`
replaces the test that pinned the swallowed press.
@max-sixty
max-sixty merged commit 345ac73 into main Oct 27, 2026
4 checks passed
@max-sixty
max-sixty deleted the playground-submit-flicker branch October 27, 2026 22:00
max-sixty added a commit that referenced this pull request Oct 28, 2026
A press on a Leaf control should draw its own result at once and stay
live while the gesture travels; the runtime already orders pending
gestures, undoes a pending one by its attempt, restores the server's
state on a refusal and says why in the notice seat. Three widgets
instead kept their own in-flight state, which marked the pressed control
busy or disabled until the server answered and flashed the cursor and
the control under the pointer on every press (the playground's submit
got the same fix in #4516).

**Done and reaction chips.** lf-options' Done and the reaction chips no
longer wear `aria-busy` while their gesture is in flight, and Done drops
its in-flight guard, so a second press does what Done then says rather
than being swallowed. Measured in Firefox on `ideas-to-implement`, Done
went pointer → progress → pointer within 45–60 ms on every press; it now
keeps its pointer and paints pressed in ~11 ms.

**Busy controls keep their cursor.** `marks.css` gives the progress
cursor to busy reading content only (a message being sent, an upload); a
control a package marks busy keeps its cursor and takes chrome.css's
existing delayed fade, so a fast answer shows nothing. No delay is
added.

**lf-suggestion.** Accept and Reject no longer leave a disabled, busy
Undo in the pressed entry's seat (in Firefox on `release-notes`:
progress cursor and 0.55 opacity for ~45 ms). The widget's `#deciding`,
`#staging` and `#undoing` state and its own refusal UI go (168 lines):
Undo is live from the press, a refusal returns Accept and Reject, and
pressing Accept again is the retry. The decision names itself through
the dispatch's `says`, so the runtime announces it and names it on undo.

**Behavior changes**, each with its test rewritten to pin the new
behavior:

- A second press while the first is in flight acts on what the control
then says (Done, the suggestion's Undo), instead of being swallowed.
- A refused suggestion decision or undo shows the delivery notice
("Couldn't take this — …") and the restored controls, with no Failed
receipt, Retry or Cancel.

`browser/AGENTS.md` now states the rule these follow.

Resolve and Reopen still single-flight: a pending settlement gates
reply, edit, resolve and reopen (`thread/model.js`, `thread/actions.js`,
`thread/folding.js`, `thread/thread-card.js`) and is tied to where the
user lands, so lifting it is its own change.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 28, 2026
…s answer held (#4608)

#4516 and #4561 made the playground's submit, Done, reaction chips and
the suggestion's controls stay live while their gesture travels. This
finishes the job for Resolve and Reopen, and adds a suite test that
presses every bundled control with the server's answer held, so the next
widget that keeps its own "sending" state fails before review.

**Resolve and Reopen stay live.** A resolve or reopen marked its thread
as settling until the server answered. While it was set, the card's and
panel's settle button wore a busy or disabled face for one round trip, a
second press was dropped, and replies and edits on the thread were
refused. The settling mark goes, with the thread's `offers` (which only
combined `resolved` with it), the busy and disabled faces, the drop in
`settleThread` and `pendingForParent`. A press while one is in flight
sends the opposite settlement after it, as the pending ledger orders
them; a reply or edit sends as usual, and a reply reopens the thread as
the server already does. `settleThread` now waits on its own attempt
rather than any settlement of the thread.

**Every bundled control is pressed with its answer held.**
`tests/browser/widgets/test_pressed_controls.py` presses each control in
each bundled package's worked examples, and the margin entries Leaf
draws for them, with the event POST held. A control whose press sends a
gesture must keep the cursor and the available, idle face it had before
the press, and where the same control stays under the pointer, a second
press must send again. A small states page adds a `multiple` group,
since no worked example shows Done. Restoring `aria-busy` or an
in-flight guard on the playground's submit, or the pre-#4561
`lf-suggestion` or `lf-options`, fails it. It runs only in the suite, so
`page check` and `package check` pay nothing for it; each package takes
at most about 3.5 s.

**`package check --render` works again.** Since #4551,
`start_throwaway_page` was handed the composed layer where it expected
the selection, so the check raised `TypeError` for every package. It now
selects the package as `page init` would, by its installed or bundled
name or else by path, with no theme, so the reading is the same on every
machine. The sweep serves examples through
`widget_quality.served_examples`, split out of `_page_findings`.

Behavior changes, with their tests:

- Pressing Reopen while the resolve travels sends `unresolve` after
`resolve`, instead of nothing
(`test_a_settlement_in_flight_leaves_its_opposite_live`, replacing the
test that the control stopped being busy once a poll accounted it).
- Packages read `thread.resolved` rather than `thread.offers`
(`module-annotations.md`).

With the render check working, the nightly
`test_bundled_widgets_meet_the_widget_quality_checks` reports first-box
findings for `lf-worktree` (#4475), `lf-timeline` (#4476) and `lf-dial`;
`test_a_widget_first_paints_the_box_it_presents[diff-*]` already fails
on main (#4349).

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 31, 2026
Main moved the playground's initial producer into widgets/playground-view.js
(#4545), lets page CSS reach every control (#4490), draws presses from their
actions (#4547, #4563), registers commands through lfCommands, and already
lets a playground run with no lf-playground-control. The PR's prose about
offer() and data-controls, its relaxed control check and its deleted
initial/vendor producer files take main's side.

What stays from the PR is actions="page", now built in the Lit view:

- playground-view.js draws no actions bar under actions="page", and no rail
  unless controls are written there; the instruction renders after the stage,
  where it was written. `give({submit, reset})` takes the page's buttons, and
  render writes the submission's words into the page's button from the same
  template Leaf's own submission uses (submit-label, then Undo choice).
- lf-playground.js's registerActions hands the buttons to the view and sets
  the playground's commands then, since a Decision command needs its control:
  the 1 key, Alt+0 and On me's arrival reach the page's buttons. A page that
  never calls registerActions still fails after first presentation.
- The copy control and popover wiring run only when Leaf draws the popover.
- The PR's test and corpus fixture pass the contributor editor main's
  registerContributor now requires.

Behavior from main kept: the submit no longer disables while a submission is
in flight (#4516), so a page's button follows the same rule.
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