From 286e3b6d5fd7bc25bba5ca7affdad95ff567fe27 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 10 Nov 2026 15:33:32 +0800 Subject: [PATCH] gui: the tray panel's Usage tab puts a vendor's account first from its count (RealZeroP27 on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RealZeroP27 asked to switch the Codex account in use from the menu bar panel's quota page, not from the Providers page. A vendor group with several accounts on the panel's Usage tab now draws its count as a button (the count and a chevron). It opens the app menu (openProtoMenu) with the accounts the provider editor can put first, the first one ticked, and Manage accounts… at the foot, which opens the window's Providers page. Picking one does what the editor's Make first or Use does, through the same code: putFirst, now shared by the editor and the panel. Kept signed in to one, that is provider/arrange with the account first in the order; otherwise login/switch. The first account's card gets a small tick. It works for any subscription with several signed-in accounts (Codex, Claude, a plugin's), not only Codex. Setup-token, access-only and lapsed accounts are left out, as in the editor; kept signed in, so are paused or off ones. A vendor with one account that can be first keeps its plain count. The panel's provider list (panelAccts) is now also read when the Usage tab has two accounts of one vendor, one read at a time. The menu reads a fresh list first when only the kept one is drawn. pluginSubs falls back to that list, since the panel has no window list (it threw on null before). Budget: the menu is in panelfirst.js, loaded when the count is pressed, and the Allowances tab's arranging (panelArrange, hidePanelUsage) moved out to panelarrange.js, loaded when Arrange is pressed. That pays for the rest with no comments cut and no raise (#5918); the core is at 1,533,604 of 1,533,802. old-webkit's lazy list names both files. Run (mote, at this change on origin/main 662546e78; rebased after onto 55b0d7c24, which changes only internal/gateway): - GUI, chromium and webkit: panel-usage-first-account (5 languages x 440/360px), panel-switch-accounts, panel-arrange, grip-inset, old-webkit, i18n-keys: 227 ok, 1 red: old-webkit's "the styles hold up in Safari 15.0" on main's .side-foot:has() from d374168d0, filed as #5919, the same at main. - go test -run Budget ./internal/gui/ at this head: ok. The whole package before the rebase: the only red is TestGatewayModeStatsNameTheGatewaySessions, run at 00:22 local, which is #5690 (red in the first hour of a local day), untouched here. - go vet ./internal/gui for darwin, GOOS=linux -tags nogui, GOOS=windows: ok. gofmt -l: clean. - Before the rebase, 21 GUI files were run at this change and at main 6a253f8af; the reds they share are the same on main under load. The two head-only reds (panel-switch-accounts' "reads the list once", a null box while the group redrew) were fixed here. Broken by hand: - The new test is red on origin/main's assets (no .pq-pick). - putFirst with the kept branch turned off sends login/switch in the kept case: the kept test goes red. - Dropping !l.accessOnly puts the access-only account in the menu: the menu's list check goes red. Not tried: the whole GUI suite, a real account switch from the real panel, the real Linux (WebKitGTK) app. --- internal/gui/assets/app.css | 7 + internal/gui/assets/app.js | 185 +++++++-------- internal/gui/assets/panelarrange.js | 77 +++++++ internal/gui/assets/panelfirst.js | 26 +++ internal/gui/core_budget_test.go | 2 +- internal/gui/tests/old-webkit.test.cjs | 6 +- .../tests/panel-usage-first-account.test.cjs | 217 ++++++++++++++++++ 7 files changed, 416 insertions(+), 104 deletions(-) create mode 100644 internal/gui/assets/panelarrange.js create mode 100644 internal/gui/assets/panelfirst.js create mode 100644 internal/gui/tests/panel-usage-first-account.test.cjs diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 7158be732..db67b4325 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -2030,6 +2030,13 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its .pq-gn { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* how many accounts: a quiet count set by the name, on its cap height */ .pq-count { flex: none; min-width: 16px; height: 15px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--fg) 7%, transparent); color: var(--muted); font-size: 9.5px; font-weight: 600; line-height: 1; letter-spacing: 0; font-variant-numeric: tabular-nums; } +/* with a vendor's accounts to put first: the count opens their menu */ +.pq-pick { height: 17px; gap: 1px; padding: 0 3px 0 6px; display: inline-flex; align-items: center; cursor: default; transition: background .12s ease, color .12s ease, transform .12s cubic-bezier(.23, 1, .32, 1); } +.pq-pick svg { flex: none; opacity: .8; } +.pq-pick:is(:hover, .open) { background: color-mix(in srgb, var(--fg) 12%, transparent); color: var(--fg); } +.pq-pick:active { transform: scale(.97); } +/* the account used first: ticked before its name */ +.pq-first { flex: none; display: inline-grid; place-items: center; width: 12px; height: 12px; margin-right: 3px; color: var(--accent); } .pq-gnote { flex: none; margin-left: auto; font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; } .pq-gnote.ends { color: var(--amber); } /* used or left: a quiet pill at the right, over the rings; lit a moment diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 153b4040a..d62418181 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -1618,7 +1618,6 @@ function switchEntry(a) { const pn = mode === "panel", b = el("button", pn ? "field ag-who" : "ag-acc ag-who"), cx = a.id === "codex"; b.type = "button"; b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); if (cur) b.title = t("Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.", { ...ag, user: cur }); b.append(pn ? el("span", "k", t("account")) : svg(EXTRA_GLYPH["sign-in"], 12, 1.5), el("span", "v", cur || t("Not signed in"))); const ago = performance.now() - (accountSwitched?.at || -1e9); @@ -1663,14 +1662,21 @@ async function switchAccountTo(a, p, user) { renderAgents(); } -// the panel's list for it: the kept one, a fresh read only with none kept +// the panel's list for it and the Usage tab's: the kept one, a fresh read +// only with none kept, one read at a time async function panelAccounts() { - if (!state.agents.some(switchesAccounts)) return; - const s = await api("providers?last=1").then((s) => s || api("providers")).catch(() => null); + if (!state.agents.some(switchesAccounts) && !panelSeveral()) return; + const s = await (panelAccounts.p ||= api("providers?last=1").then((s) => s || api("providers")).catch(() => null).finally(() => panelAccounts.p = null)); const key = (l) => JSON.stringify(l?.providers?.filter((p) => p.account).map((p) => [p.id, p.account, p.switchOnly, p.keepLoginAs])); if (!s || panelAccts === s || key(s) === key(panelAccts)) return; panelAccts = s; renderAgents(); + renderPanelQuota(true); +} + +function panelSeveral() { + const seen = new Set(); + return (quotas || []).some((q) => q.user && !q.balance && (seen.has(q.provider) || !seen.add(q.provider))); } // agentsLead: above the window's list, what 「接入」 does, said once in a @@ -12476,7 +12482,7 @@ function pluginMethod(sub, site) { // Plugins), as subscriptions like the built-in ones. The plugin, not // magpie, signs in and carries the requests. function pluginSubs() { - return (providers.plugins || []).map((x) => ({ + return ((providers || panelAccts)?.plugins || []).map((x) => ({ agent: x.id, pid: x.pid, name: x.name, icon: x.icon, plugin: x, own: true, single: !!x.single, get plans() { return t("from the plugin {spec}", { spec: x.spec }); }, })); @@ -12914,7 +12920,6 @@ function signInProxyLink(sub) { // the whole address too, which a narrow sheet cuts short b.title = proxyName(signing.proxy) + "\n" + t("The sign-in goes through this proxy, as the account's requests will. One picked here is kept as the account's."); b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); b.onclick = (e) => { e.stopPropagation(); const flow = signing; @@ -13353,6 +13358,29 @@ function loginsInOrder(a, p) { return ls.sort((x, y) => (y.active ? 1 : 0) - (x.active ? 1 : 0)); } +// the editor's First, and its Make first or Use (putFirst), which the +// panel's Usage tab shares +function firstLogin(a, p) { + const ls = loginsInOrder(a, p); + return keptLogin(p) ? ls.find((l) => (l.active || l.on) && !l.paused && !l.lapsed)?.user : ls.find((l) => l.active)?.user; +} + +function byQuotaOf(p, r = p?.routing || "") { + return p?.account && ["", "usage", "pace"].includes(r) ? ROUTINGS.find(([id]) => id === r)?.[1] : ""; +} +function firstNoteOf(p, user) { + return t("{user} is first in the order; {routing} still goes by each account's quota, so the order only settles ties. In order uses the first first.", { user, routing: t(byQuotaOf(p)) }); +} + +function putFirst(a, p, l) { + const sub = subOf(a.agent), byQuota = byQuotaOf(p), on = !l.paused && (l.active || l.on); + if (keptLogin(p)) { + const ls = loginsInOrder(a, p); + return accountAction("provider/arrange", { id: p.id, accountOrder: [l.user, ...ls.filter((x) => x !== l).map((x) => x.user)] }, byQuota ? firstNoteOf(p, l.user) : t("The gateway now uses {user} first", { user: l.user })); + } + return accountAction("login/switch", { agent: a.agent, user: l.user }, on && byQuota ? (sub?.own ? "" : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user }) + " ") + firstNoteOf(p, l.user) : sub?.own ? t("The gateway now uses {user} first", { user: l.user }) : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user })); +} + function renderAccounts(a, p) { const sub = subOf(a.agent); const list = el("div", "accts"); @@ -13369,13 +13397,12 @@ function renderAccounts(a, p) { const isOn = (l) => !unusable(l) && !l.paused && (l.active || l.on), wOf = (l) => Math.max(p?.accountWeights?.[String(l.user).toLowerCase()] || 0, 1), weights = ls.filter(isOn).reduce((n, l) => n + wOf(l), 0); // kept signed in to one (#524): the first is the order's const kept = keptLogin(p); - const firstUser = kept ? ls.find((l) => (l.active || l.on) && !l.paused && !l.lapsed)?.user : ls.find((l) => l.active)?.user; - const byQuota = p?.account && ["", "usage", "pace"].includes(p?.routing || "") ? ROUTINGS.find(([id]) => id === (p?.routing || ""))?.[1] : ""; - const firstNote = (user) => t("{user} is first in the order; {routing} still goes by each account's quota, so the order only settles ties. In order uses the first first.", { user, routing: t(byQuota) }); + const firstUser = firstLogin(a, p); + const byQuota = byQuotaOf(p); const makeFirst = (l) => { const b = el("button", "text", t("Make first")); - b.title = byQuota ? firstNote(l.user) : t("The gateway uses this account first; {agent} stays signed in to {user}", { agent: a.agentName, user: kept }); - b.onclick = () => { b.classList.add("busy"); accountAction("provider/arrange", { id: p.id, accountOrder: [l.user, ...ls.filter((x) => x !== l).map((x) => x.user)] }, byQuota ? firstNote(l.user) : t("The gateway now uses {user} first", { user: l.user })); }; + b.title = byQuota ? firstNoteOf(p, l.user) : t("The gateway uses this account first; {agent} stays signed in to {user}", { agent: a.agentName, user: kept }); + b.onclick = () => { b.classList.add("busy"); putFirst(a, p, l); }; return b; }; // pausable while another is on (#263) @@ -13513,8 +13540,8 @@ function renderAccounts(a, p) { line.append(forget, only); } else { const use = el("button", "text", on ? t("Make first") : t("Use")); - use.title = on && byQuota ? firstNote(l.user) : sub?.own ? t("The gateway uses this account first") : t("Sign {agent} in to this account", { agent: a.agentName }); - use.onclick = () => { use.classList.add("busy"); accountAction("login/switch", { agent: a.agent, user: l.user }, on && byQuota ? (sub?.own ? "" : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user }) + " ") + firstNote(l.user) : sub?.own ? t("The gateway now uses {user} first", { user: l.user }) : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user })); }; + use.title = on && byQuota ? firstNoteOf(p, l.user) : sub?.own ? t("The gateway uses this account first") : t("Sign {agent} in to this account", { agent: a.agentName }); + use.onclick = () => { use.classList.add("busy"); putFirst(a, p, l); }; line.append(forget, use); } } @@ -14278,7 +14305,6 @@ function windowCapMeter(m, p, user, w) { : own ? t("{window} has a cap of its own: magpie counts this account as used up once {window} is at {n}%, until it renews. Click to change", { window: name, n: own }) : t("Click to give {window} a cap of its own, apart from this account's", { window: name })].filter(Boolean).join("\n"); b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); const set = (v) => accountAction("provider/windowcap", { id: p.id, account: user, window: w.capId, ...w.tiers && { windows: ids }, cap: v }, v === 0 && !w.ownCap ? t("{window} of {who} follows the account's cap", { window: name, who: user }) : !(v % 100) ? t("{window} of {who} has no cap", { window: name, who: user }) @@ -15891,6 +15917,7 @@ function loadQuotas(asked, again) { if (!same) renderQuotas(true); if (view === "usage") loadUpstream(); if (reading && !quotasLater && ++quotasTries <= 20) quotasLater = setTimeout(() => { quotasLater = 0; loadQuotas(false, true); }, 1500); + if (mode === "panel" && state?.agents && !panelAccts) panelAccounts(); }); p.asked = asked; quotasLoading = p; @@ -17483,7 +17510,7 @@ function renderPanelUse() { function renderPanelQuota(lazy) { const box = $("#panelQuota"); if (mode !== "panel" || !box) return; - const drawn = JSON.stringify([quotas, quotaHistV, quotaLeft, quotaRange, [...panelOptsFolded], state?.settings, locale, panelTab, panelPeek, panelArranging, panelZeroOpen, usageArranging, Math.floor(Date.now() / 60e3)]); + const drawn = JSON.stringify([quotas, quotaHistV, quotaLeft, quotaRange, [...panelOptsFolded], state?.settings, locale, panelTab, panelPeek, panelArranging, panelZeroOpen, usageArranging, panelAcctsKey(), Math.floor(Date.now() / 60e3)]); if (lazy && renderPanelQuota.drawn === drawn) return; renderPanelQuota.drawn = drawn; const subs = byUsageOrder(keyCards(quotas || []).filter((q) => q.balance || q.error || q.windows?.length)); @@ -17515,7 +17542,7 @@ function renderPanelQuota(lazy) { fit(); return; } - if (panelArranging) { + if (panelArranging && window.panelArrange) { box.append(panelArrange(subs)); if (view && view.scrollTop !== keep) view.scrollTop = keep; fit(); @@ -17550,11 +17577,14 @@ function renderPanelQuota(lazy) { const { name, qs } = part; if (qs.every((q) => zero.has(q)) && (atZero += qs.length) && !panelZeroOpen) continue; const g = el("div", "pq-group"); + g.dataset.provider = qs[0].provider; const head = el("div", "pq-gh"); head.append(icon(qs[0].icon), el("span", "pq-gn", name)); - // several accounts: how many, a quiet count by the name; one: its plan - // and until when, at the right - if (qs.length > 1) { + // several accounts: how many, a quiet count by the name, which puts one + // first; one: its plan and until when, at the right + const first = qs.length > 1 && panelFirstOf(qs); + if (first) head.append(panelFirstMenu(qs, first)); + else if (qs.length > 1) { const n = el("span", "pq-count", String(qs.length)); n.title = t("{n} accounts", { n: qs.length }); head.append(n); @@ -17576,7 +17606,7 @@ function renderPanelQuota(lazy) { // the accounts in full; none of them, the one in sight; folded, none const shut = all && quotaAllFolded(qs[0].provider); const full = qs.length > 1 ? qs.filter((q) => usageAcctOpen(q, qs)) : qs; - if (!shut) for (const q of full.length ? full : [usageShown(qs)]) g.append(panelQuotaCard(q)); + if (!shut) for (const q of full.length ? full : [usageShown(qs)]) g.append(panelQuotaCard(q, first && sameUser(q.user, first.user))); if (qs.length > 1 && !shut) g.append(usageMore(qs, "pq-more")); box.append(g); } @@ -17585,7 +17615,7 @@ function renderPanelQuota(lazy) { const arrange = el("button", "pq-more pq-arrange", t("Arrange")); arrange.type = "button"; arrange.title = t("Choose which subscriptions this tab shows, and their order"); - arrange.onclick = () => { panelArranging = true; panelPeek = ""; renderPanelQuota(); $("#panelQuota .pq-arow .pq-ahandle")?.focus(NO_SCROLL); }; + arrange.onclick = () => import("./panelarrange.js").then(() => { panelArranging = true; panelPeek = ""; renderPanelQuota(); $("#panelQuota .pq-arow .pq-ahandle")?.focus(NO_SCROLL); }, statusErr); foot.append(arrange); if (atZero) { const z = el("button", "pq-more pq-zero", panelZeroOpen ? t("Fold the ones at 0") : t("{n} at 0", { n: atZero })); @@ -17605,6 +17635,31 @@ function renderPanelQuota(lazy) { requestAnimationFrame(focusQuotaCard); } +// a vendor's count on the panel's Usage tab puts an account first +// (RealZeroP27 on X); its menu is panelfirst.js +const sameUser = (a, b) => !!a && !!b && String(a).toLowerCase() === String(b).toLowerCase(); +function panelAcctsKey() { + return panelAccts?.providers?.map((p) => p.account?.logins?.length > 1 && [p.id, p.routing, p.keepLogin, p.keepLoginAs, p.account.logins]); +} +function panelFirstOf(qs) { + const p = panelAccts?.providers?.find((x) => x.id === qs[0].provider && x.account?.logins?.length > 1); + if (!p) return null; + const a = p.account, kept = keptLogin(p), user = firstLogin(a, p); + const can = loginsInOrder(a, p).filter((l) => !l.token && !l.accessOnly && !l.lapsed && (!kept || (!l.paused && (l.active || l.on)))); + return can.length > 1 && can.some((l) => l.user !== user) ? { p, a, user, can } : null; +} +function panelFirstMenu(qs, f) { + const b = el("button", "pq-count pq-pick"); + b.type = "button"; + b.title = t("{n} accounts", { n: qs.length }); + b.setAttribute("aria-label", b.title); + b.setAttribute("aria-haspopup", "menu"); + b.setAttribute("aria-expanded", "false"); + b.append(el("span", "", String(qs.length)), svg(CHEV, 9, 1.8)); + b.onclick = (e) => { e.stopPropagation(); if (b.classList.contains("open")) return closeProtoMenu(); import("./panelfirst.js").then(() => panelFirstOpen(b, qs, f), statusErr); }; + return b; +} + // panelBalances is a run of balances on the Allowances tab, under their // heading, as figures side by side. function panelBalances(bals) { @@ -17653,81 +17708,6 @@ function panelBalances(bals) { return g; } -// The Allowances tab's arranging (H20 on Discord): a row a subscription, -// in the order the Usage page's cards have, its logo the handle to move it -// (drag, or Alt+arrows) and a pill to hide it from this tab or show it -// again. Hiding is the panel's alone; routing and the rest still use it. -function panelArrange(subs) { - const g = el("div", "pq-group pq-arranging"); - const head = el("div", "pq-gh"); - head.append(el("span", "pq-gn", t("Arrange"))); - const done = el("button", "pq-mode pq-done", t("Done")); - done.type = "button"; - done.onclick = () => { panelArranging = false; renderPanelQuota(); }; - head.append(done); - g.append(head, el("p", "pq-anote", t("Hiding is for this panel only: routing, the Usage page and the menu bar still use what's hidden. The order is the Usage page's too."))); - const hidden = new Set(state.settings?.panelUsageHidden || []); - const list = el("div", "pq-alist"); - const seen = new Set(); - for (const q of subs) { - if (seen.has(q.provider)) continue; - seen.add(q.provider); - const off = hidden.has(q.provider); - const row = el("div", "pq-arow" + (off ? " put-away" : "")); - row.dataset.key = q.provider; - const h = el("button", "ag-handle pq-ahandle"); - h.type = "button"; - h.setAttribute("aria-label", t("Arrange {agent}", { agent: q.name })); - h.title = t("Drag to reorder · Alt+arrow keys to move"); - h.append(icon(q.icon || "generic")); - h.onkeydown = (e) => { - const step = { ArrowUp: -1, ArrowLeft: -1, ArrowDown: 1, ArrowRight: 1 }[e.key]; - if (!e.altKey || !step) return; - e.preventDefault(); - moveUsage(q.provider, usageKeys().indexOf(q.provider) + step); - $(`#panelQuota .pq-arow[data-key="${CSS.escape(q.provider)}"] .pq-ahandle`)?.focus(NO_SCROLL); - }; - h.onpointerdown = (e) => { - if (usageArranging) return; - usageArranging = dragCards(e, h, row, list, [...list.children], (to) => moveUsage(q.provider, to), () => { - usageArranging = false; - if (usageRenderPending) { usageRenderPending = false; renderQuotas(); } - }); - }; - const pill = el("button", "pq-more pq-show", t(off ? "Show" : "Hide")); - pill.type = "button"; - pill.setAttribute("aria-pressed", String(!off)); - pill.title = t(off ? "Show {name} in this panel" : "Hide {name} from this panel", { name: q.name }); - pill.onclick = () => hidePanelUsage(q.provider, !off); - row.append(h, el("span", "pq-aname", q.name), off ? el("span", "pq-hidden", t("Hidden")) : "", pill); - list.append(row); - } - g.append(list); - return g; -} - -// hidePanelUsage hides a subscription from the panel's Allowances tab, or -// shows it again: drawn at once, put back if the save fails. -async function hidePanelUsage(key, hide) { - const prev = state.settings; - const cur = (prev.panelUsageHidden || []).filter((k) => k !== key); - const panelHidden = hide ? [...cur, key] : cur; - state.settings = { ...prev, panelUsageHidden: panelHidden }; - const again = () => { - renderPanelQuota(); - $(`#panelQuota .pq-arow[data-key="${CSS.escape(key)}"] .pq-show`)?.focus(NO_SCROLL); - }; - again(); - try { - const s = await api("usage/arrange", { panelHidden }); - state.settings = { ...state.settings, panelUsageHidden: s.panelUsageHidden || [] }; - } catch (e) { - state.settings = prev; - again(); - statusErr(e); - } -} - // asOfText dates a cached allowance and distinguishes a deliberate skip // from a failed read (such as the vendor rate limiting its usage endpoint). function asOfText(q, short = false) { @@ -17743,7 +17723,7 @@ function shortWindow(name) { return m ? m[1] + { minute: "m", hour: "h", day: "d", week: "w", month: "mo" }[m[2].toLowerCase()] : t(name); } -function panelQuotaCard(q) { +function panelQuotaCard(q, first = false) { const card = el("div", "pq-card"); card.dataset.card = trayCardID(q); if (q.balanceCard) card.dataset.balCard = q.balanceCard; @@ -17751,6 +17731,13 @@ function panelQuotaCard(q) { // in for (#1515), before the account itself // and its eye while Hide accounts is on, as on the Usage page (yogurt36) const who = el("span", "pq-who"); + if (first) { + const tick = el("span", "pq-first"); + tick.append(svg(CHECK, 10, 2.2)); + tick.title = t("First"); + who.append(tick); + card.classList.add("first"); + } who.append(el("span", "pq-user" + (q.alias && q.named ? " own-name" : ""), q.alias || q.user || q.name)); if ((q.user || q.alias) && window.hideAccounts) who.append(hideAccounts.eye(q.user || q.alias, q.provider)); card.append(who); @@ -21650,7 +21637,6 @@ function sideEffortChip(val, levels, saved, now, cls, dflt, save) { const b = el("button", "rt-cond on side-effort " + cls); b.type = "button"; b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); const shown = saved ? now || saved : ""; b.setAttribute("aria-label", t("Thinking") + ": " + (shown ? t(shown) : t("Default"))); b.title = t("How hard this model thinks"); @@ -21679,7 +21665,6 @@ function replyModelRow(s, keep) { b.type = "button"; b.title = n; b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); b.append(el("span", "", t(cur[1])), svg(CHEV, 11, 1.6)); b.onclick = (e) => { e.stopPropagation(); @@ -21989,7 +21974,6 @@ function pmPick(m, pick) { const b = el("button", "sess-pick pm-model"); b.type = "button"; b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); b.title = t("The local model"); b.append(el("span", "", (PM_MODELS[m.model] || [m.model])[0]), svg(CHEV, 11, 1.6)); b.onclick = (e) => { @@ -22009,7 +21993,6 @@ function pmScore(m, pick) { const b = el("button", "sess-pick pm-score"); b.type = "button"; b.setAttribute("aria-haspopup", "menu"); - b.setAttribute("aria-expanded", "false"); b.title = t("Confidence threshold"); b.append(el("span", "", String(m.minScore)), svg(CHEV, 11, 1.6)); b.onclick = (e) => { diff --git a/internal/gui/assets/panelarrange.js b/internal/gui/assets/panelarrange.js new file mode 100644 index 000000000..597f45c4b --- /dev/null +++ b/internal/gui/assets/panelarrange.js @@ -0,0 +1,77 @@ +// The tray panel's arranging of its Allowances tab, loaded when Arrange is +// pressed (app.js's arrange button), so it weighs nothing on the core. + +// The Allowances tab's arranging (H20 on Discord): a row a subscription, +// in the order the Usage page's cards have, its logo the handle to move it +// (drag, or Alt+arrows) and a pill to hide it from this tab or show it +// again. Hiding is the panel's alone; routing and the rest still use it. +window.panelArrange = function panelArrange(subs) { + const g = el("div", "pq-group pq-arranging"); + const head = el("div", "pq-gh"); + head.append(el("span", "pq-gn", t("Arrange"))); + const done = el("button", "pq-mode pq-done", t("Done")); + done.type = "button"; + done.onclick = () => { panelArranging = false; renderPanelQuota(); }; + head.append(done); + g.append(head, el("p", "pq-anote", t("Hiding is for this panel only: routing, the Usage page and the menu bar still use what's hidden. The order is the Usage page's too."))); + const hidden = new Set(state.settings?.panelUsageHidden || []); + const list = el("div", "pq-alist"); + const seen = new Set(); + for (const q of subs) { + if (seen.has(q.provider)) continue; + seen.add(q.provider); + const off = hidden.has(q.provider); + const row = el("div", "pq-arow" + (off ? " put-away" : "")); + row.dataset.key = q.provider; + const h = el("button", "ag-handle pq-ahandle"); + h.type = "button"; + h.setAttribute("aria-label", t("Arrange {agent}", { agent: q.name })); + h.title = t("Drag to reorder · Alt+arrow keys to move"); + h.append(icon(q.icon || "generic")); + h.onkeydown = (e) => { + const step = { ArrowUp: -1, ArrowLeft: -1, ArrowDown: 1, ArrowRight: 1 }[e.key]; + if (!e.altKey || !step) return; + e.preventDefault(); + moveUsage(q.provider, usageKeys().indexOf(q.provider) + step); + $(`#panelQuota .pq-arow[data-key="${CSS.escape(q.provider)}"] .pq-ahandle`)?.focus(NO_SCROLL); + }; + h.onpointerdown = (e) => { + if (usageArranging) return; + usageArranging = dragCards(e, h, row, list, [...list.children], (to) => moveUsage(q.provider, to), () => { + usageArranging = false; + if (usageRenderPending) { usageRenderPending = false; renderQuotas(); } + }); + }; + const pill = el("button", "pq-more pq-show", t(off ? "Show" : "Hide")); + pill.type = "button"; + pill.setAttribute("aria-pressed", String(!off)); + pill.title = t(off ? "Show {name} in this panel" : "Hide {name} from this panel", { name: q.name }); + pill.onclick = () => hidePanelUsage(q.provider, !off); + row.append(h, el("span", "pq-aname", q.name), off ? el("span", "pq-hidden", t("Hidden")) : "", pill); + list.append(row); + } + g.append(list); + return g; +}; + +// hidePanelUsage hides a subscription from the panel's Allowances tab, or +// shows it again: drawn at once, put back if the save fails. +async function hidePanelUsage(key, hide) { + const prev = state.settings; + const cur = (prev.panelUsageHidden || []).filter((k) => k !== key); + const panelHidden = hide ? [...cur, key] : cur; + state.settings = { ...prev, panelUsageHidden: panelHidden }; + const again = () => { + renderPanelQuota(); + $(`#panelQuota .pq-arow[data-key="${CSS.escape(key)}"] .pq-show`)?.focus(NO_SCROLL); + }; + again(); + try { + const s = await api("usage/arrange", { panelHidden }); + state.settings = { ...state.settings, panelUsageHidden: s.panelUsageHidden || [] }; + } catch (e) { + state.settings = prev; + again(); + statusErr(e); + } +} diff --git a/internal/gui/assets/panelfirst.js b/internal/gui/assets/panelfirst.js new file mode 100644 index 000000000..056ad8031 --- /dev/null +++ b/internal/gui/assets/panelfirst.js @@ -0,0 +1,26 @@ +// The tray panel's Usage tab puts a vendor's account first (RealZeroP27 +// on X: switch Codex's account there, not on the Providers page). app.js +// draws the vendor's count as a button (panelFirstMenu) and imports this +// when it is pressed, so the menu weighs nothing on the core. The menu +// lists the accounts the provider editor can put first, the first +// ticked; a pick does what the editor's Make first or Use does +// (putFirst), and Manage accounts… opens the window's Providers. +window.panelFirstOpen = async function open(b, qs, f) { + // the kept list drew it: the menu waits for a fresh read, as the + // Agents row's account menu does (switchEntry) + const s = panelAccts?.last && await api("providers").catch(() => null); + if (s) { + panelAccts = s; + renderAgents(); + renderPanelQuota(true); + const again = [...document.querySelectorAll("#panelQuota .pq-pick")].find((x) => x.closest(".pq-group")?.dataset.provider === qs[0].provider); + return again?.click(); + } + const opts = f.can.map((l) => ({ v: "u:" + l.user, name: l.user, literalName: true, note: accountPlan({ agent: f.a.agent, builtin: f.a.builtin, plan: l.plan }) })); + opts.push({ v: "manage", name: "Manage accounts…", note: "" }); + openProtoMenu(b, opts, "u:" + (f.user || ""), (v) => { + const l = f.can.find((x) => "u:" + x.user === v); + if (v === "manage") api("window/main?view=providers", {}).catch(statusErr); + else if (l && l.user !== f.user) putFirst(f.a, f.p, l).then(() => renderPanelQuota(true)); + }, "Use first", "sess-menu", "left"); +}; diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 9e07d96be..4070fa3d4 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -16,7 +16,7 @@ import ( // raises them and says why in its commit. const ( appScriptBudget = 1_316_874 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30); 1,317,705 with a Claude account added from a setup-token (sfss5362 on X): the sign-in's Use a setup-token instead…, its sheet, and its account row's magpie only, the provider editor's account rows, the core's own editor, its comments cut down, with no room added (10-30); back to 1,315,316 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, loaded when one is asked for (signAsk, 10-30); 1,315,479 with the provider editor lining its Advanced up with its fields (the owner: 高级这个折叠按钮为什么在一个前不着村后不着店的位置?) and a refresh on each of its accounts (在这里也要加上手动刷新用量的按钮), the core's own editor, with no room added (10-31); 1,315,603 with About's Log row, the path of the log the app writes and an Open for its folder (rayem1w on X), in app.js, its comment cut to one line, with no room added (10-31); 1,316,781 with a provider's model listed by an id of the user's (zeewell on X), the provider editor's Names & levels Listed as box beside Same as, the core's own editor, with no room added (10-31); 1,316,874 with a package manager's magpie (the AUR's magpie-bin) naming the command that updates it in Settings' Version row and lighting no Update pill (shuhai on Discord), the core's own update row, which the tray panel reads too, its comments cut to one line, with no room added (10-31); Settings › Sync's Kept on this computer row (hayden4608 on Discord) raised it to 1,317,497, which is no bound; the 1,316,874 it had came back once later trims left app.js at 1,308,363 (10-31) - coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10); the daily check-in's time of day (times_ang on X), its row in checkinnow.js, its one call in app.js, went over it at 1,534,281 on a main that had grown under it, and six check-in comments cut brought it back to 1,533,495, no raise (11-10); Codex's service tier row (JackyFill on X), in app.js, paid for by eight Codex-row comments cut, no raise (11-10) + coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10); the daily check-in's time of day (times_ang on X), its row in checkinnow.js, its one call in app.js, went over it at 1,534,281 on a main that had grown under it, and six check-in comments cut brought it back to 1,533,495, no raise (11-10); Codex's service tier row (JackyFill on X), in app.js, paid for by eight Codex-row comments cut, no raise (11-10); the panel's Usage tab putting a vendor's account first from its count (RealZeroP27 on X), its menu in panelfirst.js, loaded when the count is pressed, paid for by the Allowances tab's arranging moved out to panelarrange.js, loaded when Arrange is pressed, no comments cut, no raise (11-10) ) func TestCoreScriptBudget(t *testing.T) { diff --git a/internal/gui/tests/old-webkit.test.cjs b/internal/gui/tests/old-webkit.test.cjs index 120819396..8c4af5e04 100644 --- a/internal/gui/tests/old-webkit.test.cjs +++ b/internal/gui/tests/old-webkit.test.cjs @@ -163,10 +163,12 @@ test("compat.js is the first of the page's own scripts", async () => { // balance, modellimits.js when it draws a model's row, notices.js when // About's Open-source licenses opens, videogen.js when Settings draws // Image generation, provlinks.js when Settings' search first wants its - // provider links, pageshare.js when a plugin's page shares a picture; + // provider links, pageshare.js when a plugin's page shares a picture, + // panelfirst.js when the panel's Usage tab's account count is pressed, + // panelarrange.js when its Allowances tab's Arrange is; // the checks above // still read them - for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); + for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); }); test("the styles hold up in Safari 15.0", async () => { diff --git a/internal/gui/tests/panel-usage-first-account.test.cjs b/internal/gui/tests/panel-usage-first-account.test.cjs new file mode 100644 index 000000000..ab2b6f3e7 --- /dev/null +++ b/internal/gui/tests/panel-usage-first-account.test.cjs @@ -0,0 +1,217 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// RealZeroP27 on X: switch which Codex account is used from the tray +// panel's Usage tab, not only from the Providers page. A vendor with +// several accounts has its count in the group's heading open the app's +// menu (never a