fix(gui): keep the capacity panel when a credit expiry cannot be formatted - #2950
fix(gui): keep the capacity panel when a credit expiry cannot be formatted#2950luvs01 wants to merge 4 commits into
Conversation
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. |
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ 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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughQuota timestamp handling now rejects unrepresentable dates at wire and report boundaries. The xAI credits parser preserves usable weekly data when reset timestamps are missing or invalid. The capacity panel skips invalid date rows. Regression tests cover these cases. ChangesQuota timestamp handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change keeps provider capacity data visible when an invalid expiry is supplied and preserves the existing 0% default for omitted usage; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Title checkExplanation The title clearly describes the primary change: preventing the GUI capacity panel from failing when a credit expiry timestamp cannot be formatted. It is concise, specific, and directly related to the changeset.
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
리뷰 · 우선순위 71 / 80이 PR은 지금 쉽게 말하면 이렇다. 지금 HEAD의 고침은 세 층이다. 와이어( 지금 라인 59–72 (ProviderCapacityQuota.tsx) - 경로 gui/src/provider-workspace/report.ts · dateTimestamp - 경로 src/providers/quota-wire.ts · epochMillis - 표현 못 하는 값을 경로 tests/command-code-quota.test.ts - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
`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.
35ef304 to
e7f5995
Compare
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.
|
Carried to #2965 and merged there, with your three commits cherry-picked so authorship is preserved. Reopened as a maintainer PR because the repair commit I pushed here reset the review-readiness checklist and returned this PR to draft. That checklist is your attestation, bound to an exact head, so it is not mine to tick for you. The repair: rejecting an unrenderable timestamp at the wire boundary is right, but Thanks for the fix. |
Summary
An unrepresentable credit expiry aborted rendering of the provider capacity panel. Omit the
affected line instead of handing the value to a formatter.
The defect
Intl.DateTimeFormat.format()throws a RangeError on a time value outside ±8.64e15 msrather than rendering an approximation.
ProviderCapacityQuotaformattedexpiresAtandnextRecoveryAtdirectly:So a provider reporting a bogus expiry did not produce a wrong date. It produced a render
fault: server-side rendering aborts with "date value is not finite in DateTimeFormat
format()", taking the credit balance, the recovery rows, and the aggregate view with it.
One malformed field from one provider removes the whole panel.
The fix
Two layers, because each is reachable without the other:
gui/src/provider-workspace/report.tsgui/src/components/provider-workspace/ProviderCapacityQuota.tsxnextRecoveryAt, which formats on the same pathThe component resolves to
nulland omits the line rather than formatting it.Representable timestamps, seconds inference, and every other credit figure are unchanged.
UI change
Left is current
dev, right is this branch. The top row is a provider reportingexpiresAt: 1e20; the bottom row is an ordinary representable expiry, which is unaffected.Verification
Based on
dev@47b8d164366b9db9e4331b2bb8b542db22766910with #2951 applied.bun test testsingui/→ full suite, 0 failures.bun x tsc -bclean ingui/.RangeError: date value is not finite in DateTimeFormat format()raised fromrenderToStringImpl— the render fault itself, not an assertion. The screenshot above isthat same server render, captured before and after the change.
full-matrix check.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Bug Fixes
Tests