shangyuan0818 on X: "Claude Ultra 订阅在最新 magpie 中仍显示为 Max,而
ChatGPT Pro 100 订阅显示为 Pro Lite 这种根本不存在的订阅".
Claude: Claude Code writes subscriptionType "max" for both Max plans and
tells them apart only by rateLimitTier (default_claude_max_20x is Ultra).
The account chip already went through claudePlan, but the Usage card of
the one signed-in Claude account (claudeSubscriptionUsage) took
`claude auth status`'s raw "max". It is now named as the account is,
through one helper (claudeLivePlan) shared with claudeAccount, a sign-in
(claudeLogin), a saved login and the live login. When the credentials
carry no tier, Claude's own plan name decides: /api/oauth/profile's
organization.plan_display_name, kept by Claude Code as
oauthAccount.planDisplayName, which Claude Code 2.1.316 shows as
"Claude <name>". A known tier always wins, so a profile left from
another account can't rename a 5x one. Checked read-only against the
owner's accounts with saved tokens: the 20x ones answer
plan_display_name "Ultra" with tier default_claude_max_20x, the 5x one
no plan_display_name.
ChatGPT: planName mapped prolite to "Pro Lite" and promax to "Pro Max".
ChatGPT.app 26.1029.61003's bundle names them "Pro 100" and "Pro 500"
(and pro "Pro 200"). prolite and promax now read Pro 100 and Pro 500.
Plain "pro" stays Pro: Claude's and Grok's plans share that id, and
scoping it to ChatGPT put app.js over its code budget.
Run (mote, at this head on c38753a7e):
- go test ./internal/provider (149s) ok, before the rebase;
go test -run Claude ./internal/provider and go test ./internal/gui ok
at this head.
- red on the old code: TestClaudeUsageCardPlanIsUltra (Usage card plan
"max", want "ultra"; account plan "max" with no tier) and
TestClaudeSavedPlanFromProfileName (sign-in "max"); plan-name-fits
"Pro Lite", want "Pro 100".
- node --test plan-name-fits, routing-codex-seats,
routing-model-chip-whole, routing-twin-logo, i18n-keys: 134 of 134,
Chromium and WebKit, five languages (the GUI files naming a ChatGPT
plan id); plan-name-fits and i18n-keys again at this head.
- gofmt -l clean; go vet ./internal/provider for linux, windows and
darwin, ./internal/gui for windows and darwin.
Not tried: a real ChatGPT prolite or promax account (the owner's are pro
and plus); a real Claude account with no rateLimitTier; the whole GUI
suite (only the files that name a ChatGPT plan id).
165 lines
11 KiB
JavaScript
165 lines
11 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// visamzh on X: a ChatGPT Business seat's plan, as /wham/usage names it
|
|
// (self_serve_business_prolite), was shown as it came, and on the Usage
|
|
// page's Codex card it pushed each account's name out of its row. A plan
|
|
// id is named as the vendor's own app names it (ChatGPT's Business), and
|
|
// any plan too long for its row gives its room up first: cut with "…",
|
|
// its whole text in its tooltip, the account's name still read. Checked
|
|
// on the Usage page's card (the account rows, the card's head and the
|
|
// "All accounts" strip), the tray panel's Allowances tab and the provider
|
|
// editor's account rows, five languages, wide and narrow, Chromium and
|
|
// WebKit. No backend; the API is faked here.
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
|
|
const assets = path.resolve(__dirname, "../assets");
|
|
const later = new Date(Date.now() + 3 * 864e5).toISOString();
|
|
const LONG = "Coding Plan Pro Max Ultra Enterprise Seat for the whole team";
|
|
const UNNAMED = "self_serve_business_flex_usage_based_credits";
|
|
const quotas = [
|
|
{ provider: "codex", name: "Codex", icon: "codex-color", user: "siaorhm.long.name@example.com", plan: "self_serve_business_prolite",
|
|
windows: [{ name: "7 days", used: 20, resetsAt: later }], resets: { count: 2, until: later } },
|
|
{ provider: "codex", name: "Codex", icon: "codex-color", user: "second.seat@example.com", plan: "self_serve_business_prolite",
|
|
windows: [{ name: "7 days", used: 7, resetsAt: later }], resets: { count: 1, until: later } },
|
|
// shangyuan0818 on X: ChatGPT's $100 Pro, plan_type prolite, read "Pro
|
|
// Lite", a plan ChatGPT never sold; its app calls it Pro 100
|
|
{ provider: "codex", name: "Codex", icon: "codex-color", user: "pro100.account@example.com", plan: "prolite",
|
|
windows: [{ name: "5 hours", used: 7, resetsAt: later }, { name: "7 days", used: 64, resetsAt: later }], resets: { count: 1, until: later } },
|
|
// a plan id no app has named yet: shown as it comes, and cut
|
|
{ provider: "codex", name: "Codex", icon: "codex-color", user: "next.seat@example.com", plan: UNNAMED,
|
|
windows: [{ name: "7 days", used: 3, resetsAt: later }] },
|
|
// one account of a vendor whose plan is long in its own words: named in
|
|
// the card's head, and alone in its group on the panel
|
|
{ provider: "volc", name: "Volcengine", icon: "volcengine-color", plan: LONG, until: later, renew: "auto",
|
|
windows: [{ name: "5 hours", used: 30, resetsAt: later }] },
|
|
];
|
|
const codex = {
|
|
id: "codex", name: "Codex", icon: "codex-color", chat: "", responses: "", anthropic: "", catalog: "", routing: "",
|
|
models: [{ id: "gpt-6", name: "GPT-6", on: true }], agents: [], fallback: [], headers: {}, keyList: [],
|
|
account: {
|
|
agent: "codex", agentName: "Codex", agentIcon: "codex-color", user: "siaorhm.long.name@example.com", plan: "self_serve_business_prolite",
|
|
logins: [
|
|
{ user: "siaorhm.long.name@example.com", plan: "self_serve_business_prolite", active: true, on: true },
|
|
{ user: "plus.account@example.com", plan: "plus", on: true },
|
|
],
|
|
},
|
|
};
|
|
const serve = (lang) => {
|
|
const settings = { theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", trayUsages: ["codex", "volc"], codexAutoReset: ["siaorhm.long.name@example.com", "second.seat@example.com", "plus.account@example.com"] };
|
|
return async (route) => {
|
|
const url = new URL(route.request().url()), json = (data) => route.fulfill({ json: data });
|
|
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: "light", web: false })};` });
|
|
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings });
|
|
if (url.pathname === "/api/settings") return json(settings);
|
|
if (url.pathname === "/api/providers") return json({ providers: [codex], presets: [], excluded: [], gateway: { running: true, window: true } });
|
|
if (url.pathname === "/api/usage/quotas") return json(quotas);
|
|
if (url.pathname === "/api/usage/quotas/history") return json([]);
|
|
if (url.pathname === "/api/usage") return json({ calls: 0, cost: 0, days: [], agents: [], models: [], keys: [] });
|
|
if (url.pathname === "/api/login/usage") return json({});
|
|
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
|
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
|
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
|
};
|
|
};
|
|
|
|
// measure: each part's box under root, whether it is cut, and whether it
|
|
// stays inside root, read in one go from the page as it is now (a redraw
|
|
// between finding a node and reading it would leave a detached, empty box)
|
|
const measure = (page, root, parts) => page.evaluate(([root, parts]) => {
|
|
const r = document.querySelector(root), c = r.getBoundingClientRect();
|
|
const m = (e) => {
|
|
const b = e.getBoundingClientRect();
|
|
return { cls: e.className, w: b.width, cut: e.scrollWidth > e.clientWidth + 1, inside: b.left >= c.left - 1 && b.right <= c.right + 1, text: e.textContent, title: e.title };
|
|
};
|
|
const out = {};
|
|
for (const [k, sel] of Object.entries(parts)) out[k] = sel === "*rows" ? [...r.querySelectorAll(".subscription-account")].map((row) => ({
|
|
user: m(row.querySelector(".user")), plan: m(row.querySelector(".plan")),
|
|
kids: [...row.children].filter((k) => k.getClientRects().length).map(m),
|
|
})) : m(r.querySelector(sel));
|
|
return out;
|
|
}, [root, parts]);
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
|
test(`${engine} ${lang}: a long plan name never pushes an account's name out`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
const errors = [];
|
|
const open = async (url, viewport, init) => {
|
|
const page = await (await browser.newContext({ viewport, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(8000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
if (init) await page.addInitScript(init);
|
|
await page.route("**/*", serve(lang));
|
|
await page.goto(url);
|
|
return page;
|
|
};
|
|
|
|
for (const width of [1100, 760, 420]) {
|
|
const at = `${lang} ${width}`;
|
|
const page = await open("http://magpie.test/?view=usage", { width, height: 900 });
|
|
const codex = '#subscriptionUsage .subscription-card[data-provider="codex"]';
|
|
await page.locator(codex + " .subscription-account").nth(3).waitFor();
|
|
const { rows } = await measure(page, codex, { rows: "*rows" });
|
|
assert.equal(rows.length, 4, `${at}: four accounts`);
|
|
rows.forEach(({ user, plan, kids }, i) => {
|
|
assert.ok(user.w >= 60, `${at} row ${i}: the account's name is read (${user.w}px of ${user.text})`);
|
|
for (const k of kids) assert.ok(k.inside, `${at} row ${i}: ${k.cls} stays inside the card`);
|
|
assert.equal(plan.text, ["Business", "Business", "Pro 100", UNNAMED][i], `${at} row ${i}: the plan as ChatGPT names it`);
|
|
assert.equal(plan.title, plan.text, `${at} row ${i}: the plan's tooltip`);
|
|
});
|
|
// "All accounts": its windows by plan, named as the rows name them
|
|
const all = await page.locator(codex + " .quota-all-name").allTextContents();
|
|
assert.ok(all.length && all.every((s) => !s.includes("_")), `${at}: the strip names no plan id (${all.join(" | ")})`);
|
|
assert.ok(all.some((s) => s.includes("Business")), `${at}: the strip says Business`);
|
|
|
|
// a card named in its head, its plan long: the plan is cut, the name read
|
|
const { name, plan } = await measure(page, '#subscriptionUsage .subscription-card[data-provider="volc"]', { name: ".subscription-head > b", plan: ".subscription-head > .plan" });
|
|
assert.ok(name.w >= 40 && !name.cut, `${at}: the card's name is read whole (${name.w}px)`);
|
|
assert.ok(plan.inside, `${at}: the long plan stays inside the card`);
|
|
assert.ok(plan.text.startsWith(LONG) && plan.title.startsWith(LONG), `${at}: the long plan's whole text, and in its tooltip`);
|
|
const wide = await page.evaluate(() => document.scrollingElement.scrollWidth - document.scrollingElement.clientWidth);
|
|
assert.ok(wide <= 0, `${at}: the page doesn't scroll sideways (${wide}px)`);
|
|
await page.context().close();
|
|
}
|
|
|
|
// the tray panel: the long plan alone in its group's head, cut, the name read
|
|
for (const width of [440, 360]) {
|
|
const at = `${lang} panel ${width}`;
|
|
const page = await open("http://magpie.test/?mode=panel", { width, height: 700 }, () => { try { localStorage.setItem("magpie.panelTab", "usage"); } catch {} });
|
|
await page.locator("#panelQuota .pq-group[data-provider=\"volc\"] .pq-gnote").waitFor();
|
|
const { name, note } = await measure(page, '#panelQuota .pq-group[data-provider="volc"] .pq-gh', { name: ".pq-gn", note: ".pq-gnote" });
|
|
assert.ok(name.w >= 40 && !name.cut, `${at}: the group's name is read whole (${name.w}px)`);
|
|
assert.ok(note.inside && note.cut, `${at}: the long plan is cut inside the head`);
|
|
assert.ok(note.title.startsWith(LONG), `${at}: the whole plan in its tooltip`);
|
|
const cards = await page.locator("#panelQuota .pq-card").evaluateAll((cs) => cs.map((c) => c.title));
|
|
assert.ok(cards.length && cards.every((s) => !s.includes("self_serve")), `${at}: the cards' tooltips name no plan id`);
|
|
await page.context().close();
|
|
}
|
|
|
|
// the provider editor: the account rows' chip and the sheet
|
|
for (const width of [1000, 560]) {
|
|
const at = `${lang} editor ${width}`;
|
|
const page = await open("http://magpie.test/?view=providers", { width, height: 900 });
|
|
await page.locator(".row.provider", { hasText: "Codex" }).first().click();
|
|
const row = '.editor .accts .acc[data-account-id="siaorhm.long.name@example.com"]';
|
|
await page.locator(row).waitFor();
|
|
const { chip } = await measure(page, row, { chip: ".acc-line > .plan" });
|
|
assert.equal(chip.text, "ChatGPT Business", `${at}: the chip names ChatGPT's Business`);
|
|
assert.equal(chip.title, chip.text, `${at}: the chip's tooltip`);
|
|
assert.ok(chip.inside, `${at}: the chip stays inside its row`);
|
|
await page.context().close();
|
|
}
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|