From 3c4a03985519c5487eb42ff023d56738b5953cea Mon Sep 17 00:00:00 2001 From: Terry Tan Date: Mon, 10 Aug 2026 18:38:23 -0700 Subject: [PATCH 1/2] fix: recognize legacy Team capacity Treat upstream plan 'team' as the Business-tier configured weight so valid Codex pools are not excluded from dashboard capacity estimates. --- src/providers/codex-capacity.ts | 1 + tests/provider-capacity.test.ts | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/providers/codex-capacity.ts b/src/providers/codex-capacity.ts index 2cb2dc4864..be40a2eb60 100644 --- a/src/providers/codex-capacity.ts +++ b/src/providers/codex-capacity.ts @@ -2,6 +2,7 @@ import { codexPlanKey, codexPlanValue } from "../codex/plan"; export const CODEX_CONFIGURED_CAPACITY_WEIGHTS = { plus: 1, + team: 1, business: 1, prolite: 5, pro: 20, diff --git a/tests/provider-capacity.test.ts b/tests/provider-capacity.test.ts index 42508e8d59..be54754840 100644 --- a/tests/provider-capacity.test.ts +++ b/tests/provider-capacity.test.ts @@ -44,6 +44,20 @@ describe("configured-weight Codex pool capacity", () => { expect(aggregateCodexPoolCapacity(rows(9), NOW).quota?.weeklyPercent).toBeCloseTo(39.33333333, 8); }); + test("legacy Team and Business plans share configured weight", () => { + const result = aggregateCodexPoolCapacity([ + account("team", 20, { isMain: true, active: true }), + account("business", 60), + ], NOW); + expect(result.quota?.weeklyPercent).toBe(40); + expect(result.aggregation).toMatchObject({ + includedAccounts: 2, + excludedAccounts: 0, + unknownPlanAccounts: 0, + incomplete: false, + }); + }); + test("same-time resets group partial consumed capacity and expose only recovery percent", () => { const result = aggregateCodexPoolCapacity([ account("pro", 25, { weeklyResetAt: NOW + 10_000 }), @@ -66,7 +80,7 @@ describe("configured-weight Codex pool capacity", () => { test("unknown, missing, paused, and reauth rows are excluded with incomplete coverage", () => { const result = aggregateCodexPoolCapacity([ account("pro", 10, { active: true, isMain: true }), - account("team", 50), + account("future-plan", 50), account("plus", undefined), account("prolite", 20, { paused: true }), account("business", 30, { needsReauth: true }), @@ -109,7 +123,7 @@ describe("configured-weight Codex pool capacity", () => { ], NOW); expect(expired.aggregation?.weekly).not.toHaveProperty("nextRecoveryAt"); const fallback = aggregateCodexPoolCapacity([ - account("team", 70, { active: true, isMain: true }), + account("future-plan", 70, { active: true, isMain: true }), account("go", 80), ], NOW); expect(fallback.aggregation).toMatchObject({ @@ -209,7 +223,7 @@ describe("configured-weight Codex pool capacity", () => { const stale = account("pro", 90); stale.quota = { ...stale.quota!, updatedAt: NOW - CODEX_CAPACITY_MAX_QUOTA_AGE_MS - 1 }; const result = aggregateCodexPoolCapacity([ - account("team", 10, { active: true, isMain: true }), + account("future-plan", 10, { active: true, isMain: true }), account("plus", undefined), account("prolite", 20, { paused: true }), account("business", 30, { needsReauth: true }), From b0885837234ef8d804313a29d3463abd16fd16b9 Mon Sep 17 00:00:00 2001 From: Wibias <37517432+Wibias@users.noreply.github.com> Date: Tue, 11 Aug 2026 06:19:34 +0200 Subject: [PATCH 2/2] test: add all-Team pool capacity regression --- tests/provider-capacity.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/provider-capacity.test.ts b/tests/provider-capacity.test.ts index be54754840..a10572f9f8 100644 --- a/tests/provider-capacity.test.ts +++ b/tests/provider-capacity.test.ts @@ -58,6 +58,20 @@ describe("configured-weight Codex pool capacity", () => { }); }); + test("an all-Team pool has complete configured-weight coverage", () => { + const result = aggregateCodexPoolCapacity([ + account("team", 20, { isMain: true, active: true }), + account("team", 60), + ], NOW); + expect(result.quota?.weeklyPercent).toBe(40); + expect(result.aggregation).toMatchObject({ + includedAccounts: 2, + excludedAccounts: 0, + unknownPlanAccounts: 0, + incomplete: false, + }); + }); + test("same-time resets group partial consumed capacity and expose only recovery percent", () => { const result = aggregateCodexPoolCapacity([ account("pro", 25, { weeklyResetAt: NOW + 10_000 }),