gui: the open provider editor holds still as allowances come in (#3492)

congee949 (#3492, Playwright on v0.1.1403's assets, a fixture of five
accounts and 16 models): with a subscription's editor open, the whole
dialog, its head and buttons too, went to opacity .5 and 2px down and
came back as its accounts' allowances came in, for an empty answer
({}) as well. The editor reads them (loginUsageOf) as it is drawn, and
the read's end draws it again (renderProviders). openModal took every
redraw of an open dialog for new content and played the soft refresh
it gives one (.dialog.swap: content-in, 220ms from opacity .5 and
translateY(2px)).

That redraw is now a quiet one: loginUsageOf's finally calls
renderProviders(true), renderProviders hands it to openModal, and
openModal adds no swap for it. The rest of the redraw is as before: the
body keeps its scroll, the focus stays on its control and the dialog
keeps its place (holdModal). Every other call of renderProviders and
openModal passes nothing and does as before. The issue's other way,
filling in only the allowances, would take a second way of drawing an
account's meters and its at-its-cap note beside the editor's own; this
keeps the one. app.js is 33 bytes bigger (1,309,476 of its 1,310,460;
the core's scripts 1,525,572 of 1,526,556), no budget raised. On
origin/main 1a804859 app.js is 1,309,717, so its budget has room, but
the core's scripts are 1,526,548, so coreScriptBudget needs 25 bytes
more for this.

Why the caller says so, and not openModal by comparing the old content
with the new: the allowances coming in and a change the reader makes
in the same editor (an account switched on or off, made first,
renamed) both draw the editor again under the same title, and the swap
is for the second. Of the redraws of an open dialog that no press
starts, only this one draws the same content again:
- a sign-in being followed (followSignIn) draws again only when its
  state, link or code changed, which is new content;
- the list's poll while models are fetched (providersWhileFetching)
  and the window coming back (load) skip an open editor;
- Check balance, a plugin page's buttons and README, a request's
  context text and the update notes fill their dialog in place;
- What's new and the CLI's note open only on a closed dialog.
Every other redraw of an open dialog follows a press: a question and
back, a switch, a sign-in started, an account or a key changed.

account-eye.test.cjs now moves the pointer off the rows before it
checks that an account's eye is quiet with Hide accounts on. The click
on the list's ZCode row leaves the pointer at 180,204, and in the
360px editor the Personal account's name is drawn at y 204 to 221, so
its eye shows. On main the WebKit check passed only because the
allowances' redraw had just started its swap, still on its first
frame when the check ran: the dialog was 2px lower, with the name at
206 to 223. With that redraw quiet, the test as it was is red in
WebKit in en, zh, zh-TW and ja; de's name sits lower (227 to 244).

Not changed: a read that ends while an account is being moved waits
for the move to be saved (accountRenderPending) and is drawn with the
move's own redraw, which plays the swap as any change the reader
makes does. A read that ends while Codex's Sign out question is up
puts the editor back over the question, here as on main (#3943).

What was run (tree fb30c3f4, on origin/main f8cd964a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- editor-quota-quiet.test.cjs (new; Node 22.22.1, Playwright 1.58.2),
  Chromium and WebKit, en and zh: 3 runs at load 22 to 29, 12 of 12
  each
- the same test with f8cd964a's app.js and app.css: 8 of 12 red, both
  answers in both engines and languages, each at opacity 0.5 as the
  class changed. Chromium: "the dialog dimmed or moved as the
  allowances came in: its opacity 0.5 content-in as its class changed,
  0.5 at its lowest over 5 frames, its top from 16 to 18px". WebKit's
  frames read it later in its 220ms: 0.95 to 0.99 at their lowest, its
  top up to 16.2px. The 4 switch cases ok.
- broken by hand, each alone in a scratch worktree, both engines:
  - loginUsageOf's finally calling renderProviders() again: the same
    8 red
  - renderProviders not handing it on (openModal(dialog)): the same 8
  - openModal not reading it (if (!fresh)): the same 8
  - openModal never swapping (if (false)): the 4 switch cases red,
    "the dialog turned to the question without its swap:
    [{"opacity":1,"anims":[]}]"
  - .dialog.swap's animation set to none in app.css: the same 4
- account-eye.test.cjs, both engines: 2 runs, 30 of 30 each; with
  f8cd964a's app.js and app.css, 30 of 30. As it is at f8cd964a, at
  this tree: red in WebKit's en, zh, zh-TW and ja editor cases, the
  eye at opacity 1 where 0 is wanted. With app.css showing the eye
  always (opacity 1): 30 of 30 red, the editor's on that same check.
- the 214 GUI files that name the modal (#modal, .modal or
  openModal), open a provider's editor, answer /api/login/usage or
  name the swap, and window-mask: each alone, Chromium then WebKit,
  four at a time at load 27 to 72: 411 of 428 runs ok. Each red file
  was run again alone, here and on f8cd964a in turn: red on both with
  the same cases, but for the last two, which come and go:
  - account-arrange, Chromium: the key rename's page error (#3944)
  - update-notes-ask (3 en cases) and whats-new, WebKit:
    "ResizeObserver loop completed with undelivered notifications." as
    a page error (#3942)
  - plugin-github, WebKit, de 440: a click scrolls #view-plugins (55
    to 121), the check #3218 is about
  - vertex-editor, WebKit zh: "a Vertex AI row names its Google
    credentials" and its pills and fields fitting a narrow window and
    browser (a file #1671 names)
  - copilot-signed-out-account (20 cases), revoked-signin-account (10)
    and agent-failover (10), WebKit: innerText read with a newline at
    its end ("Signed out\n") or start, in this box's WebKit (Playwright
    1.58.2; the tests' README names 1.62.1)
  - session-identity, both engines, en light and dark: "both badges
    share one row below the account at 440"
  - usage-ledger, both engines, en and zh: "newest live route needs no
    return-to-live button"
  - provider-remove, WebKit zh: "the Remove click didn't push the page
    down"
  - readable-focus, WebKit: "Tab's focused field stays in sight"
  - modal-centred-late, WebKit, 820px and 560px: "grew over frames"
  - mcp-oauth-app, Chromium, de 390: the box's Cancel sent no cancel.
    Alone, red 2 of 6 runs here and 1 of 12 on f8cd964a: a Cancel
    pressed while the sign-in is still opening (#3984)
  - found-skill-pick-remove, WebKit, en 420: a click moved
    #view-library by 1px; alone, ok 2 of 2 here and on f8cd964a
- go test -tags nogui -count=1 -timeout 45m ./... (tools/suite.sh, Bun
  1.4.2): 69 packages ok and 7 red, none in what this changes: agent
  TestCodexDriftReached (#3398), TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141), the two Reasonix tests (#3641) and
  TestWSLColdPlaceOpensNothing (#3924); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
  #3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649), TestCoreScriptBudget ok; provider TestCodexAppServersOnHome
  (#3906), then "close of synctest channel from outside bubble"
  (#3632); tui TestTUIFetchesSubscriptionModels/agent (#3919)
- On origin/main 1a804859 with this commit cherry-picked (a scratch
  worktree, not this tree): editor-quota-quiet and account-eye, both
  engines, 42 of 42
Not run: gofmt, vet and the builds; no Go file changes.

Not tried: the real app's webviews (WebKitGTK, WKWebView, WebView2)
and a real subscription's allowance read; the fixture is the
reporter's. Whether every flash in the Qoder recording the issue
started from was this one; the recording wasn't posted.

Review (yetone, at this commit on origin/main bb5e68cea, after
09e09e994 made the 25 bytes' room without raising coreScriptBudget):
- The test moved onto today's editor: since 18005c803 an account's
  buttons, Sign out among them, sit under its ⋯ and the reporter's
  editor fits 1015px whole, so the window is 760 high (251px to
  scroll), the focus is on an account's ⋯, the swap case opens ⋯
  before Sign out, and the focus is matched by its row, class and
  words, not its index, which moves as each account's own refresh
  (923812362) comes in above it. That redraw goes through loginUsageOf
  too, so it is quiet as well.
- Linux (WSL magpie-desktop, Playwright 1.62.0), Chromium and WebKit,
  en and zh: editor-quota-quiet 12 of 12; on main bb5e68cea with only
  the test added, 8 red ("its opacity 0.5 content-in as its class
  changed ... its top from 16 to 18px"), the 4 swap cases ok.
- Broken by hand, Linux: finally's renderProviders(true) back to
  renderProviders(): 8 red; openModal not reading quiet: 8 red;
  openModal never swapping: the 4 swap cases red.
- go test -tags nogui -run Budget ./internal/gui ok on macOS (mote).
- The 94 GUI files this can reach (those with logins, a provider row or
  editor, the swap, the modal, i18n-keys, gui-de, gui-ja, gui-zh-tw and
  sessions-row-narrow), both engines, Linux, 6 at a time: 1725 of 1745
  ok. The red files were run again, 2 at a time, on main with only the
  new test added and at this tree. The reds are the same on both:
  - i18n-keys "Unmarked" (#4524)
  - modal-centred-late in WebKit (#4116)
  - plugin-move-unserved Try again (#4392, #4410)
  - plugin-move "for good" in WebKit (#4471)
  - routing-cline-route in WebKit (#4121)
  - usage-ledger Requests (#4120)
  - session-identity in WebKit, 3 of 3 on both (#4567, filed now)
  account-arrange's WebKit red in the full run passed in both reruns.
Not verified: macOS. On mote at load 25, every browser launch timed
out (180s), so that run tested nothing. Also not tried: the real
Wails webviews, and a real allowance read.

At the pushed tree (rebased on origin/main 7e0fe83d4), Linux, both
engines: editor-quota-quiet and account-eye ok, i18n-keys red only on
#4524; go test -tags nogui -run Budget ./internal/gui ok on mote.
This commit is contained in:
JoeyWu-tech
2026-10-31 18:52:01 +08:00
committed by yetone
parent 79d2379d66
commit a9154b170a
4 changed files with 190 additions and 5 deletions
+5 -5
View File
@@ -6078,7 +6078,7 @@ $("#foldOff").onclick = () => {
// One row per provider: logo, name, the agents pointed at it, key status.
// Everything else lives in the editor, a dialog over the page.
function renderProviders() {
function renderProviders(quiet) {
if (accountArranging || providerArranging) { accountRenderPending = true; return; }
// Rebuilding the list empties the page for a moment, which clamps its
// scroll to the top; put it back so closing the editor leaves the reader
@@ -6186,7 +6186,7 @@ function renderProviders() {
keptIcons = null;
markUpstream();
view.scrollTop = top; // first: a closing dialog folds into its row where it is
if (dialog) openModal(dialog); else closeModal();
if (dialog) openModal(dialog, quiet); else closeModal();
}
// providerHandle is an on row's logo, which is also its handle (#499):
@@ -8701,7 +8701,7 @@ function holdModal(later) {
// a scroll moves the marked element, not the dialog
m.addEventListener("scroll", () => modalMark(modalHold.at), true);
}
function openModal(content) {
function openModal(content, quiet) {
const m = $("#modal"), d = m.firstElementChild;
const fresh = m.hidden || m.classList.contains("out");
const top = m.hidden ? 0 : d.querySelector(".ebody")?.scrollTop || 0;
@@ -8710,7 +8710,7 @@ function openModal(content) {
const namesAt = names && { provider: names.dataset.provider, top: names.scrollTop };
m.classList.remove("out");
d.classList.remove("swap");
if (!fresh) { void d.offsetWidth; d.classList.add("swap"); } // content changed: a soft refresh, not a re-entrance
if (!fresh && !quiet) { void d.offsetWidth; d.classList.add("swap"); } // content changed: a soft refresh, not a re-entrance
frame(content);
// an editor of long text (a prompt's) takes a wider dialog
d.classList.toggle("wide", content.classList.contains("wide"));
@@ -13459,7 +13459,7 @@ function loginUsageOf(agent) {
.then((d) => { u.data = d || {}; }, () => { u.data = u.data || {}; })
.finally(() => {
u.at = Date.now(); u.loading = null;
if (providers?.providers.find((p) => p.id === editing)?.account?.agent === agent && !document.querySelector(".editor .rename-in, .editor input:focus, .signing.import textarea:focus")) renderProviders();
if (providers?.providers.find((p) => p.id === editing)?.account?.agent === agent && !document.querySelector(".editor .rename-in, .editor input:focus, .signing.import textarea:focus")) renderProviders(true);
});
}
return u.data;
+9
View File
@@ -1044,6 +1044,15 @@ over the model chips runs them to the last one and then takes the editor's
body on to its end, where the chips' held ends stopped it; the page never
moves. In Chromium and WebKit, English and Chinese.
`editor-quota-quiet.test.cjs` holds a subscription's allowance read
(/api/login/usage) while its editor opens, then lets it answer, empty and
with meters, in congee949's fixture (#3492: five accounts, 16 models,
1960x1015): the editor drawn again for it keeps the dialog at opacity 1
and its top in every frame, its body's scroll and the focus, where the
whole dialog played its swap from opacity .5 and 2px down. Codex's only
account's Sign out, and Cancel back to the editor, still play the swap.
In Chromium and WebKit, English and Chinese.
`group-from-model-add.test.cjs` opens the Routing page on a new group made
from a model (?newgroup=, as "Make a routing group of it" does; 悠悠哥 on
Discord: "Hy4 preview" did nothing on Add in a small window). Each label
+3
View File
@@ -105,6 +105,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator(".row.provider", { hasText: "ZCode" }).first().click();
const row = (id) => page.locator(`.editor .accts .acc[data-account-id="${id}"]`);
await row(TEAM).locator(".acct-who").waitFor();
// the pointer off the rows: the click that opened the editor left it
// on ME's name at 360px
await page.mouse.move(0, 0);
const eye = (id) => row(id).locator(".acct-eye");
// Hide accounts off: no eye at all
@@ -0,0 +1,173 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// A provider's accounts get their allowances from a read of their own, and
// the open editor is drawn again when it comes in (loginUsageOf). That
// redraw is nothing the reader did, so the dialog doesn't play the soft
// refresh a change of its content gets (.dialog.swap, content-in from
// opacity .5 and 2px down): congee949 saw the whole dialog, its head and
// buttons too, dim and drop and come back as the read came in, an empty
// answer too (#3492). Here every frame from the answer until well after
// the redraw keeps the dialog at opacity 1 and its top where it was, and
// the body keeps its scroll and the focus, for an empty answer and for
// one that fills the meters in. A change the reader makes still plays
// it: Codex's only account's Sign out turns the dialog to its question,
// and Cancel turns it back to the editor. The reporter's fixture (five
// accounts, 16 models, 1960 wide, dark; 760 high, as since an account's
// settings went under its ⋯ that editor fits 1015 whole and its body has
// nothing to scroll); Chromium and WebKit, English and Chinese, the API
// faked.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const accounts = Array.from({ length: 5 }, (_, i) => ({ user: `account-${i + 1}@example.invalid`, active: i === 0, on: true, plan: "personal_standard" }));
const fakeco = { id: "fakeco", name: "FakeCo", icon: "generic", models: Array.from({ length: 16 }, (_, i) => ({ id: `model-${i + 1}`, on: i % 2 === 0 })), agents: [], key: {}, routing: "smart",
account: { agent: "fakeco", agentName: "FakeCo", agentIcon: "generic", user: accounts[0].user, logins: accounts } };
const SOLO = "solo@example.invalid";
const codex = { id: "codex", name: "Codex", icon: "codex", models: [{ id: "gpt-6", on: true }], agents: [], key: {},
account: { agent: "codex", agentName: "Codex", agentIcon: "codex", user: SOLO, logins: [{ user: SOLO, plan: "plus", active: true, on: true }] } };
const plugins = [{ id: "fakeco", pid: "fakeco", name: "FakeCo", icon: "generic", spec: "fakeco-fixture", signedIn: true, models: 16, methods: [{ type: "oauth", label: "Browser sign-in" }] }];
const inHours = (h) => new Date(Date.now() + h * 36e5).toISOString();
// the reporter's empty answer, and one with each account's two windows
const answers = {
empty: () => ({}),
meters: () => Object.fromEntries(accounts.map((a, i) => [a.user, { provider: "fakeco", windows: [{ name: "5 hours", used: 10 + 15 * i, resetsAt: inHours(3) }, { name: "Weekly", used: 5 * i, resetsAt: inHours(100) }] }])),
};
function serve(lang, usage) {
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"dark",web:false};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "dark" } });
if (url.pathname === "/api/providers") return json({ providers: [fakeco, codex], presets: [], excluded: [], gateway: { running: true, window: true }, plugins });
if (url.pathname === "/api/login/usage") return json(await usage(url.searchParams.get("agent")));
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
if (url.pathname.startsWith("/api/")) return json({});
if (!/^\/[\w./-]*$/.test(url.pathname) || url.host !== "magpie.test") return route.fulfill({ status: 404, body: "" });
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
};
}
async function openEditor(browser, lang, id, usage) {
const page = await (await browser.newContext({ viewport: { width: 1960, height: 760 }, reducedMotion: "no-preference" })).newPage();
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, usage));
await page.goto("http://magpie.test/?view=providers");
await page.locator(`.row.provider[data-id="${id}"]`).click();
await page.locator("#modal .ebody").waitFor();
// the open's grow and fade over: what moves after is the redraw's
await page.waitForFunction(() => { const m = document.querySelector("#modal"); return !m.getAnimations().length && !m.firstElementChild.getAnimations().length; });
return { page, errors };
}
// From here every frame's opacity and top of the dialog and its body's
// scroll, until `until` holds and 400ms more, past the swap's 220ms; and
// the opacity read as its class changes, before any frame, so a frame
// late under load still sees a swap begin.
const watch = (page, until) => page.evaluate((until) => {
const d = document.querySelector("#modal .dialog"), was = d.querySelector(".ebody");
const seen = window.seen = { frames: [], atClass: [], at: 0, done: false };
new MutationObserver(() => seen.atClass.push({ opacity: +getComputedStyle(d).opacity, anims: d.getAnimations().map((a) => a.animationName || "") }))
.observe(d, { attributes: true, attributeFilter: ["class"] });
const step = (now) => {
const body = d.querySelector(".ebody");
seen.frames.push({ opacity: +getComputedStyle(d).opacity, top: d.getBoundingClientRect().top, scroll: body?.scrollTop });
if (!seen.at && (until === "redrawn" ? body && body !== was : d.querySelector(until))) seen.at = now;
if (seen.at && now - seen.at > 400) { seen.done = true; return; }
requestAnimationFrame(step);
};
requestAnimationFrame(step);
}, until);
const watched = async (page, what) => {
await page.waitForFunction(() => window.seen.done).catch(() => assert.fail(`${what} never came, so this tested nothing`));
return page.evaluate(() => window.seen);
};
// the focused element as a redraw that keeps it finds it again: its row,
// its kind and its words (its place among the dialog's controls moves, as
// the allowances bring each account's own controls in above it)
const focused = (page) => page.evaluate(() => {
const d = document.querySelector("#modal .dialog"), a = document.activeElement;
return { row: a.closest(".acc")?.dataset.accountId, kind: d.contains(a) ? a.className : "", text: a.textContent };
});
const W = {
en: { signOut: "Sign out", cancel: "Cancel", ask: `Sign Codex out of ${SOLO}?` },
zh: { signOut: "退出登录", cancel: "取消", ask: `让 Codex 退出 ${SOLO}?` },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
for (const answer of ["empty", "meters"]) {
test(`${engine} ${lang}: the allowances coming in (${answer}) don't dim or move the open editor`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
let release;
const held = new Promise((r) => { release = r; });
const { page, errors } = await openEditor(browser, lang, "fakeco", async () => { await held; return answers[answer](); });
// read down the body a way, a control in it focused, as the reporter scrolled
const before = await page.evaluate(() => {
const d = document.querySelector("#modal .dialog"), body = d.querySelector(".ebody");
body.scrollTop = 120;
[...d.querySelectorAll(".acc .acc-more")].at(-2).focus({ preventScroll: true });
return { scroll: body.scrollTop, room: body.scrollHeight - body.clientHeight, waiting: d.querySelectorAll(".aq .skeleton").length };
});
assert(before.scroll > 0, `the body scrolls, so its scroll is something to keep: ${JSON.stringify(before)}`);
assert(before.waiting > 0, `the allowances are still on their way: ${JSON.stringify(before)}`);
const focus = await focused(page);
assert(focus.kind === "acc-more" && focus.row, `a control in an account's row has the focus: ${JSON.stringify(focus)}`);
await watch(page, "redrawn");
release();
const seen = await watched(page, "the editor's redraw for the allowances");
assert.equal(await page.locator("#modal .aq .skeleton").count(), 0, "the allowances are drawn in");
const low = Math.min(...seen.frames.map((f) => f.opacity)), tops = seen.frames.map((f) => f.top);
t.diagnostic(`${seen.frames.length} frames, opacity ${low} at the lowest, top ${Math.min(...tops)} to ${Math.max(...tops)}px, scroll ${before.scroll}`);
assert(low === 1 && seen.atClass.every((c) => c.opacity === 1) && Math.max(...tops) - Math.min(...tops) < 0.5,
`the dialog dimmed or moved as the allowances came in: its opacity ${seen.atClass.map((c) => [c.opacity, ...c.anims].join(" ")).join(", ")} as its class changed, `
+ `${low} at its lowest over ${seen.frames.length} frames, its top from ${Math.min(...tops)} to ${Math.max(...tops)}px`);
const scrolls = [...new Set(seen.frames.map((f) => f.scroll))];
assert.deepEqual(scrolls, [before.scroll], "the body keeps its scroll");
assert.deepEqual(await focused(page), focus, "the focus stays on its control");
assert.deepEqual(errors, []);
});
}
test(`${engine} ${lang}: a change the reader makes still plays the dialog's swap`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const w = W[lang];
const { page, errors } = await openEditor(browser, lang, "codex", answers.empty);
// its allowance read in and drawn first, so the swaps below are the clicks'
await page.locator("#modal .acc .aq .aq-none").waitFor();
await page.waitForFunction(() => !document.querySelector("#modal .dialog").getAnimations().length);
// Sign out waits under the account's ⋯, which opens in place; it asks
// first, in the same dialog
await page.locator("#modal .acc .acc-more").click();
await watch(page, ".forget-ask");
await page.locator("#modal .acc button", { hasText: w.signOut }).click();
let seen = await watched(page, "Sign out's question");
assert.equal(await page.locator("#modal .forget-ask .ehead b").textContent(), w.ask);
// read as the class changes: a frame comes when it will, and under
// load one may come after the swap's 220ms
const swapped = (s) => s.atClass.some((c) => c.opacity < 0.9 && c.anims.includes("content-in"));
assert(swapped(seen), `the dialog turned to the question without its swap: ${JSON.stringify(seen.atClass)}`);
// Cancel goes back to the editor, as a change of content too
await page.waitForFunction(() => !document.querySelector("#modal .dialog").getAnimations().length);
await watch(page, ".acc");
await page.locator("#modal .forget-ask button", { hasText: w.cancel }).click();
seen = await watched(page, "the editor after Cancel");
assert(swapped(seen), `the dialog turned back to the editor without its swap: ${JSON.stringify(seen.atClass)}`);
assert.deepEqual(errors, []);
});
}
}