fix(studio): the edit bench waits out the preview swap once a plain element gains keyframes (#8113)

This commit is contained in:
Miguel Ángel
2026-11-17 21:36:28 +00:00
committed by GitHub
parent b930c4d2d7
commit ba62d77489
4 changed files with 45 additions and 13 deletions
@@ -315,7 +315,9 @@ const previewFrames = (page) =>
async function hiddenTarget(page, selector = "#target") {
for (const f of page.frames().filter((f) => f.url().includes("/preview"))) {
const host = await f.frameElement().catch(() => null);
const shown = await host?.evaluate((e) => e.checkVisibility({ visibilityProperty: true }));
const shown = await host
?.evaluate((e) => e.checkVisibility({ visibilityProperty: true }))
.catch(() => null);
if (shown === false && (await f.$(selector).catch(() => null))) return true;
}
return false;
@@ -55,17 +55,7 @@ export function bankable(runs) {
* Cases a real Studio race flips run to run, with the PR fixing it: measured and listed every run, never gated.
* The fixing PR deletes its own ids here and re-banks them in the same PR.
*/
export const QUARANTINED = {
// Undo or redo of a keyframed plain element restores the bytes but sometimes leaves the box 230-400px off.
"seqplainkeys-none-center-r0-nested-z100": "#6989",
"seqplainkeys-none-center-r0-root-z100": "#6989",
"seqplainkeys-none-center-r30-root-z100": "#6989",
"seqplainkeys-none-pct-r0-root-z100": "#6989",
"seqplainkeys-none-pct-r30-root-z100": "#6989",
"seqplainkeys-none-px-r0-nested-z100": "#6989",
"seqplainkeys-none-px-r30-nested-z100": "#6989",
"seqplainkeys-none-px-r30-root-z100": "#6989",
};
export const QUARANTINED = {};
/**
* Every run of every case: each shard's run plus the re-runs of the cases it flipped. `scope`, for a run of
@@ -423,6 +423,13 @@ function rememberBox(step, state, m) {
}
/** Under auto-record, size keys hold their nearest value before the first and after the last. */
/** An element that gains keyframes mid-sequence is keyframed from then on: its settles wait out Studio's swap. */
export function keyedBy(ctx, step, state) {
const writesKeys = step.do === "addkey" || (step.do === "drag" && state.autokey);
const c = ctx[step.element ?? "A"];
if (writesKeys && c && !c.keys) c.keys = true;
}
export function heldSize(sizeKeys, time) {
const times = [...sizeKeys.keys()].sort((a, b) => a - b);
if (!times.length) return undefined;
@@ -496,6 +503,7 @@ async function measureSequence({ spec, dir, files, evidence }, session, control,
for (const step of spec.steps) {
if (step.do !== "drag") await collect();
steps.push(await driveStep(ctx, step, state));
keyedBy(ctx, step, state);
if (spec.settle) await settleStep(ctx.A, steps, step, state, watcher);
}
// Every saving step saves once (a nudge burst saves once); wait for all of them. An undo may
@@ -12,7 +12,7 @@ import {
swapPending,
unsettledBy,
} from "./case.mjs";
import { heldSize } from "./sequences.mjs";
import { heldSize, keyedBy } from "./sequences.mjs";
describe("settling on the shown preview", () => {
const read = (pending, x = 0, frames = "a") => ({
@@ -53,6 +53,19 @@ describe("settling on the shown preview", () => {
expect(await swapPending({ page: page(frame("/studio", false, true)), keys })).toBe(false);
});
it("reads a preview that went away mid-read as holding nothing, not as an error", async () => {
const gone = {
url: () => "/preview/a?_t=1",
frameElement: async () => ({
evaluate: async () => {
throw new Error("Attempted to use detached Frame");
},
}),
$: async () => ({}),
};
expect(await swapPending({ page: page(gone), keys })).toBe(false);
});
it("calls a swap pending while Studio says the preview is changing, with no hidden preview yet", async () => {
const changing = (on) => ({ frames: () => [], evaluate: async () => on });
expect(await swapPending({ page: changing(true), keys })).toBe(true);
@@ -66,6 +79,25 @@ describe("settling on the shown preview", () => {
});
});
describe("a plain element that gains keyframes mid-sequence", () => {
const changing = { frames: () => [], evaluate: async () => true };
const plain = () => ({ A: { page: changing }, B: { page: changing } });
it("waits out Studio's swap from the step that writes its first keyframe", async () => {
const ctx = plain();
keyedBy(ctx, { do: "drag" }, { autokey: false });
expect(await swapPending(ctx.A), "a drag with auto-keyframe off writes none").toBe(false);
keyedBy(ctx, { do: "addkey" }, { autokey: false });
expect(await swapPending(ctx.A)).toBe(true);
});
it("keys the element a drag with auto-keyframe on moved, and only that one", async () => {
const ctx = plain();
keyedBy(ctx, { do: "drag", element: "B" }, { autokey: true });
expect([await swapPending(ctx.A), await swapPending(ctx.B)]).toEqual([false, true]);
});
});
describe("settling on the page's network", () => {
const read = (busy, activity) => ({
pending: false,