mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
feat(quota): show Codex limit resets in the Plan tab, hover card and CLI
The Plan tab row #724 added showed a count and an expiry. It now also shows how many of those credits can be applied right now and when the most recent one landed, which is what a user deciding whether to push through or throttle back actually needs. The same sentence appears in the agent-tab quota hover card and in `codeburn quota`. One formatter produces it, mirrored line for line in Swift and TypeScript, down to the compact-age rules — deliberately not RelativeDateTimeFormatter or Intl.RelativeTimeFormat, because the two surfaces have to print the same characters, and a locale-aware formatter would not. `codeburn quota` grows a `notes` channel for provider facts that are not a window; only Codex sets it, so every other provider's output is byte-identical to before. The CLI reads the credits off the `rate_limit_reset_credits` block of the usage response it already fetches and never calls the companion endpoint, so it prints the count without the grant and expiry captions that only the per-credit list carries. Refs #725. No new polling loop and no new data source: this reads fields from a response already fetched on the existing cadence.
This commit is contained in:
parent
79d1482951
commit
6be422ac52
7 changed files with 317 additions and 16 deletions
|
|
@ -2184,15 +2184,17 @@ private struct CodexPlanInsight: View {
|
|||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
// Limit-reset credits the account is holding. Hidden at zero so
|
||||
// plans that never receive these grants see no extra row.
|
||||
if let resets = usage.resetCredits, resets.availableCount > 0 {
|
||||
// Limit-reset credits the account is holding, including the banked
|
||||
// ones OpenAI grants out of band. Hidden at zero so plans that never
|
||||
// receive these grants see no extra row.
|
||||
if let resets = usage.resetCredits,
|
||||
let detail = CodexBankedResetPresentation.detail(resets, now: Date()) {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text("Limit resets")
|
||||
Text(CodexBankedResetPresentation.rowLabel)
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
Text(resetCreditsLabel(resets))
|
||||
Text(detail)
|
||||
.font(.system(size: 10.5))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
|
@ -2241,12 +2243,6 @@ private struct CodexPlanInsight: View {
|
|||
)
|
||||
}
|
||||
|
||||
private func resetCreditsLabel(_ resets: CodexUsage.ResetCredits) -> String {
|
||||
let count = "\(resets.availableCount) available"
|
||||
guard let next = resets.nextExpiresAt else { return count }
|
||||
return "\(count) · next expires \(relativeReset(next))"
|
||||
}
|
||||
|
||||
private func relativeReset(_ date: Date) -> String {
|
||||
let f = RelativeDateTimeFormatter()
|
||||
f.unitsStyle = .short
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue