usage: a Claude Ultra account reads Ultra on its Usage card, and ChatGPT's $100 Pro reads Pro 100 (shangyuan0818 on X)

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).
This commit is contained in:
yetone
2026-11-16 14:19:19 +08:00
parent b1dd96ab14
commit 58cf764533
7 changed files with 133 additions and 16 deletions
+5 -2
View File
@@ -17186,8 +17186,11 @@ function planTerm(q) {
return t(q.renew === "auto" ? "Renews {date}" : q.renew === "off" ? "Expires {date}" : "Until {date}", { date });
}
// planName: a plan id as the vendor's own app names it (visamzh on X:
// ChatGPT's self_serve_business_prolite is its Business)
const PLAN_NAMES = { self_serve_business_prolite: "Business", self_serve_business_usage_based: "Business", free_workspace: "Free", ent26: "Enterprise", prolite: "Pro Lite", promax: "Pro Max", edu_plus: "Edu Plus", edu_pro: "Edu Pro" };
// ChatGPT's self_serve_business_prolite is its Business). ChatGPT's app
// names its Pro plans by price: prolite Pro 100, promax Pro 500
// (shangyuan0818 on X: "Pro Lite" is no plan it sells). Its plain pro
// stays Pro, as Claude's and Grok's pro share the id
const PLAN_NAMES = { self_serve_business_prolite: "Business", self_serve_business_usage_based: "Business", free_workspace: "Free", ent26: "Enterprise", prolite: "Pro 100", promax: "Pro 500", edu_plus: "Edu Plus", edu_pro: "Edu Pro" };
const planName = (p) => p && (PLAN_NAMES[p] || (/^enterprise_cbp_/.test(p) ? "Enterprise" : p));
const planChip = (s) => Object.assign(el("span", "plan", s), { title: s });
function planSpan(q) {
+4 -2
View File
@@ -24,7 +24,9 @@ const quotas = [
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 } },
{ provider: "codex", name: "Codex", icon: "codex-color", user: "plus.account@example.com", plan: "plus",
// 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,
@@ -111,7 +113,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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", "plus", UNNAMED][i], `${at} row ${i}: the plan as ChatGPT names it`);
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
+36 -6
View File
@@ -438,13 +438,46 @@ type claudeAuth struct {
// and tells the two apart only by the rate-limit tier.
func (a claudeAuth) plan() string { return claudePlan(a.SubscriptionType, a.RateLimitTier) }
func claudePlan(sub, tier string) string {
if sub == "max" && strings.Contains(tier, "max_20x") {
func claudePlan(sub, tier string) string { return claudePlanShown(sub, tier, "") }
// claudePlanShown is claudePlan with the name Claude itself shows the
// plan by: /api/oauth/profile's organization.plan_display_name, which
// Claude Code keeps as oauthAccount.planDisplayName and shows as
// "Claude <name>" ("Ultra" for a Max 20x account, none for Max 5x). A
// known tier decides; the name is read only when the tier doesn't say,
// so a profile left from another account can't rename this one.
func claudePlanShown(sub, tier, shown string) string {
if sub != "max" {
return sub
}
switch {
case strings.Contains(tier, "max_20x"):
return "ultra"
case strings.Contains(tier, "max_5x"):
return "max"
case strings.EqualFold(strings.TrimSpace(shown), "ultra"):
return "ultra"
}
return sub
}
// claudeShownPlan is the plan name in a Claude Code oauthAccount profile.
func claudeShownPlan(acct map[string]any) string {
s, _ := acct["planDisplayName"].(string)
return s
}
// claudeLivePlan is the plan of Claude Code's own sign-in c: the
// credentials', or `claude auth status`'s when it said one, named by the
// tier (claudePlanShown); acct is Claude Code's profile, nil when unread.
func claudeLivePlan(c claudeCredentials, statusPlan string, acct map[string]any) string {
sub := c.OAuth.SubscriptionType
if statusPlan != "" {
sub = statusPlan
}
return claudePlanShown(sub, c.OAuth.RateLimitTier, claudeShownPlan(acct))
}
// claudeCredentials keeps the whole credential blob in raw, so refreshing a
// token writes back everything else — MCP OAuth state included — untouched.
type claudeCredentials struct {
@@ -836,14 +869,11 @@ func claudeAccount() (Provider, bool) {
if signedOut {
return claudeStandInAccount()
}
plan := c.OAuth.plan()
if statusPlan != "" {
plan = claudePlan(statusPlan, c.OAuth.RateLimitTier)
}
// named as its saved login is (liveLogin): it is then the account Logins
// flags Active, not served a second time beside itself, and its
// allowances and limits are found under its name (#177)
user, acct := claudeSignedInUser(c.OAuth.SubscriptionType, statusPlan, user)
plan := claudeLivePlan(c, statusPlan, acct)
if b, err := c.marshal(); err == nil && user != "" {
// by its sign-in when its profile is another's (claudeSignInOwner)
l := savedLogin{Agent: "claude", User: user, Auth: b}
+75
View File
@@ -1,8 +1,14 @@
package provider
import (
"context"
"encoding/json"
"path/filepath"
"sync/atomic"
"testing"
"time"
"github.com/yetone/magpie/internal/testenv"
)
// Claude Max 20x is sold as Claude Ultra now, but Claude Code still says
@@ -61,3 +67,72 @@ func TestClaudeMax20xIsUltra(t *testing.T) {
t.Fatalf("a held Ultra account renewed under another profile isn't found: %v %v", h.User, ok)
}
}
// The Usage card of Claude Code's own sign-in, the only Claude account,
// named its plan by `claude auth status`, which says "max" for Max 20x
// too: an Ultra account read "Max" (shangyuan0818 on X). It is named as
// the account is. Credentials and profile are shaped as Claude Code 2.1
// writes them; plan_display_name is what /api/oauth/profile answers
// (organization.plan_display_name "Ultra" for a 20x account, none for 5x).
func TestClaudeUsageCardPlanIsUltra(t *testing.T) {
for _, c := range []struct {
name, tier, shown, want string
}{
{"20x", "default_claude_max_20x", "Ultra", "ultra"},
{"20x, profile not yet read", "default_claude_max_20x", "", "ultra"},
{"no tier, Claude names it Ultra", "", "Ultra", "ultra"},
{"5x", "default_claude_max_5x", "", "max"},
// a profile left from another account doesn't rename a known tier
{"5x under a 20x profile", "default_claude_max_5x", "Ultra", "max"},
} {
t.Run(c.name, func(t *testing.T) {
home := claudeHome(t)
writeFile(t, filepath.Join(home, ".claude", ".credentials.json"), map[string]any{
"claudeAiOauth": map[string]any{
"accessToken": "sk-ant-oat01-a", "refreshToken": "sk-ant-ort01-a",
"expiresAt": time.Now().Add(time.Hour).UnixMilli(), "subscriptionType": "max",
"rateLimitTier": c.tier, "scopes": []string{"user:inference", "user:profile"},
},
})
acct := map[string]any{"emailAddress": "a@example.com", "billingType": "stripe_subscription"}
if c.shown != "" {
acct["planDisplayName"] = c.shown
}
writeFile(t, filepath.Join(home, ".claude.json"), map[string]any{"oauthAccount": acct})
dir := t.TempDir()
exe := filepath.Join(dir, "claude")
testenv.Program(t, exe, "#!/bin/sh\necho '{\"loggedIn\":true,\"authMethod\":\"claude.ai\",\"apiProvider\":\"firstParty\",\"email\":\"a@example.com\",\"subscriptionType\":\"max\"}'\n")
old := claudeExecutable
claudeExecutable = func() string { return exe }
t.Cleanup(func() { claudeExecutable = old; forgetClaudeStatus() })
forgetClaudeStatus()
var out atomic.Value
out.Store("Current session: 40% used")
fakeClaudeUsage(t, &out, nil)
if q := claudeSubscriptionUsage(context.Background(), "a@example.com"); q.Plan != c.want {
t.Errorf("Usage card plan %q, want %q", q.Plan, c.want)
}
if p, ok := claudeAccount(); !ok || p.Account.Plan != c.want {
t.Errorf("account plan %v %q, want %q", ok, p.Account.Plan, c.want)
}
})
}
}
// A sign-in or saved account whose credentials carry no tier is named by
// the plan name Claude gave its profile.
func TestClaudeSavedPlanFromProfileName(t *testing.T) {
c, _ := parseClaudeCredentials([]byte(`{"claudeAiOauth":{"accessToken":"a","refreshToken":"r","subscriptionType":"max"}}`))
l, err := claudeLogin(c, map[string]any{"emailAddress": "u@example.com", "planDisplayName": "Ultra"})
if err != nil || l.Plan != "ultra" {
t.Fatalf("sign-in plan %q, %v; want ultra", l.Plan, err)
}
b, _ := json.Marshal([]savedLogin{{Agent: "claude", User: "u@example.com", Plan: "max",
Auth: json.RawMessage(`{"claudeAiOauth":{"accessToken":"a","refreshToken":"r","subscriptionType":"max"}}`),
Profile: json.RawMessage(`{"emailAddress":"u@example.com","planDisplayName":"Ultra"}`)}})
ls, err := parseLogins(b)
if err != nil || len(ls) != 1 || ls[0].Plan != "ultra" {
t.Fatalf("saved plan %+v %v; want ultra", ls, err)
}
}
+5 -2
View File
@@ -226,7 +226,9 @@ func parseLogins(b []byte) ([]savedLogin, error) {
// a Max 20x saved before it was named Ultra
if out[i].Agent == "claude" && out[i].Plan == "max" {
if c, ok := parseClaudeCredentials(out[i].Auth); ok {
out[i].Plan = claudePlan(out[i].Plan, c.OAuth.RateLimitTier)
var acct map[string]any
_ = json.Unmarshal(out[i].Profile, &acct)
out[i].Plan = claudePlanShown(out[i].Plan, c.OAuth.RateLimitTier, claudeShownPlan(acct))
}
}
}
@@ -869,12 +871,13 @@ func liveLogin(agent string) (savedLogin, bool) {
if signedOut {
return savedLogin{}, false
}
l := savedLogin{Agent: agent, Plan: c.OAuth.plan(), Auth: b}
l := savedLogin{Agent: agent, Auth: b}
var acct map[string]any
if l.User, acct = claudeSignedInUser(c.OAuth.SubscriptionType, plan, user); acct != nil {
l.Profile, _ = json.Marshal(acct)
l.HeldAs = claudeProfileKey(l.Profile)
}
l.Plan = claudeLivePlan(c, "", acct)
if l.User == "" {
return savedLogin{}, false
}
+1 -1
View File
@@ -838,7 +838,7 @@ func claudeLogin(c claudeCredentials, acct map[string]any) (savedLogin, error) {
return savedLogin{}, err
}
profile, _ := json.Marshal(acct)
return savedLogin{Agent: "claude", User: claudeUser(email, c.OAuth.SubscriptionType, acct), Plan: c.OAuth.plan(), Auth: auth, Profile: profile}, nil
return savedLogin{Agent: "claude", User: claudeUser(email, c.OAuth.SubscriptionType, acct), Plan: claudeLivePlan(c, "", acct), Auth: auth, Profile: profile}, nil
}
func codexExchange(ctx context.Context, code, verifier, redirect string) (savedLogin, error) {
+7 -3
View File
@@ -730,12 +730,16 @@ func (e *accountStatusError) Error() string { return http.StatusText(e.status) }
// a Team seat isn't the email alone `claude auth status` gives.
func claudeSubscriptionUsage(ctx context.Context, user string) SubscriptionQuota {
q := SubscriptionQuota{Provider: "claude", Name: "Claude Code", Icon: "claude-color", Windows: []QuotaWindow{}}
if _, _, ok := claudeCredential(); !ok {
c, _, ok := claudeCredential()
if !ok {
q.Error = "Claude Code is signed out; run claude auth login"
return q
}
_, plan, _ := claudeIdentity()
q.Plan = plan
// named as the account is (claudeAccount): `claude auth status` says
// "max" for Max 20x too, which Claude sells as Ultra (shangyuan0818 on X)
_, statusPlan, _ := claudeIdentity()
acct, _ := claudeProfileAccount()
q.Plan = claudeLivePlan(c, statusPlan, acct)
var err error
q.Windows, err = claudeWindows(ctx, user, true)
if err != nil {