Skip to content

test(studio): the edit-accuracy bench reads what a person ends with after sealed saves and undos - #8475

Merged
miguel-heygen merged 5 commits into
mainfrom
test/edit-accuracy-waits-for-held-press
Nov 22, 2026
Merged

miguel-heygen merged 5 commits into
mainfrom
test/edit-accuracy-waits-for-held-press

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

The edit-accuracy bench's sequences now read what a person ends up with:

  • End of a sequence: the bench reads the final file only once every edit has saved.
  • After each undo: the next press waits until the undo is shown.

Studio says on the page while an edit is saving (data-studio-edits-saving), the same way it already says data-preview-changing. Each undo step also records two times:

  • shownMs: when the box first moved;
  • restMs: when Studio went idle.

Why

In a sealed preview, edits and undos reach the page later than in a plain one, and the sequence bench read too early in two places.

1. The end of a sequence. A press made while the previous gesture's save is still out waits for that save, then replays and saves itself. Before reading, the bench waited for its write count to reach the number of saving steps, and for no press waiting. Both can pass before the last gesture saves:

  • one gesture can write the file twice (a resize of a timeline-held box does, sealed and plain alike), so the count is met early;
  • the waiting mark clears once the press replays, before that press's own save.

So the bench read the file without the last edit, and the edit looked lost. With the server's write trace for seqheldtwice-tlhold-px-r0-root-z100, sealed:

  • the last move was let go at +13387 ms;
  • Studio committed it at +14238, once the previous resize's save returned;
  • the server wrote it at +15142;
  • the bench had already recorded the resize's write as the final file.

2. After an undo. The bench pressed Ctrl+Z, waited one frame, then pressed the box's centre for the next drag.

  • Plain: the undo changes the page at once, so that press lands on the box.
  • Sealed: the undo reaches the preview later. In failing runs of sequndo-none-pct-r0-nested-z100, the bench pressed where the box was before the undo. Studio held the press until the undo showed, as it does for any press while the preview changes, found nothing under it, and the drag never started. That's the 12-248 px "jump" those cases reported.

shownMs is the time during which a person still sees the old box, so it's the number to compare between sealed and plain.

Related work

Refs #7846 (Studio's preview sealed by default): its edit-accuracy gate flagged these sequences as lost edits, lost undos and jumps.

How

  • studioPendingEdits.ts: isStudioEditSaving() (pending edits and shown undo/redo restores) is mirrored onto the page as data-studio-edits-saving, updated wherever either set changes.
  • sequences.mjs:
    • restedFor(busy, frame) waits until nothing is busy for two frames in a row and returns the ms until the first clear read. It throws after 20 s.
    • Busy means a press is waiting, an edit is saving, or the preview is changing.
    • A sequence calls it after the write-count wait (the count stays as a floor and a reported metric) and after every undo step.
    • The undo step reports shownMs and restMs.

Plain sequences now also wait for each undo's save before their next press (about 0.7 s at p50 on Linux), where they used to press one frame after Ctrl+Z.

Results

The 13 cases the sealed gate flagged for undo, reload or a jump: Linux, 3 jobs, sealed and plain, on main plus the open sealed fixes, with the redo-box fix from #8462.

Each of the 13 failed sealed at least once on the gate before this PR. With it:

  • plain: 13 of 13 pass undo and reload, 3 of 3 runs;
  • sealed: 6 of 13 pass undo and reload in every run with the undo wait (3 runs), and 2 more in 2 of 3.

Passing sealed in every run:

resize-spin-px-r0-root-z100-{after,mid} pass in 2 of 3 runs; the third failed drop and reload on the same run, which I haven't rooted.

Still failing sealed and passing plain, with their own roots to find:

  • seqfastkeys-none-px-r0-root-z100;
  • seqheldtwice-tlhold-px-r0-nested-z100;
  • textselect-none-px-r0-root-z100;
  • seqplainkeys-none-{center,pct}-r0-root-z100.

Drag-follow (tracking, teleport) fails sealed in most cases; that's separate work and this PR doesn't change it.

No visible change

Studio gains one attribute on its root element while an edit saves, which nothing styles; the rest is bench code.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

fails without the fix:

  • studioPendingEdits.test.ts:
    • "holds from a pending edit's start until its save lands";
    • "holds while a shown undo or redo waits for its save".
  • settle.test.mjs:
    • "waits until no press waits and no edit saves, two reads in a row";
    • "says how long until the first of the clear reads, the undo's time to show";
    • "gives up with a reason when an edit never stops saving".

studioPendingEdits.test.ts plus the whole tests/e2e/edit-accuracy/ folder (14 files, 157 tests) pass three runs in a row on Linux. Pre-commit (format, lint, fallow, typecheck) passes.

…s last edit has saved

A sealed press made while the previous save is out waits, then replays and saves. The sequence bench read the
file once its write count was met, which one gesture writing twice can reach before the last gesture saves, so
that edit looked lost. Studio now says on the page while an edit saves, and the bench also waits for that and
for no waiting press, two frames in a row.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 58 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@jrusso1020 jrusso1020 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.

Requesting changes at 87668e85, for one item: a new test in this PR is timing-flaky, and that turns the required Flake gate red.

settle.test.mjs, "says how long until the first of the clear reads, the undo's time to show", waits two 10 ms setTimeout frames and asserts ms >= 20. Node timers can fire about 1 ms early against the wall clock. Under the gate's CPU contention, 1 of 10 runs got expected 19 to be greater than or equal to 20 (settle.test.mjs:311, Flake gate job 137157040454).

Fix: have the test measure with an injected clock or fake timers, or assert a margin (e.g. >= 18) together with an upper bound that still tells "two frames" from "one frame". Then re-run the Flake gate.

The rest reviewed clean:

  • studioPendingEdits.ts mirrors isStudioEditSaving() wherever either set changes.
  • restedFor requires two clear reads in a row, and throws with a reason after its timeout.
  • The bench waits after the write count and after each undo.
  • The "fails without the fix:" tests are named.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. The PR is test and bench code, plus one unstyled page attribute. The only blocker is this flake in the PR's own test.

— Rames (hf-review)

@jrusso1020 jrusso1020 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.

Approving at aca81b37. My change request at 87668e85 is resolved.

  • restedFor now takes an injected now (defaulting to Date.now).
  • The settle tests drive a fake clock that each frame advances by 10 ms, so "the undo's time to show" asserts an exact 20 with no wall-clock sleeps. That removes the 19-vs-20 flake under contention.
  • The rest of the delta threads now through. Production calls keep the Date.now default. The previously reviewed parts are unchanged.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. Test and bench code only.

— Rames (hf-review)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit bc3d7b4 Nov 22, 2026
89 of 91 checks passed
@miguel-heygen
miguel-heygen deleted the test/edit-accuracy-waits-for-held-press branch November 22, 2026 11:27
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