fix(usage): keep same-email Codex subscriptions apart when their plans differ #10845
Closedtan7vir(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/10845/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -152,0 +157,21 @@157+ * behind the same address are two independent quotas, not one. An unset plan158+ * on either side does not split the group: callers do not always know a159+ * subscription's plan, and treating unknown as a wildcard keeps the existing160+ * native/hub and multi-environment dedupe intact. `knownPlans` records the161+ * first plan seen per base key; pass one shared map per collection pass so162+ * every account examined agrees on which group is "the" unlabeled one.163+ */164+function accountGroupKey(165+ driver: ServerProvider["driver"],166+ email: string | undefined,167+ plan: string | undefined,168+ knownPlans: Map<string, string>,169+): string | null {170+ const base = accountKey(driver, email);171+ if (base === null || plan === undefined) return base;172+ const knownPlan = knownPlans.get(base);173+ if (knownPlan === undefined) {174+ knownPlans.set(base, plan);175+ return base;176+ }177+ return knownPlan === plan ? base : `${base}::${plan}`;
- packages/shared/src/usageLimits.test.ts line 441OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -391,0 +421,21 @@421+ {422+ ...source,423+ accounts: [424+ {425+ id: "codex-same@example.com.json",426+ driver: ProviderDriverKind.make("codex"),427+ email: "same@example.com",428+ plan: "ChatGPT Plus Subscription",429+ usageLimits: {430+ checkedAt: "2026-09-03T11:30:00.000Z",431+ windows: [{ ...window, usedPercent: 55 }],432+ },433+ },434+ ],435+ },436+ ],437+ },438+ },439+ ],440+ ]);441+ expect(collectLimitAccounts(input)).toHaveLength(1);
juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
8c5bedce-09df-451a-864f-adc8627f4560📥 Commits
Reviewing files that changed from the base of the PR and between 38e53e6963957cef7c90dc8691c91b5b0a3f079b and 47b28f48750332e1e47d21c438e3922399765516.
📒 Files selected for processing (1)
packages/shared/src/usageLimits.test.ts🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough#
Usage limit grouping now separates same-email subscriptions when their plan strings differ. Native and hub accounts still merge when their plans match. Claude OAuth usage no longer assigns a hardcoded plan.
Changes#
Usage limit account grouping
packages/shared/src/usageLimits.tscollectLimitSourcesandaccountGroupKeyretain separate groups for differing plans while treating unset plans as wildcards.packages/shared/src/usageLimits.ts,apps/server/src/usage/cliproxyApi.tscollectLimitAccountsapplies plan-aware keys to native and hub accounts. Claude OAuth usage leaves the plan unset.packages/shared/src/usageLimits.test.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
47b28This change separates same-email Codex subscriptions with different plans while preserving intended merging for matching or unset plans, and removes unsupported Claude plan labels. No current merge-readiness risk remains.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#10835by separating same-email Codex subscriptions with different plans, preserving matching-plan merges, and treating unset plans as compatible. The shared grouping logic a…✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.