Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: a Settings option pressed through two redraws clicks its newest self (#3922)
yetone761e0e0105cd
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 4b8492b88..ee7c25578 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -6837,7 +6837,8 @@ addEventListener("pointerup", (e) => {addEventListener("click", seen, true);setTimeout(() => {removeEventListener("click", seen, true);- if (!clicked && b.isConnected) b.click();+ // its newest self: b, or what a draw since put there (#3922)+ if (!clicked) [...document.querySelectorAll(".segs")].find((x) => segsWho(x) === p.who)?.querySelectorAll(":scope > .opt")[p.i]?.click();});}, true);diff --git a/internal/gui/tests/README.md b/internal/gui/tests/README.mdindex c5f919acb..61cdf39ca 100644--- a/internal/gui/tests/README.md+++ b/internal/gui/tests/README.md@@ -874,7 +874,10 @@ node --test --test-concurrency=1 internal/gui/tests/settings-sections.test.cjs i(`renderSettings()`, as a save's answer does) while the button is held andlets go on the same spot: Lightweight mode → On is posted once and shown on.Dragged off to the other option, or to the same option of another control,-nothing is posted, and a plain click is posted once, not twice. It then+nothing is posted, and a plain click is posted once, not twice. Drawn+again once more after it is let go and before the click that sets off,+as Browser access is when the answer to its state comes then (#3922),+On is posted once. It thenpresses every option control on every Settings tab (49 in English, thewarm-up, check-in, sync and local network ones included) the same way andchecks that the control drawn in its place is clicked once on the samediff --git a/internal/gui/tests/segs-press-redraw.test.cjs b/internal/gui/tests/segs-press-redraw.test.cjsindex d6766263c..70781487a 100644--- a/internal/gui/tests/segs-press-redraw.test.cjs+++ b/internal/gui/tests/segs-press-redraw.test.cjs@@ -6,8 +6,11 @@// and nothing was saved. Pressed, redrawn and let go on the same option,// Lightweight mode → On is saved once; dragged off to another option, or to// the same option of another control, nothing is; a click with no redraw-// is saved once. Every segs control on every Settings tab is pressed the-// same way and its new self clicked once. Chromium and WebKit, in English,+// is saved once. Pressed, redrawn, let go and redrawn again before its+// click comes, as a draw that asks for its state draws once more with the+// answer (Browser access, #3922), the newest On is saved once. Every segs+// control on every Settings tab is pressed the same way and its new self+// clicked once. Chromium and WebKit, in English,// Chinese, Japanese and German, in a wide and a narrow window, the API faked.const assert = require("node:assert/strict");const fs = require("node:fs/promises");@@ -65,18 +68,35 @@ async function open(engine, lang, width, tab, posted, st, t, touch = false) {const settle = (page) => page.evaluate(() => new Promise((ok) => setTimeout(ok, 80)));// brought out from under the header and the foot by the reader's wheel, as-// code's scrolls are put back, till the pointer at its middle is on it+// code's scrolls are put back, till the pointer at its middle is on it.+// Each wheel's scroll lands before the option is looked at again: WebKit's+// glides on for some 200ms (a wheel of 150px is at 9, 111, 142, 149 and+// 150 by its frames), and a box read on the way was pressed where the+// option had been, off it (#3922)async function reveal(page, loc) {for (let i = 0; i < 40; i++) {const b = await loc.boundingBox();const h = page.viewportSize().height;if (b && await loc.evaluate((o, [x, y]) => o.contains(document.elementFromPoint(x, y)), mid(b))) return b;await page.mouse.move(page.viewportSize().width / 2, h / 2);+ const was = await page.evaluate(() => document.getElementById("view-settings").scrollTop);await page.mouse.wheel(0, b && b.y < h / 2 ? -150 : 150);- await page.waitForTimeout(60);+ await landed(page, was);}throw new Error("could not bring the option into view");}+// landed: Settings' view moved from where it was and then held still for+// three frames in turn, or didn't move in a second (it is at its end)+const landed = (page, was) => page.evaluate((was) => new Promise((ok) => {+ const v = document.getElementById("view-settings"), t0 = performance.now();+ let last = v.scrollTop, still = 0;+ const frame = () => {+ still = v.scrollTop === last ? still + 1 : 0;+ last = v.scrollTop;+ if (last !== was ? still >= 3 : performance.now() - t0 > 1000) ok(); else requestAnimationFrame(frame);+ };+ requestAnimationFrame(frame);+}), was);const mid = (b) => [b.x + b.width / 2, b.y + b.height / 2];for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {@@ -147,6 +167,21 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await page.waitForTimeout(300);assert.deepEqual(saves(), [true, false], `posted ${JSON.stringify(posted)}`);assert.equal(await on(), w.off);++ // pressed, redrawn, let go, and redrawn again before the click it+ // set off comes, as Browser access is when its state's answer lands+ // then (#3922): the newest On is clicked, once+ await page.mouse.move(...mid(await reveal(page, opt("lightweightSegs", w.on))));+ await page.mouse.down();+ await page.evaluate(() => {+ renderSettings();+ addEventListener("pointerup", () => renderSettings(), { capture: true, once: true });+ });+ await page.mouse.up();+ for (let i = 0; i < 40 && saves().length < 3; i++) await page.waitForTimeout(50);+ await page.waitForTimeout(300);+ assert.deepEqual(saves(), [true, false, true], `redrawn twice, posted ${JSON.stringify(posted)}`);+ assert.equal(await on(), w.on);assert.deepEqual(errors, []);});