From 96115018cf610715b906b6458efdf10c65b08beb Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 28 Oct 2026 22:55:23 +0800 Subject: [PATCH] gateway: a key's Limit and Models keep their room unhovered (#4072) f835bd713 gave the Gateway page's key list the Providers keys list's class (.accts.keys), whose rules squeeze Models, Limit and the quiet words to no width until the row is hovered. On the Gateway page that left Limit at 0px wide: Playwright called it "not visible", and a real row reflowed sideways under the pointer. The list is .accts.gw-keys only now; narrow, the masked key gives up its room first (flex 0 6, ellipsis, 3em at least) before the key's name does. Tests brought up to the redesign: - gateway-older and web-page waited on #gateway .dot, gone since f835bd713; they wait on the mark (#gateway > .gw-mark). - gateway-key-limit's window is 560 tall, not 420: in webkit the limit editor ended at 462px, so Playwright's own check() scrolled the box into view and the test read that as "Cancel moved the page". Run at this head on mote (both engines, en+zh where the files have it): gateway-*.test.cjs (all 26), web-page, api-key-theme, click-scroll, i18n-keys: all pass except the 560-wide reads right after a resize that are already filed (#3523 key-limit, #3797 caller-keys, and key-models' same check). go test ./internal/gui -run Budget: ok. Broken by hand: with the keys class put back, gateway-key-cycle and gateway-key-limit go red on "element is not visible". Not tried: the real app on Windows and Linux. --- internal/gui/assets/app.css | 6 ++++-- internal/gui/assets/plugins/gateway/keys.js | 2 +- internal/gui/tests/gateway-key-limit.test.cjs | 2 +- internal/gui/tests/gateway-older.test.cjs | 4 ++-- internal/gui/tests/web-page.test.cjs | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 58965acb6..600ff792f 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -2331,8 +2331,10 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; } /* a gateway key: the copy right beside the masked key, the rest under its … (the owner: a copy out in the row's middle looked lost) */ .gw-keys .acc > .plan + .copy { margin-left: -5px; } -/* narrow, the masked key gives up its room before the key's name does */ -.gw-keys .acc > .plan { flex-shrink: 6; } +/* narrow, the masked key gives up its room before the key's name does. + Not the Providers keys list's rules (.accts.keys): Limit and Models keep + their room there while hidden, so a hover doesn't push the row about */ +.gw-keys .acc > .plan { flex: 0 6 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; } .gw-keys .gw-key-more { flex: none; color: var(--muted); } .gw-keys .gw-key-more:is(:hover, .open) { color: var(--fg); } #view-gateway .row-head, #view-usage .row-head { margin: 14px 0 6px; padding: 0 2px; } diff --git a/internal/gui/assets/plugins/gateway/keys.js b/internal/gui/assets/plugins/gateway/keys.js index 0f45f0eac..433d76df2 100644 --- a/internal/gui/assets/plugins/gateway/keys.js +++ b/internal/gui/assets/plugins/gateway/keys.js @@ -207,7 +207,7 @@ function renderGatewayKeys() { $("#addGatewayKey").onclick = () => { gatewayKeyDraft = ""; renderGatewayKeys(); }; // keys: a badge left unset folds away until the row is pointed at, as // on a provider's keys, so nothing invisible holds a place in the row - const list = el("div", "accts keys gw-keys"); + const list = el("div", "accts gw-keys"); if (gatewayKeys === null) { if (gatewayKeysErr) list.append(el("div", "none", t(gatewayKeysErr))), box.append(list); return; diff --git a/internal/gui/tests/gateway-key-limit.test.cjs b/internal/gui/tests/gateway-key-limit.test.cjs index 8cefc136f..36f576a50 100644 --- a/internal/gui/tests/gateway-key-limit.test.cjs +++ b/internal/gui/tests/gateway-key-limit.test.cjs @@ -24,7 +24,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", test(`${engine} ${lang}: a gateway key's limit is shown and set with Save`, async (t) => { const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); t.after(() => browser.close()); - const page = await (await browser.newContext({ viewport: { width: 1000, height: 420 }, reducedMotion: "reduce" })).newPage(); + const page = await (await browser.newContext({ viewport: { width: 1000, height: 560 }, reducedMotion: "reduce" })).newPage(); page.setDefaultTimeout(6000); const events = [], errors = []; page.on("pageerror", (e) => errors.push(e.message)); diff --git a/internal/gui/tests/gateway-older.test.cjs b/internal/gui/tests/gateway-older.test.cjs index ba6598676..50fad7ad1 100644 --- a/internal/gui/tests/gateway-older.test.cjs +++ b/internal/gui/tests/gateway-older.test.cjs @@ -62,14 +62,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", if (older) { assert.equal((await state.textContent()).trim(), c.state); assert.match(await page.locator("#gateway .sub").textContent(), c.sub); - assert(await page.locator("#gateway .dot").evaluate((d) => !d.classList.contains("on")), "the dot isn't green"); + assert(await page.locator("#gateway > .gw-mark").evaluate((d) => !d.classList.contains("on")), "the mark's light isn't green"); // the whole text is there to read, nothing cut off, and the page doesn't scroll sideways const fits = await page.locator("#gateway .sub").evaluate((s) => s.scrollWidth <= s.clientWidth + 1); assert(fits, "the advice is cut off"); assert(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), "the page scrolls sideways"); } else { assert.equal((await state.textContent()).trim(), c.same); - assert(await page.locator("#gateway .dot").evaluate((d) => d.classList.contains("on"))); + assert(await page.locator("#gateway > .gw-mark").evaluate((d) => d.classList.contains("on"))); } await context.close(); } diff --git a/internal/gui/tests/web-page.test.cjs b/internal/gui/tests/web-page.test.cjs index b988f6e8a..0e3c44e17 100644 --- a/internal/gui/tests/web-page.test.cjs +++ b/internal/gui/tests/web-page.test.cjs @@ -111,7 +111,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }; const { page, errors, failed, seen } = await open(true); - await page.locator("#gateway .dot").waitFor(); + await page.locator("#gateway > .gw-mark").waitFor(); // the request archive's switch, over the Usage page's requests await page.locator('[data-view="usage"]').first().click(); @@ -147,7 +147,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", // the app's window still takes its runtime, for close and maximise const app = await open(false); - await app.page.locator("#gateway .dot").waitFor(); + await app.page.locator("#gateway > .gw-mark").waitFor(); for (let i = 0; i < 50 && !app.seen.paths.includes("/wails/runtime.js"); i++) await app.page.waitForTimeout(40); assert(app.seen.paths.includes("/wails/runtime.js"), "the app's window no longer loads its runtime"); assert.deepEqual(app.errors, []);