fix(quota): keep the capacity panel when a credit expiry cannot be formatted - #2965
Conversation
`epochMillis` accepted any finite number, but finite is not the same as representable. ECMAScript caps time values at ±8.64e15 ms, and `Intl.DateTimeFormat.format()` throws a RangeError past that rather than rendering an approximation. So a provider reporting a bogus expiry did not produce a wrong date; it produced a value that faults every consumer that formats it. Measured against the current code, 1e20 and 1e16 both yield "date value is not finite in DateTimeFormat format()", while 8.64e15 remains representable. Resolve an unrepresentable value to undefined so it never enters a report. Seconds inference, the zero/negative sentinel handling, and every representable timestamp are unchanged.
…atted `Intl.DateTimeFormat.format()` throws a RangeError on a time value outside ±8.64e15 ms rather than rendering an approximation. The capacity panel formatted `expiresAt` and `nextRecoveryAt` directly, so one unrepresentable timestamp did not merely show a wrong date — it aborted rendering and removed the credit balance, the recovery rows, and the aggregate view along with it. The wire-side guard stops such a value entering a fresh report, but persisted reports predate it and the component is reachable without that path. Guard both layers here: normalization drops the field, and the component omits the line instead of formatting it. Representable timestamps and seconds inference are unchanged.
Server-rendered comparison of the provider capacity panel when a provider reports an expiry outside the representable date range, following the repository's existing convention of committing PR screenshots under assets/.
An unrenderable weekly reset timestamp caused the credits parser to discard an otherwise valid usage percentage. Validate the percentage independently and omit only the invalid reset timestamp so the preferred weekly meter remains available.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 397958e488
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { | ||
| percent, | ||
| ...(resetAt !== undefined ? { resetAt } : {}), |
There was a problem hiding this comment.
Fall back when the weekly response has no usable meter
When xAI returns a weekly period but both end is missing or unrenderable and creditUsagePercent is omitted, this unconditional return now produces { percent: 0 }, so fetchXaiQuota treats the weekly probe as successful and never calls the legacy monthly endpoint. A truncated or malformed response that previously activated the fallback will therefore falsely display 0% weekly usage and hide usable monthly quota. Preserve an explicit valid percentage when only the reset is bad, but return null when neither an explicit percentage nor a valid reset exists, with a focused regression case.
AGENTS.md reference: src/AGENTS.md:L15-L17
Useful? React with 👍 / 👎.
리뷰 · 우선순위 72 / 80설명 이 PR은 크레딧 만료 시각(expiry)이 날짜로 그릴 수 없을 때, 용량(capacity) 패널 전체가 같이 죽던 버그를 고칩니다. 지금 고치는 층이 세 겹입니다. 첫째, 메인테이너 수리 커밋이 핵심입니다. 기반은 라인 - 문제 src/providers/quota.ts gui/.../ProviderCapacityQuota.tsx assets/pr2950-capacity-expiry.png - PR 설명용 before/after 스크린샷이 저장소 gui/.../ProviderCapacityQuota.tsx 복구(recovery) 줄 - 메인테이너의 판단이 필요한 지점
너의 추천
이 댓글은 grok-bot이 작성했습니다 |
Summary
Carries #2950 by @luvs01, plus one repair commit. A credit expiry timestamp that no date formatter can
render used to take the whole capacity panel down with it.
This also carries #2951 in full: commit
6fcd39ac0— thesrc/providers/quota-wire.tschange and itstests/command-code-quota.test.tscase — is the same commit object in both branches, so #2951 issuperseded by this rather than in conflict with it.
Opened as a maintainer PR because pushing the repair to the contributor branch reset its
review-readiness checklist and returned it to draft; that attestation belongs to the author. The
cherry-pick preserves @luvs01's authorship.
Carries #2950 and supersedes #2951. Close both as carried once this lands.
The repair
Rejecting an unrenderable timestamp at the wire boundary is right, but
parseXaiCreditsResponseinsrc/providers/quota.tsreturnednullwhenever the reset was unrenderable — discarding a perfectlyvalid
creditUsagePercentalong with it. That silently degraded the preferred xAI weekly meter to thelegacy monthly one, or removed the xAI quota report entirely when the fallback also failed.
The percent is now parsed and validated independently of the reset, and the reset is included only
when it is defined and renderable.
Verification
Based on
dev@dca16949b.bun test tests/provider-quota.test.ts tests/command-code-quota.test.ts→ 121 pass, 0 failcd gui && bun test tests/provider-capacity-credits.test.tsx tests/provider-capacity.test.ts→ 11 pass, 0 failbun x tsc --noEmit→ cleanThe new xAI case uses a weekly period whose
endis1e20and asserts the percent survives without areset timestamp.
Checklist