GeezerVison is showing github.com — fix(server): Codex seat workspaces with a zero credit cap are no long… · pingdotgg/t3code@69a5396
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: apps/server/src/provider/codexUsageLimits.test.ts +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,6 +39,22 @@ describe("codexRateLimitsToLimits", () => { |
39 | 39 | expect(codexRateLimitsToUpdate(snapshot)).toEqual({ windows }); |
40 | 40 | }); |
41 | 41 |
|
| 42 | + it("leaves out a zero credit cap on seat-based workspaces", () => { |
| 43 | + const snapshot = { |
| 44 | + limitId: "codex", |
| 45 | + planType: "team", |
| 46 | + primary: { usedPercent: 0, windowDurationMins: 300 }, |
| 47 | + secondary: { usedPercent: 14, windowDurationMins: 10080 }, |
| 48 | + individualLimit: { limit: "0", remainingPercent: 0, resetsAt: 1_796_083_200 }, |
| 49 | + }; |
| 50 | + |
| 51 | + expect(codexRateLimitsToLimits({ checkedAt, snapshot }).windows.map((w) => w.id)).toEqual([ |
| 52 | + "primary", |
| 53 | + "secondary", |
| 54 | + ]); |
| 55 | + expect(codexUsageLimitResetAt(snapshot)).toBeNull(); |
| 56 | + }); |
| 57 | + |
42 | 58 | it("maps primary and secondary onto the session and weekly windows", () => { |
43 | 59 | expect( |
44 | 60 | codexRateLimitsToLimits({ |
|
Collapse file
Copy file name to clipboardExpand all lines: apps/server/src/provider/codexUsageLimits.ts +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,7 @@ export interface CodexRateLimitSnapshot { |
23 | 23 | readonly primary?: CodexRateLimitWindow | null; |
24 | 24 | readonly secondary?: CodexRateLimitWindow | null; |
25 | 25 | readonly individualLimit?: { |
| 26 | + readonly limit?: string; |
26 | 27 | readonly remainingPercent: number; |
27 | 28 | readonly resetsAt: number; |
28 | 29 | } | null; |
@@ -84,7 +85,12 @@ function codexRateLimitsToWindows( |
84 | 85 | }); |
85 | 86 | } |
86 | 87 | const individualLimit = snapshot.individualLimit; |
87 | | - if (individualLimit && Number.isFinite(individualLimit.remainingPercent)) { |
| 88 | + // Seat-based workspaces report a 0 credit cap that only applies once the seat allowance runs out. |
| 89 | + if ( |
| 90 | + individualLimit && |
| 91 | + Number.isFinite(individualLimit.remainingPercent) && |
| 92 | + Number(individualLimit.limit) !== 0 |
| 93 | + ) { |
88 | 94 | const resetsAt = isoFromEpochSeconds(individualLimit.resetsAt); |
89 | 95 | windows.push({ |
90 | 96 | id: "individual", |
|