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 onto55b0d7c24, 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() fromd374168d0, 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.
27 lines
1.5 KiB
JavaScript
27 lines
1.5 KiB
JavaScript
// 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");
|
|
};
|