fix(plan): a Claude plan is the one Anthropic reports now, not the sign-in's
An account signed in on Pro and upgraded to Max 5x kept showing "Pro": the plan was read only from .credentials.json / .claude.json, whose subscriptionType and rate-limit tiers are written at sign-in. fetchOwner already asks GET /api/oauth/profile for a token's owner; it now also reads organization_type / rate_limit_tier / seat_tier into a plan (planFromProfile), remembered per account uuid (rememberLivePlan). The live row, saved profiles (identityOf) and pool accounts (poolStatus, whose quota refresh now asks a login's owner too) show that plan when one was seen (shownPlan), else planLabel of the files as before.
This commit is contained in:
@@ -448,8 +448,14 @@ describe("cc-profiles — identity and token disagree", () => {
|
||||
it("planLabel reads the plan from the rate-limit tier and seat, not subscriptionType alone", () => {
|
||||
const { planLabel } = profiles;
|
||||
// An upgrade keeps `subscriptionType: "pro"` from sign-in; the tier is the truth.
|
||||
assert.strictEqual(planLabel({ subscriptionType: "pro", rateLimitTier: "default_claude_max_5x" }, null), "Max 5x");
|
||||
assert.strictEqual(planLabel({ subscriptionType: "max", rateLimitTier: "default_claude_max_20x" }, null), "Max 20x");
|
||||
assert.strictEqual(
|
||||
planLabel({ subscriptionType: "pro", rateLimitTier: "default_claude_max_5x" }, null),
|
||||
"Max 5x"
|
||||
);
|
||||
assert.strictEqual(
|
||||
planLabel({ subscriptionType: "max", rateLimitTier: "default_claude_max_20x" }, null),
|
||||
"Max 20x"
|
||||
);
|
||||
assert.strictEqual(planLabel({ subscriptionType: "pro" }, null), "Pro");
|
||||
const team = { subscriptionType: "team", rateLimitTier: "default_raven" };
|
||||
assert.strictEqual(planLabel(team, { seatTier: "team_standard" }), "Team Standard");
|
||||
@@ -462,3 +468,31 @@ it("planLabel reads the plan from the rate-limit tier and seat, not subscription
|
||||
assert.strictEqual(planLabel(team, null), "Team");
|
||||
assert.strictEqual(planLabel(null, null), null);
|
||||
});
|
||||
|
||||
it("the profile endpoint's live plan wins over files written at sign-in", () => {
|
||||
const { planFromProfile, rememberLivePlan, shownPlan } = profiles;
|
||||
assert.strictEqual(
|
||||
planFromProfile({ organization_type: "claude_max", rate_limit_tier: "default_claude_max_5x" }),
|
||||
"Max 5x"
|
||||
);
|
||||
assert.strictEqual(
|
||||
planFromProfile({
|
||||
organization_type: "claude_team",
|
||||
rate_limit_tier: "default_raven",
|
||||
seat_tier: "team_standard",
|
||||
}),
|
||||
"Team Standard"
|
||||
);
|
||||
assert.strictEqual(planFromProfile({ organization_type: "claude_pro" }), "Pro");
|
||||
assert.strictEqual(planFromProfile(null), null);
|
||||
|
||||
// Signed in on Pro, upgraded to Max 5x since: the files still say Pro.
|
||||
const oauth = { subscriptionType: "pro", rateLimitTier: "default_claude_pro" };
|
||||
const account = { accountUuid: "acct-upgraded" };
|
||||
assert.strictEqual(shownPlan(oauth, account), "Pro");
|
||||
rememberLivePlan("acct-upgraded", "Max 5x");
|
||||
assert.strictEqual(shownPlan(oauth, account), "Max 5x");
|
||||
rememberLivePlan("acct-upgraded", null); // an unknown answer keeps the last one
|
||||
assert.strictEqual(shownPlan(oauth, account), "Max 5x");
|
||||
assert.strictEqual(shownPlan(oauth, { accountUuid: "other" }), "Pro");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user