Skip to content

feat: show billing reset times in the user's timezone#5

Merged
kenryu42 merged 2 commits into
kenryu42:mainfrom
setkyar:feat/local-usage-timezone
Jul 11, 2026
Merged

feat: show billing reset times in the user's timezone#5
kenryu42 merged 2 commits into
kenryu42:mainfrom
setkyar:feat/local-usage-timezone

Conversation

@setkyar

@setkyar setkyar commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Display Grok CLI billing reset times in the local system timezone, including both the short offset/abbreviation and IANA timezone identifier (for example, Jul 11, 13:01 GMT+7 Asia/Bangkok). This makes it easier for users to see exactly when their quota resets without converting from Pacific Time.

Testing

  • bun run check

Generated with pi using GPT-5.6, as noted in #3.

Summary by CodeRabbit

  • Bug Fixes

    • Billing reset times now display in the user’s local timezone instead of a fixed Pacific Time zone.
    • Quota status messages include the local timezone name for clearer reset-time information.
  • Documentation

    • Clarified that quota reset times use the local system timezone.
    • Added an example of the reset-time format.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@setkyar, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36f05558-1a80-4c99-925f-e37d23ab0080

📥 Commits

Reviewing files that changed from the base of the PR and between de81533 and 043689a.

📒 Files selected for processing (2)
  • src/provider/billing.ts
  • tests/provider/register.test.ts
📝 Walkthrough

Walkthrough

Billing reset timestamps now use the runtime’s local timezone and include timezone details. Status tests avoid fixed timezone assumptions, and the quota documentation describes the updated output format.

Changes

Local billing timezone

Layer / File(s) Summary
Local reset-time formatting
src/provider/billing.ts
Reset formatting uses the runtime locale and timezone, appending the formatted timezone name and resolved timezone identifier.
Status validation and quota documentation
tests/provider/register.test.ts, README.md
Status assertions validate stable usage and timezone content, while quota documentation describes local timezone output with an example.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: displaying billing reset times in the user's timezone.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR shows Grok CLI billing reset times in the local system timezone. The main changes are:

  • Billing reset formatting now uses the runtime timezone and includes the short timezone name.
  • Reset output now appends the resolved IANA timezone identifier.
  • README and status command tests were updated for the local timezone display.

Confidence Score: 4/5

The production formatter looks safe, but the changed tests need cleanup around reset-time coverage.

  • The timezone assertion can fail in DST-observing zones because it compares July reset output with today's abbreviation.
  • The monthly-only test no longer verifies that the reset time is printed.
  • No security issues were identified.

tests/provider/register.test.ts

Important Files Changed

Filename Overview
src/provider/billing.ts Formats reset timestamps with the local timezone name and resolved IANA timezone.
tests/provider/register.test.ts Updates billing status assertions, but one check is DST-sensitive and another no longer verifies the reset line.
README.md Documents the local timezone reset-time display.

Fix All in Codex

Reviews (1): Last reviewed commit: "feat: show usage reset in local timezone" | Re-trigger Greptile

Comment thread tests/provider/register.test.ts Outdated
expect(status).toContain('1% used');
const localFormatter = new Intl.DateTimeFormat(undefined, { timeZoneName: 'short' });
expect(status).toContain(
localFormatter.formatToParts(new Date()).find((part) => part.type === 'timeZoneName')?.value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 DST Abbreviation Uses Today

This expected timezone name comes from new Date(), but the command output formats the mocked July 2026 reset timestamps. In DST-observing zones, today's abbreviation can differ from July's abbreviation, so the test can fail even when the reset time is formatted correctly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex

Comment on lines +267 to +269
const status = String(notify.mock.calls.at(-1)?.[0]);
expect(status).toContain('172 / 4,000 used 4%');
expect(status).toContain('3,828 credits');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Reset Line Goes Untested

This test still uses a monthly billing fixture with billingPeriodEnd, but it no longer checks that the Reset line is present or formatted. A regression that drops the reset time while keeping credits and remaining credits would pass, even though /grok-cli-usage is documented to print the reset time.

Fix in Codex

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/provider/register.test.ts (1)

246-250: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid duplicating formatter logic in tests.

The test creates a new Intl.DateTimeFormat(undefined, { timeZoneName: 'short' }) to compute expected values, duplicating the formatter configuration from billing.ts. If the implementation changes its formatter options (e.g., timeZoneName: 'long'), this test would still pass using its own parallel formatter, missing the regression.

Consider exporting LOCAL_TIME_ZONE from billing.ts and importing it here to assert against the actual implementation value. As per coding guidelines, "do not duplicate logic into tests."

♻️ Suggested refactor

In src/provider/billing.ts, export the constant:

-const LOCAL_TIME_ZONE = RESET_FORMATTER.resolvedOptions().timeZone;
+export const LOCAL_TIME_ZONE = RESET_FORMATTER.resolvedOptions().timeZone;

Then in the test, import and use it directly:

+import { LOCAL_TIME_ZONE } from '../../src/provider/billing';
+
 // ...
-    const localFormatter = new Intl.DateTimeFormat(undefined, { timeZoneName: 'short' });
-    expect(status).toContain(
-      localFormatter.formatToParts(new Date()).find((part) => part.type === 'timeZoneName')?.value,
-    );
-    expect(status).toContain(localFormatter.resolvedOptions().timeZone);
+    expect(status).toContain(LOCAL_TIME_ZONE);

For the timeZoneName assertion, consider a regex pattern (e.g., /GMT[+-]\d+|UTC|[A-Z]{3,4}/) or export the formatter itself from billing.ts to avoid parallel construction.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/provider/register.test.ts` around lines 246 - 250, Export the
implementation’s LOCAL_TIME_ZONE value from billing.ts and import it in the test
instead of recreating the formatter configuration. Update the assertions around
the local time-zone name to avoid duplicating Intl.DateTimeFormat options, using
an implementation-derived value or an appropriate pattern while still asserting
the status contains the exported LOCAL_TIME_ZONE.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/provider/register.test.ts`:
- Around line 246-250: Export the implementation’s LOCAL_TIME_ZONE value from
billing.ts and import it in the test instead of recreating the formatter
configuration. Update the assertions around the local time-zone name to avoid
duplicating Intl.DateTimeFormat options, using an implementation-derived value
or an appropriate pattern while still asserting the status contains the exported
LOCAL_TIME_ZONE.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 243cac1e-6165-42ce-b167-ec9059248369

📥 Commits

Reviewing files that changed from the base of the PR and between 52b4675 and de81533.

📒 Files selected for processing (3)
  • README.md
  • src/provider/billing.ts
  • tests/provider/register.test.ts

@kenryu42 kenryu42 merged commit 5bdc1ae into kenryu42:main Jul 11, 2026
3 checks passed
@kenryu42

Copy link
Copy Markdown
Owner

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants