Repository navigation
fix(server): avoid replaying stale Codex usage limits #26331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,29 @@ describe("codexRateLimitsToLimits", () => { | |
| }); | ||
|
|
||
| describe("codexRateLimitsToUpdate", () => { | ||
| it("does not republish cached windows over a newer account probe", () => { | ||
| const cached = { | ||
| primary: { usedPercent: 0, resetsAt: 1_784_000_000, windowDurationMins: 300 }, | ||
| secondary: { usedPercent: 20, resetsAt: 1_784_500_000, windowDurationMins: 10080 }, | ||
| }; | ||
| expect(codexRateLimitsToUpdate(cached)?.windows).toHaveLength(2); | ||
| expect(codexRateLimitsToUpdate(structuredClone(cached), cached)).toBeUndefined(); | ||
|
|
||
| const changed = { ...cached, secondary: { ...cached.secondary, usedPercent: 21 } }; | ||
| expect(codexRateLimitsToUpdate(changed, cached)?.windows.map((window) => window.id)).toEqual([ | ||
| "secondary", | ||
| ]); | ||
| expect(codexRateLimitsToUpdate({ primary: cached.primary }, cached)).toBeUndefined(); | ||
| expect( | ||
| codexRateLimitsToUpdate({ primary: { ...cached.primary, resetsAt: 1_784_001_000 } }, cached) | ||
| ?.windows, | ||
| ).toHaveLength(1); | ||
| expect( | ||
| codexRateLimitsToUpdate({ primary: { ...cached.primary, usedPercent: 76 } }, cached) | ||
| ?.windows[0]?.usedPercent, | ||
| ).toBe(76); | ||
| }); | ||
|
|
||
|
Comment on lines
+131
to
+153
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| it("carries only the windows the notification names", () => { | ||
| expect( | ||
| codexRateLimitsToUpdate({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compare the merged snapshot before publishing.
If a Free plan has a duration-less primary window, a plan-only update to Plus changes
rateLimitSnapshotbut publishes no window. The next notification with the same primary value is then filtered out, so the UI keeps showing a monthly window until usage changes. Compare the merged snapshot withpreviousso plan changes publish affected windows. Add a regression test for this sequence.As per path instructions: “For a logic, data, state, or protocol bug fix, provide a failing test first.”
Source: Path instructions