From c0477aa728bf4bbedf78f404efa72eb4c7c48011 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 1 Nov 2026 20:54:39 +0800 Subject: [PATCH] providers, settings: a Codex account's resets are used where they are shown, its Providers row and Settings' auto-use rows (roamlog, husky_bobo on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit roamlog on X (使用重置卡的功能哪去了): the Providers page's Codex editor showed "↺ 2 张重置卡" on each ChatGPT account, windows at 0% left, and no way to use one. Nothing was removed: the use (askReset, resetask.js) was only ever on the Usage card ("Use a reset") and the menu bar panel ("Use one…"); the Providers row's chip (#813) was words. husky_bobo (X, Windows 10, v0.1.2597, 为什么我没有这个手动用卡按钮呢?) looked for it in Settings › Usage, under "Codex: auto-use resets" with both times on, where it never was either. - Providers editor: a Codex account's "↺ N resets" is a button (a span with role=button, the window meters' aq-set look and hover, no colour of its own; Enter and Space too) opening the same confirmation, its tooltip saying which reset a use spends. A GLM team's resets, counted by window and used on the vendor's page, stay words. - The confirmation asked from the editor goes back to it on Cancel or once spent (ed.back, as Sign out's does): the editor is the modal, and closing would have closed it too. - Settings › Usage › Codex: auto-use resets: each account holding resets says "↺ N resets · until … · auto-used before it expires" under its name with "Use a reset" beside it, read as the editor reads them (loginUsageOf, cached a minute), drawn again once spent. In autoresetown.js, loaded with those rows. - No new strings. The core's scripts are 1,533,441 bytes, 305 under their size before, budget 1,533,802 not raised: a span-as-button helper (spanBtn) shared with windowCapMeter, and the reset helpers' comments cut down. Run, at base 9d08993c8: - mote (mote-run): providers-reset-use.test.cjs (new: 40 cases, Chromium and WebKit, en/zh/zh-TW/ja/de, 420 and 1000/1100 px; Providers row click and keyboard, Cancel spends nothing and keeps the editor, a use posts {user} alone and the row reads 1, the GLM chip inert, no page move; Settings as the Windows app (navigator.platform Win32, web:false) with husky_bobo's settings, both times on), reset-providers, codex-auto-reset-settings, codex-reset-lead, codex-auto-reset: 114 of 114 pass. go test -tags nogui -run 'Budget|I18n|Asset|Script' ./internal/gui ok. gofmt -l clean. - Whole GUI suite: on the Linux box (wsl-run, magpie-desktop), since mote had three other sessions' full GUI suites running; started before the push, its result follows in the report, reds filed on their own. Broken by hand (red, then put back), on mote: - origin/main's assets: the Providers cases red ("the resets are words only, nothing uses one"), the Settings cases red (no .ar-own-resets). - origin/main's resetask.js with the rest of this change: Cancel closes the editor (chip gone), and Settings still says 2 resets after a use. Not tried: a real reset was not spent (fixtures only); not run in the real Windows app on xiaomi-gpu, only with Windows' navigator.platform. --- internal/gui/assets/app.css | 3 + internal/gui/assets/app.js | 47 ++--- internal/gui/assets/autoresetown.js | 15 ++ internal/gui/assets/resetask.js | 10 +- .../gui/tests/providers-reset-use.test.cjs | 197 ++++++++++++++++++ 5 files changed, 244 insertions(+), 28 deletions(-) create mode 100644 internal/gui/tests/providers-reset-use.test.cjs diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index ccd6053a2..51c64fb0e 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -2049,6 +2049,9 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its .ar-own-case { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; } .ar-own-say { min-width: 0; color: var(--muted); font-size: 12px; text-align: right; } .ar-own-case .segs { flex: none; } +/* the account's resets, and Use, under its name (as on its Usage card) */ +.ar-own-resets { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-variant-numeric: tabular-nums; } +.ar-own-resets .text { font-size: 11px; padding: 2px 7px; } .lib-switch.auto-reset, .lib-switch.use-credits { width: 28px; height: 16px; padding: 0; border: 0; cursor: pointer; } .lib-switch.auto-reset i, .lib-switch.use-credits i { width: 12px; height: 12px; } .lib-switch.auto-reset.on i, .lib-switch.use-credits.on i { transform: translateX(12px); } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 77e76f1a2..524ae5b0a 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -13236,7 +13236,7 @@ function renderAccounts(a, p) { } } if (quota && !l.lapsed) line.querySelector(".plan").after(accountRefresh(a.agent, p, l.user)); - row.append(accountQuota(l.lapsed ? { [l.user]: { error: t(l.lapsed) } } : quota, l.user, capFor, p ? (m, w) => windowCapMeter(m, p, l.user, w) : null)); + row.append(accountQuota(l.lapsed ? { [l.user]: { error: t(l.lapsed) } } : quota, l.user, capFor, p ? (m, w) => windowCapMeter(m, p, l.user, w) : null, a.agent)); row.classList.add("with-aq"); // not :has(.aq), which Safari 15.0 lacks (#220) // Remove goes under ⋯ too, but beside Sign in again while signed out if (!row.classList.contains("signed-out")) tools.append(...line.querySelectorAll(":scope > .text.quiet")); @@ -13698,7 +13698,7 @@ function accountRefresh(agent, p, user) { // accountQuota: an account's allowance as a line of small meters under its // name, the reset time on the ones nearly used up, credits and held resets. -function accountQuota(data, user, capFor = () => 0, settable = null) { +function accountQuota(data, user, capFor = () => 0, settable = null, prov) { const line = el("div", "aq"); if (!data) { line.append(el("span", "skeleton sk-aq"), el("span", "skeleton sk-aq")); @@ -13710,10 +13710,15 @@ function accountQuota(data, user, capFor = () => 0, settable = null) { line.append(el("span", "aq-asof", asOfText(q))); } if (q?.resets?.count && !q.error) { - const words = resetsWords(q.resets); - const resets = el("span", "aq-w aq-resets"); - resets.title = tipLines(words.textContent, words.title); + // Codex's are used from here too, as on Usage (roamlog on X) + const words = resetsWords(q.resets), use = prov == "codex" && !q.resets.byWindow; + const resets = el("span", "aq-w aq-resets" + (use ? " aq-set" : "")); + resets.title = tipLines(words.textContent, words.title, use && "\n" + resetUseTitle(q)); resets.append(words.querySelector(".resets-n")); + if (use) { + spanBtn(resets).setAttribute("aria-haspopup", "dialog"); + resets.onclick = (e) => { e.stopPropagation(); askReset({ ...q, provider: prov, user }); }; + } line.append(resets); } // an account on no plan says so, whatever else can be read of it @@ -13973,21 +13978,12 @@ function pillNumber(at, val, ph, cls, label, parse, bad, own, set) { } // windowCapMeter: a window's meter on an account's row as the button that -// sets the window's own cap, in the app's menu: the account's cap, none on -// this window, a share, or one typed in place. A window of a model family -// shown as one figure (tiers) stands for several windows and isn't set -// here; one the cap doesn't count (on-demand) has none to set. +// sets the window's own cap; not a family's (tiers) or on-demand's. function windowCapMeter(m, p, user, w) { if (!w.capId || w.tiers) return m; const own = windowOwnCapOf(p, user, w), cap = accountCapOf(p, user); const name = t(w.name); - // a span acting as the button: a