Skip to content

Show Codex reset credit expiry - #5865

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/codex-reset-expiry
Jun 20, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/codex-reset-expiry

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • fetch detailed Codex reset-credit metadata, including expiry timestamps
  • display the next available reset-credit expiry next to the reset action
  • avoid duplicating reset-credit copy in the Codex provider summary

Test Plan

  • pnpm vitest run --config config/vitest.config.ts src/main/rate-limits/codex-fetcher.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/tooltip.test.ts
  • pnpm exec tsc --noEmit --pretty false
  • git diff --check

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jun 20, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Update rate-limit types for credit metadata
2 Implement Codex credit fetching and parsing
3 Add credit expiry formatting utilities
4 Display credit expiry in the UI
Open in Stage

Chapters generated by Stage for commit ea478dd on Jun 20, 2026 1:37am UTC.

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-reset-expiry branch 2 times, most recently from 370d805 to cdd0753 Compare June 20, 2026 01:33
@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1dfb058b-2c48-4d22-9f9a-2cc49be9d896

📥 Commits

Reviewing files that changed from the base of the PR and between cdd07533adbe52401f42b61934c4a9ecc9ec7e89 and ea478dd.

📒 Files selected for processing (6)
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/main/rate-limits/codex-fetcher.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/shared/rate-limit-types.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/shared/rate-limit-types.ts
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/main/rate-limits/codex-fetcher.ts

📝 Walkthrough

Walkthrough

The shared rateLimitResetCredits type in rate-limit-types.ts is expanded to include totalEarnedCount, nextExpiresAt, and a credits array with per-credit status, expiresAt, and grantedAt. The Codex fetcher in codex-fetcher.ts updates its internal types, adds normalization helpers (parseCreditTimestamp, normalizeCreditStatus, getNextAvailableCreditExpiry), revises both RPC and backend mapping functions, changes the backend endpoint from wham/usage to wham/rate-limit-reset-credits, adds OpenAI-Beta and originator request headers, and alters the early-return condition in withBackendRateLimitResetCredits. The tooltip gains an exported formatResetCreditExpiry helper and a showResetCredits prop on ProviderPanel. StatusBar wires in the expiry display and a new hidePanelResetCredits prop for ProviderDetailsMenu. Tests are updated throughout.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and does not follow the required template structure. It is missing Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections. Complete the description by adding all required sections from the template: Screenshots, Testing checklist items, AI Review Report (including cross-platform compatibility checks), Security Audit, and Notes sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Show Codex reset credit expiry' clearly and directly summarizes the main user-visible change in the pull request.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
src/main/rate-limits/codex-fetcher.ts (1)

143-146: ⚡ Quick win

Document the seconds-vs-milliseconds heuristic.

Line 145 uses a non-obvious cutoff (10_000_000_000) that encodes a parsing contract; add a short “Why” comment so this logic is not accidentally changed.

💡 Suggested inline clarification
 function parseCreditTimestamp(value: number | string | null | undefined): number | null {
   if (typeof value === 'number' && Number.isFinite(value)) {
+    // Why: some payloads send Unix seconds while others send Unix milliseconds.
     return value < 10_000_000_000 ? value * 1000 : value
   }

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines

src/main/rate-limits/codex-fetcher.test.ts (1)

360-369: ⚡ Quick win

Add one numeric-epoch-string timestamp case to lock the widened contract.

These tests cover ISO timestamp strings, but not numeric-string epochs. Since mapping now accepts number | string | null, add one case (e.g. "1719326400" or "1719326400000") to prevent regressions in timestamp normalization.

Also applies to: 383-393

src/renderer/src/components/status-bar/StatusBar.tsx (1)

1381-1385: ⚡ Quick win

Add a short Why: note for the hide/show split of reset-credit UI.

This path intentionally hides reset credits in ProviderPanel while rendering them in the menu header. A one-line rationale here will prevent future “cleanup” from reintroducing duplicated copy.

As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Also applies to: 1683-1683

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 25acbeaa-9651-40e7-a328-9442200255a4

📥 Commits

Reviewing files that changed from the base of the PR and between 5a85528 and e5c988775ee1ce9de14d82d647c1ac81a36d2338.

📒 Files selected for processing (6)
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/main/rate-limits/codex-fetcher.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/shared/rate-limit-types.ts

Comment thread src/main/rate-limits/codex-fetcher.ts Resolved
Comment on lines +1458 to +1461
{resetCreditExpiry ? (
<div className="text-[11px] font-normal text-muted-foreground">
{resetCreditExpiry}
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Localize the expiry phrase before rendering it in the dropdown.

resetCreditExpiry is produced by formatResetCreditExpiry, which currently returns English phrases directly. That leaves Line 1458 untranslated while adjacent strings use translate(...).

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-reset-expiry branch from cdd0753 to ea478dd Compare June 20, 2026 01:37
@Jinwoo-H
Jinwoo-H merged commit 7320c1e into main Jun 20, 2026
1 check passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/codex-reset-expiry branch June 20, 2026 01:49
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

1 participant