Repository navigation
Add Codex reset credit controls - #5631
Conversation
Co-authored-by: Orca <[email protected]>
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit dcd32b8 on Jun 17, 2026 10:31pm UTC. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
💤 Files with no reviewable changes (6)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR implements end-to-end support for consuming Codex rate-limit reset credits. New shared types ( 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 03a36686-3505-4e19-befe-b4da9815b2db
📒 Files selected for processing (20)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/main/ipc/rate-limits.tssrc/main/rate-limits/codex-fetcher.test.tssrc/main/rate-limits/codex-fetcher.tssrc/main/rate-limits/service.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/rate-limits.tssrc/renderer/src/web/web-preload-api.tssrc/shared/constants.tssrc/shared/rate-limit-types.tssrc/shared/types.ts
| if (skipFutureResetConfirm) { | ||
| await updateSettings({ skipCodexRateLimitResetConfirm: true }) | ||
| } | ||
| await handleRedeemReset() |
There was a problem hiding this comment.
Don’t let “Don’t ask again” persistence failures block redemption.
On Line 1319, updateSettings is awaited without handling failure. If it rejects, redeem is aborted even though preference persistence is optional.
Proposed fix
const handleConfirmReset = async (): Promise<void> => {
if (isRedeemingReset) {
return
}
if (skipFutureResetConfirm) {
- await updateSettings({ skipCodexRateLimitResetConfirm: true })
+ try {
+ await updateSettings({ skipCodexRateLimitResetConfirm: true })
+ } catch (error) {
+ console.error('Failed to save Codex reset confirmation preference:', error)
+ }
}
await handleRedeemReset()
if (mountedRef.current) {
setResetConfirmOpen(false)
setSkipFutureResetConfirm(false)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (skipFutureResetConfirm) { | |
| await updateSettings({ skipCodexRateLimitResetConfirm: true }) | |
| } | |
| await handleRedeemReset() | |
| if (skipFutureResetConfirm) { | |
| try { | |
| await updateSettings({ skipCodexRateLimitResetConfirm: true }) | |
| } catch (error) { | |
| console.error('Failed to save Codex reset confirmation preference:', error) | |
| } | |
| } | |
| await handleRedeemReset() |
| consumeCodexRateLimitResetCredit: async () => { | ||
| try { | ||
| const result = await window.api.rateLimits.consumeCodexResetCredit() | ||
| set({ rateLimits: result.state }) | ||
| } catch (error) { | ||
| console.error('Failed to consume Codex rate-limit reset:', error) | ||
| } |
There was a problem hiding this comment.
Propagate consume failures instead of resolving silently.
On Line 113, the catch block logs and swallows errors. That makes failed reset-consume attempts look like success to callers and breaks failure-aware UI handling.
Proposed fix
consumeCodexRateLimitResetCredit: async () => {
try {
const result = await window.api.rateLimits.consumeCodexResetCredit()
set({ rateLimits: result.state })
} catch (error) {
console.error('Failed to consume Codex rate-limit reset:', error)
+ throw error
}
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| consumeCodexRateLimitResetCredit: async () => { | |
| try { | |
| const result = await window.api.rateLimits.consumeCodexResetCredit() | |
| set({ rateLimits: result.state }) | |
| } catch (error) { | |
| console.error('Failed to consume Codex rate-limit reset:', error) | |
| } | |
| consumeCodexRateLimitResetCredit: async () => { | |
| try { | |
| const result = await window.api.rateLimits.consumeCodexResetCredit() | |
| set({ rateLimits: result.state }) | |
| } catch (error) { | |
| console.error('Failed to consume Codex rate-limit reset:', error) | |
| throw error | |
| } | |
| }, |
| get: () => Promise.resolve(empty), | ||
| refresh: () => Promise.resolve(empty), | ||
| refreshCodexForTarget: () => Promise.resolve(empty), | ||
| consumeCodexResetCredit: () => Promise.resolve({ outcome: 'noCredit', state: empty }), |
There was a problem hiding this comment.
Add a short “Why” comment for the web no-op.
Returning noCredit here is a safe fallback, but the desktop-only reset-credit constraint is non-obvious.
Proposed fix
+ // Why: web clients do not own local Codex auth, so reset-credit
+ // redemption remains desktop-only and reports the safe no-credit outcome.
consumeCodexResetCredit: () => Promise.resolve({ outcome: 'noCredit', state: empty }),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
…imit-reset-banking-display-banked-re # Conflicts: # src/renderer/src/i18n/locales/ja.json
Co-authored-by: Orca <[email protected]>
Summary
Closes #5494.
Screenshots
Screenshot proof was captured locally at
/tmp/orca-pr-evidence/codex-reset-confirmation.pngafter launching this worktree via CDP, injectingrateLimitResetCredits.availableCount = 1in renderer state, opening the Codex status menu, and clicking Reset now. No real reset credit was consumed.Testing checklist
pnpm vitest run --config config/vitest.config.ts src/main/rate-limits/codex-fetcher.test.tspnpm vitest run --config config/vitest.config.ts src/main/codex-accounts/runtime-home-service.test.ts src/main/codex-accounts/service.test.tspnpm run typecheckpnpm run verify:localization-catalogpnpm exec oxlint ...AI Review Report
join(...).Security Audit
Note: local shell is using Node v26, so pnpm prints the repo's expected Node 24 engine warning, but the checks above passed.