feat(opencode): show quota usage toast after quota refresh#36
Open
iceteaSA wants to merge 2 commits into
Open
Conversation
Unified quota cache and API gateway for main + fallback quota state. All consumers share one QuotaManager instance for consistent caching. Features: - Inflight deduplication prevents concurrent API calls - Exponential backoff (60s-15min) for 429/5xx errors - Persists main quota and backoff state to disk via callbacks - Cross-process file lock guard for quota API dedup - Seeds from persisted storage on construction - Integrates with FallbackAccountManager for shared staleness - Captures storage path at init to prevent test config corruption - Request-count-based refresh trigger (refreshEveryNRequests)
There was a problem hiding this comment.
3 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/src/index.ts">
<violation number="1" location="packages/opencode/src/index.ts:428">
P2: Fallback quota command output drops fresh per-account refresh errors by always passing an empty error map.</violation>
</file>
<file name="packages/core/src/quota-manager.ts">
<violation number="1" location="packages/core/src/quota-manager.ts:88">
P2: Persisted main quota cache uses interval-only staleness instead of policy-aware `getQuotaNextRefreshAt`, causing premature refreshes.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Displays quota usage bar notifications via client.tui.showToast after quota data is refreshed. Shows main and fallback account usage with visual bars, percentage, and reset time. Toast variant reflects severity (info < 70%, warning >= 70%, error >= 90%).
4e7ccc0 to
18123ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Displays quota usage bar notifications via
client.tui.showToastafter quota data is refreshed.█░)Single file change:
packages/opencode/src/index.ts(+127 lines)Summary by cubic
Adds a quota usage toast and a unified
QuotaManagerin@cortexkit/anthropic-auth-coreto cache, deduplicate, and rate‑limit quota API calls for main and fallback accounts, reducing rate-limit errors and improving routing reliability.New Features
client.tui.showToastwith bars, percent, reset time, and active account indicator; variant reflects usage (info/warning/error) and clamps >100%.QuotaManagerwith shared cache for main/fallback, inflight dedup, a serial API gate (1s gap) plus cross‑process file lock, exponential backoff (60s–15m) for 429/5xx, request‑count refresh trigger, and persistence of main quota/backoff via callbacks.Refactors
QuotaManagerwithFallbackAccountManagerand request routing: seeds from disk, shared staleness checks, background refresh, and overlay of cached fallback quotas for display.failClosedOnUnknownQuotais set, no cached quota, and the quota API is backed off, return 429 with Retry‑After and a backoff message.QuotaManagersuite.Written for commit 18123ae. Summary will update on new commits. Review in cubic