Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
usage: a card's refresh opens after its "Refreshed just now", so the text never moves
yetonef5b1d36ffa5b
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.cssindex 0065720e3..2c18ed5e1 100644--- a/internal/gui/assets/app.css+++ b/internal/gui/assets/app.css@@ -1022,16 +1022,19 @@ body.window .field.solo { grid-column: auto; }.quota-read { flex-basis: 100%; margin-top: 2px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }.quota-windows + .quota-read, .quota-balance + .quota-read { margin-top: 8px; }.quota-read.stale { color: var(--amber); }-/* a card's own refresh, left of when it was read (or of why it couldn't- be), opening as the card is hovered: at rest the line starts where the- card's other lines do (#840) */+/* a card's own refresh, right after when it was read (or why it couldn't+ be), opening as the card is hovered. At rest it takes no room, so the+ line starts where the card's others do (#840); it opens rightward, so+ the text before it never moves. Opening left of the text pushed+ "Updated …" right on every hover, and the card's 12px padding has no+ room for it to hang into. */.quota-refresh { display: inline-grid; place-items: center; width: 0; margin: 0; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--faint); vertical-align: baseline; opacity: 0; overflow: hidden; cursor: pointer; transition: width .12s, margin .12s, opacity .12s; }/* Inherited text supplies the inline baseline; the icon shares its centered cell. */.quota-refresh::before { content: "\00a0"; grid-area: 1 / 1; }.quota-refresh svg { grid-area: 1 / 1; }-.subscription-card:hover .quota-refresh, .pq-card:hover .quota-refresh, .quota-refresh.busy, .quota-refresh.kept { width: 14px; margin: 0 3px 0 -2px; opacity: 1; }+.subscription-card:hover .quota-refresh, .pq-card:hover .quota-refresh, .quota-refresh.busy, .quota-refresh.kept { width: 14px; margin: 0 -2px 0 3px; opacity: 1; }/* apart: Safari before 15.4 drops a whole selector list with :focus-visible in it */-.quota-refresh:focus-visible { width: 14px; margin: 0 3px 0 -2px; opacity: 1; }+.quota-refresh:focus-visible { width: 14px; margin: 0 -2px 0 3px; opacity: 1; }.quota-refresh:hover { color: var(--fg); background: var(--pill-hover); }.quota-refresh.busy { cursor: default; }.quota-refresh.busy svg > * { transform-box: view-box; transform-origin: 50% 50%; }@@ -1039,7 +1042,7 @@ body.window .field.solo { grid-column: auto; }Usage page's draw the same account) turns by itself */.quota-refresh.spun svg > * { animation: spin .8s linear infinite; }@media (prefers-reduced-motion: reduce) { .quota-refresh.spun svg > * { animation: none; } }-@media (hover: none) { .quota-refresh { width: 14px; margin: 0 3px 0 -2px; opacity: 1; } }+@media (hover: none) { .quota-refresh { width: 14px; margin: 0 -2px 0 3px; opacity: 1; } }@media (prefers-reduced-motion: reduce) { .quota-refresh { transition: none; } }.skeleton { display: block; border-radius: 5px; background: linear-gradient(90deg, var(--skel, var(--pill)) 25%, var(--skel-hi, var(--pill-hover)) 45%, var(--skel, var(--pill)) 65%); background-size: 240% 100%; animation: skeleton-shift 1.4s ease-in-out infinite; }@keyframes skeleton-shift { from { background-position: 100% 0; } to { background-position: -100% 0; } }@@ -1912,14 +1915,14 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its.pq-bals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }.pq-card.bal { grid-template-columns: minmax(0, 1fr); }.pq-bn { display: flex; align-items: center; gap: 6px; }-.pq-bn > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }+.pq-bn > span:not(.ic) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }.pq-bn .ic { width: 14px; height: 14px; flex: none; }-/* the card's own refresh before the logo: closed, the row's gap closed with- it; open, as wide as on the Usage page (#840) */-.pq-bn > .quota-refresh { margin-right: -6px; }-.pq-card:hover .pq-bn > .quota-refresh, .pq-bn > .quota-refresh.busy { margin: 0 -3px 0 -2px; }-.pq-bn > .quota-refresh:focus-visible { margin: 0 -3px 0 -2px; }-@media (hover: none) { .pq-bn > .quota-refresh { margin: 0 -3px 0 -2px; } }+/* the card's own refresh after the name: closed, the row's gap closed+ with it; open, as wide as on the Usage page (#840) */+.pq-bn > .quota-refresh { flex: none; margin-left: -6px; }+.pq-card:hover .pq-bn > .quota-refresh, .pq-bn > .quota-refresh.busy { margin: 0 -2px 0 -3px; }+.pq-bn > .quota-refresh:focus-visible { margin: 0 -2px 0 -3px; }+@media (hover: none) { .pq-bn > .quota-refresh { margin: 0 -2px 0 -3px; } }.pq-amt { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--fg); font-variant-numeric: tabular-nums; }/* a balance field's several amounts on a balance's card (#420) */.pq-lead { display: flex; align-items: baseline; gap: 6px; min-width: 0; }diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 4e3e91610..ad1d8e6f1 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -17134,7 +17134,7 @@ function panelBalances(bals) {card.title = [q.name, q.user].filter(Boolean).join(" · ");// whose balance, at a glance: the provider's logo before its nameconst who = el("span", "pq-sub pq-bn");- who.append(quotaRefresh(q), icon(q.icon || "generic"), el("span", "", q.name));+ who.append(icon(q.icon || "generic"), el("span", "", q.name), quotaRefresh(q));card.append(who);// a balance field with several amounts: the first as the figure,// the others each a quiet line, a percent a meter (#420); what the@@ -17269,7 +17269,7 @@ function panelQuotaCard(q) {if (q.error) {card.classList.add("err");const why = el("span", "pq-sub err", quotaError(q.error, q));- why.prepend(quotaRefresh(q));+ why.append(quotaRefresh(q));card.append(why);card.title += "\n" + q.error;return card;@@ -17283,7 +17283,7 @@ function panelQuotaCard(q) {const fam = familyWindows(q.windows.filter((w) => !w.unlimited));if (!fam.length && q.windows.some((w) => w.unlimited)) {const sub = el("span", "pq-sub", t("Unlimited"));- sub.prepend(quotaRefresh(q));+ sub.append(quotaRefresh(q));card.append(sub);if (balance) card.append(balance);return card;@@ -17310,7 +17310,7 @@ function panelQuotaCard(q) {const pace = line ? quotaEtaText(line, Date.now()) : "";if (pace) sub.append(el("span", "pq-pace", " · " + pace));// the card's own refresh, as on the Usage page: shown as it's hovered- sub.prepend(quotaRefresh(q));+ sub.append(quotaRefresh(q));card.append(sub);const rings = el("span", "pq-rings");for (const w of ws) {@@ -18030,7 +18030,7 @@ function readWhen(q, refresh = false) {s.append(when);s.title = new Date(q.readAt).toLocaleString(intlLang());} else return null;- if (refresh) s.prepend(quotaRefresh(q));+ if (refresh) s.append(quotaRefresh(q));return s;}setInterval(() => {@@ -18226,8 +18226,6 @@ function quotaWindows(sub) {const failed = () => {const e = el("div", "subscription-error", quotaError(sub.error, sub));e.title = sub.error;- // read again from here too: a failed reading is the one most wanted- e.prepend(quotaRefresh(sub));// one click away: the access key a plan needs (#1821), or the// vendor's page for a balance it tells no key (seeAt, Zen's console)const key = sub.needsAccessKey && sub.provider;@@ -18237,6 +18235,8 @@ function quotaWindows(sub) {go.onclick = (ev) => { ev.stopPropagation(); key ? openProvider(sub.provider) : api("open", { url: sub.seeAt }).catch(() => {}); };e.append(" ", go);}+ // read again from here too: a failed reading is the one most wanted+ e.append(quotaRefresh(sub));return e;};if (sub.balance && !sub.windows?.length) {diff --git a/internal/gui/tests/usage-card-refresh.test.cjs b/internal/gui/tests/usage-card-refresh.test.cjsindex 9508042cd..047664540 100644--- a/internal/gui/tests/usage-card-refresh.test.cjs+++ b/internal/gui/tests/usage-card-refresh.test.cjs@@ -1,8 +1,10 @@// Run with Node's test runner and Playwright on the module path; see README.md.// A card's own refresh (Hu9956, #840: 在更新时间左侧加一个刷新按钮,鼠标悬停-// 在套餐卡片上时显示,可以单独刷新某个套餐的用量): left of "Updated …", or of-// why a reading failed, or under a balance, opening as the card is hovered;-// at rest the line starts where the card's others do. A click reads that card alone+// 在套餐卡片上时显示,可以单独刷新某个套餐的用量): after "Updated …", or+// after why a reading failed, or under a balance, opening as the card is+// hovered; at rest the line starts where the card's others do, and the text+// doesn't move when it opens (opening left of it pushed it right on every+// hover). A click reads that card alone// (POST /api/usage/quotas/refresh?provider=&user=), turns while it does, and// draws what came back; no other card is asked, and the page doesn't scroll.// Button controls in English and Chinese; refresh ordering, deferred@@ -137,12 +139,21 @@ function layoutFixtures(now) {] };}+// where the line's text starts, line by line+const textAt = (row) => row.evaluate((e) => {+ const range = document.createRange();+ range.selectNodeContents(e);+ return [...range.getClientRects()].filter((r) => r.width).map((r) => Math.round(r.x * 4) / 4)[0];+});+async function showRefresh(row) {+ const was = await textAt(row);await row.hover();await row.locator(".quota-refresh").evaluate(e => new Promise(done => {const tick = () => getComputedStyle(e).opacity === "1" && e.getBoundingClientRect().width >= 14 ? done() : requestAnimationFrame(tick);tick();}));+ assert.equal(await textAt(row), was, "the text stays where it was as the refresh opens");}async function assertRefreshAligned(row) {@@ -152,11 +163,13 @@ async function assertRefreshAligned(row) {const range = document.createRange();range.selectNodeContents(text);const rect = (r) => ({ x: r.x, right: r.right, cy: r.y + r.height / 2 });- return { icon: rect(button.querySelector("svg").getBoundingClientRect()), text: rect(range.getClientRects()[0]) };+ return { icon: rect(button.querySelector("svg").getBoundingClientRect()), text: rect([...range.getClientRects()].at(-1)) };});- assert.ok(boxes.icon.right <= boxes.text.x, "the refresh icon stays left of the first line");- assert.ok(Math.abs(boxes.icon.cy - boxes.text.cy) <= 0.75,- "the refresh icon and the first text line must share a vertical center: " + JSON.stringify(boxes));+ // after the text: on its last line, or on a line of its own below it+ const below = boxes.icon.cy > boxes.text.cy + 4;+ assert.ok(below || boxes.icon.x >= boxes.text.right, "the refresh icon comes after the text: " + JSON.stringify(boxes));+ if (!below) assert.ok(Math.abs(boxes.icon.cy - boxes.text.cy) <= 0.75,+ "the refresh icon and the text's line must share a vertical center: " + JSON.stringify(boxes));}async function assertInlineSettings(row, multiline) {@@ -296,12 +309,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const user = await claude.locator(".subscription-account .user").boundingBox();assert.ok(Math.abs((await ago.boundingBox()).x - user.x) < 1, "the time lines up with the card at rest");- // hovered: left of the time, on its line+ // hovered: after the time, on its lineawait claude.hover();await btn.evaluate((e) => new Promise((done) => { const tick = () => getComputedStyle(e).opacity === "1" && e.getBoundingClientRect().width >= 14 ? done() : requestAnimationFrame(tick); tick(); }));assert.equal(await opacity(), "1");const [b, when] = [await btn.boundingBox(), await ago.boundingBox()];- assert.ok(b.width >= 14 && b.x + b.width <= when.x + 0.5 && Math.abs(b.y + b.height / 2 - (when.y + when.height / 2)) < 4, JSON.stringify({ b, when }));+ assert.ok(b.width >= 14 && b.x >= when.x + when.width - 0.5 && Math.abs(b.y + b.height / 2 - (when.y + when.height / 2)) < 4, JSON.stringify({ b, when }));await assertRefreshAligned(read);// a failed reading and a balance have one too