-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(codex): show the five-hour quota on account cards (#2616) #2620
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 |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| export interface AccountQuota { | ||
| weeklyPercent?: number; | ||
| fiveHourPercent?: number; | ||
| /** Codex account API aliases for the same five-hour window. */ | ||
| shortPercent?: number; | ||
| monthlyPercent?: number; | ||
| weeklyResetAt?: number; | ||
| fiveHourResetAt?: number; | ||
| shortResetAt?: number; | ||
| monthlyResetAt?: number; | ||
| customWindows?: { label: string; percent: number; resetAt?: number }[]; | ||
| resetCredits?: number; | ||
|
|
@@ -16,11 +19,19 @@ export function isThirtyDayOnlyPlan(plan: string | null | undefined): boolean { | |
| } | ||
|
|
||
| export function normalizeQuotaForPlan(quota: AccountQuota | null, plan: string | null | undefined): AccountQuota | null { | ||
| if (!quota || !isThirtyDayOnlyPlan(plan)) return quota; | ||
| if (!quota) return null; | ||
| const normalized = quota.shortPercent === undefined && quota.shortResetAt === undefined | ||
| ? quota | ||
| : { | ||
| ...quota, | ||
| fiveHourPercent: quota.fiveHourPercent ?? quota.shortPercent, | ||
| fiveHourResetAt: quota.fiveHourResetAt ?? quota.shortResetAt, | ||
| }; | ||
| if (!isThirtyDayOnlyPlan(plan)) return normalized; | ||
| return { | ||
| ...(quota.monthlyPercent !== undefined ? { monthlyPercent: quota.monthlyPercent } : {}), | ||
| ...(quota.monthlyResetAt !== undefined ? { monthlyResetAt: quota.monthlyResetAt } : {}), | ||
| ...(quota.resetCredits !== undefined ? { resetCredits: quota.resetCredits } : {}), | ||
| updatedAt: quota.updatedAt, | ||
| ...(normalized.monthlyPercent !== undefined ? { monthlyPercent: normalized.monthlyPercent } : {}), | ||
| ...(normalized.monthlyResetAt !== undefined ? { monthlyResetAt: normalized.monthlyResetAt } : {}), | ||
| ...(normalized.resetCredits !== undefined ? { resetCredits: normalized.resetCredits } : {}), | ||
|
Comment on lines
+30
to
+34
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.
For a Go or Free account whose API quota contains both a healthy monthly window and an exhausted AGENTS.md reference: gui/AGENTS.md:L10-L10 Useful? React with 👍 / 👎. |
||
| updatedAt: normalized.updatedAt, | ||
| }; | ||
| } | ||
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.
When WHAM supplies any explicitly sub-day primary window,
src/codex/quota.tsstores it asshortPercentand retainsshortWindowSecondsprecisely because the slot is not duration-stable; this mapping instead converts every such value to the GUI's fixed “five-hour” row. A one-hour or twelve-hour limit would consequently be shown with the wrong duration. CarryshortWindowSecondsintoAccountQuotaand only use the five-hour alias when the duration is five hours, or render a duration-aware burst label.AGENTS.md reference: gui/AGENTS.md:L10-L10
Useful? React with 👍 / 👎.