From f1c91a99c040e5e557bc62c7bbe7eb39ad984bd0 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 16 Oct 2026 06:08:53 +0800 Subject: [PATCH] gui: a redraw mid-move keeps the move running and its failure said The redraw comes from renderProviders, for example when an account's allowance read lands (loginUsageOf). It drew a subscription's "Move to the plugin" field again from the provider alone. Midway through a move, the button then said "Move to the plugin" again and took presses: a second move could start while the first ran. A failure that came after the redraw was said into the old field, which was gone, so the user saw nothing. renderMove now keeps the running move's label, and a failure's reason, per provider in moveSaid. A redraw draws both again. A failure that lands after a redraw redraws the providers, so the reason shows in the field on screen. Found while chasing #2431 (plugin-move's editor scrolls 23px in WebKit). That shift was not reproduced: 16 loaded WebKit runs were green, and so were injected late usage, late icons, a busy main thread and a forced chain. The findings are on the issue. This doesn't close #2431. plugin-move.test.cjs now redraws mid-move and after a failure. - Broken by hand: without moveSaid it is red 4 of 4, both engines. The errors are "a redraw mid-move forgot the move" and "a redraw forgot why the move failed". - With the fix: 8 of 8 green, 3 runs. Review: a failure said is kept only while the move's state is the one it failed from, so a move that lands another way (the hourly hand-over) doesn't keep showing it. plugin-move*, fonts: 56/56 in both engines after. Full suite: node --test --test-concurrency=4 internal/gui/tests/*.test.cjs (chromium and webkit) on a61a6f954 with all three of these commits' changes: 10655 tests, 10616 pass, 39 fail, all in 16 top-level tests. Each of their files was then run alone: - green alone on origin/main 008571462 and on this tree (load): import-link-gemini, market-have, plugin-page, readable-focus, text-size. - red alone on main too, filed or commented: - quota-count-wrap and quota-name-translated: #2228 - s3-sync: #2448 - usage-agents-hide: #2276 - usage-checkin: #2142 - usage-fold: #2163 - tray-usages: #2453, new After rebasing onto 008571462, these were run again on this tree, alone: - green: fonts, key-balance-card, plugin-move, i18n-keys. - still red, the same as main: quota-name-translated, quota-count-wrap, tray-usages. The full GUI run was not repeated after the rebase. go test ./internal/gui on 008571462 plus these changes, sandbox HOME: FAIL. The only failure is TestPanelJoinsFullScreenSpaces, which is #2450 and is red on main too. TestCoreScriptBudget passes. --- internal/gui/assets/app.js | 21 +++++++++++++++++---- internal/gui/tests/plugin-move.test.cjs | 9 +++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index b8a7b5fa2..ef52835f8 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -14376,6 +14376,10 @@ function moveWhy(m, p) { // community plugin, and the move between them. The editor stays open // through it: the button says what it is doing, a failure is said under // it, and on success the field turns over where the reader is. +// moveSaid keeps both through a redraw mid-move (an allowance landing): +// drawn from the provider alone, the button took presses again and the +// failure was said into a field drawn over. +const moveSaid = {}; // provider id → { busy } or { why } function renderMove(p) { const m = p.move; const box = el("div", "stack move"); @@ -14387,15 +14391,21 @@ function renderMove(p) { const why = el("div", "move-why"); why.setAttribute("role", "alert"); const say = (text) => { why.textContent = text; why.hidden = !text; }; - const failed = m.state === "failed" && (m.why || m.error); - say(failed ? t("It stays built-in: {error}", { error: moveWhy(m, p) }) : ""); + // a failure said stands only while the move's state is the one it failed + // from: once a move lands another way (the hourly hand-over), it's gone + if (moveSaid[p.id]?.why && moveSaid[p.id].state !== m.state) delete moveSaid[p.id]; + const going = moveSaid[p.id]; + const failed = going?.why || m.state === "failed" && (m.why || m.error) && t("It stays built-in: {error}", { error: moveWhy(m, p) }); + say(failed || ""); const idle = () => onPlugin ? t("Use the built-in again") : failed ? t("Try again") : t("Move to the plugin"); - const b = el("button", "text action", idle()); // a button, not a line of text: it changes what runs the subscription + const b = el("button", "text action", going?.busy || idle()); // a button, not a line of text: it changes what runs the subscription + b.disabled = b.classList.toggle("busy", !!going?.busy); b.onclick = async () => { b.classList.add("busy"); b.disabled = true; say(""); b.textContent = onPlugin ? t("Moving back…") : t("Installing the plugin and checking each account…"); + moveSaid[p.id] = { busy: b.textContent }; try { // the models as the editor shows them picked, when changed and not // saved: the reason a move fails says to untick one there (noting_ever) @@ -14403,6 +14413,7 @@ function renderMove(p) { const was = pickedOf(p); const changed = picks && (picks.length !== was.length || picks.some((id) => !was.includes(id))); providers = await api("provider/" + (onPlugin ? "moveback" : "move"), changed ? { id: p.id, models: picks } : { id: p.id }); + delete moveSaid[p.id]; draft = null; // the provider changed under it renderProviders(); // the editor stays open, turned over, where it was const now = providers.providers.find((x) => x.id === p.id); @@ -14416,7 +14427,9 @@ function renderMove(p) { state = await api("state"); renderAgents(); } catch (e) { - say(onPlugin ? e.message : t("It stays built-in: {error}", { error: moveWhy({ why: e.why, error: e.message }, p) })); + moveSaid[p.id] = { state: m.state, why: onPlugin ? e.message : t("It stays built-in: {error}", { error: moveWhy({ why: e.why, error: e.message }, p) }) }; + if (!box.isConnected) return renderProviders(); + say(moveSaid[p.id].why); b.classList.remove("busy"); b.disabled = false; b.textContent = onPlugin ? t("Use the built-in again") : t("Try again"); diff --git a/internal/gui/tests/plugin-move.test.cjs b/internal/gui/tests/plugin-move.test.cjs index 3ece1fb5d..7204b6305 100644 --- a/internal/gui/tests/plugin-move.test.cjs +++ b/internal/gui/tests/plugin-move.test.cjs @@ -146,6 +146,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await press(); await page.waitForFunction((busy) => [...document.querySelectorAll("#modal .move button")].some((b) => b.textContent === busy), w.busy, { timeout: 300 }); assert.equal(await btn.isDisabled(), true, "the button can be pressed again mid-move"); + // an account's allowance landing mid-move redraws the editor + // (loginUsageOf): the move is still said to run, and its end is said + // in the field drawn now + await page.evaluate(() => renderProviders()); + assert.equal(await btn.innerText(), w.busy, "a redraw mid-move forgot the move"); + assert.equal(await btn.isDisabled(), true, "a redraw mid-move lets the button be pressed again"); // it fails: said under the button, the editor open where it was const why = ed.locator(".move-why"); @@ -154,6 +160,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.equal(await btn.innerText(), w.again); assert.equal(await btn.isDisabled(), false); assert.equal(await body.evaluate((e) => e.scrollTop), top, "the failure moved the editor"); + await page.evaluate(() => renderProviders()); + assert.equal(await why.innerText(), w.failed, "a redraw forgot why the move failed"); + assert.equal(await btn.innerText(), w.again); if (process.env.ARTIFACT_DIR) await ed.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-move-failed-${engine}-${lang}.png`) }); // tried again, it goes through: the same editor, turned over