Add rate-limit reset redemption - #7
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae2fd78457
ℹ️ 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".
| catch (Exception ex) when ( | ||
| ex is IOException or InvalidOperationException or UnauthorizedAccessException) |
There was a problem hiding this comment.
Keep redemption failure handling out of the view
If the Codex executable becomes unavailable after the initial snapshot, restarting the app-server can throw Win32Exception; similarly, a response without outcome throws KeyNotFoundException. Neither matches this filter, so the exception escapes the async void handler onto the WPF dispatcher and can terminate the application. Normalize transport/protocol failures in an Application-layer redemption use case and return a stable result for the view to present, rather than coordinating the operation and infrastructure exception types in code-behind.
AGENTS.md reference: AGENTS.md:L33-L35
Useful? React with 👍 / 👎.
| MessageBoxImage.Warning); | ||
| } | ||
|
|
||
| await _usageMonitor.RefreshAsync(); |
There was a problem hiding this comment.
Guarantee the post-redemption refresh
If a periodic, notification-triggered, or manual refresh already holds UsageMonitor's refresh gate when redemption finishes, this call returns immediately because RefreshAsync uses WaitAsync(0). If that in-flight read captured the pre-redemption state, the redeemed credit remains selectable until the next two-minute refresh, potentially leading the user to retry a reset that was already consumed. Queue or coalesce a refresh that is guaranteed to run after the active refresh completes.
Useful? React with 👍 / 👎.
Summary
Validation
dotnet build .\CodexUsageWidget.slnx -c Release --no-restoredotnet test .\CodexUsageWidget.slnx -c Release --no-build(168 passed)