feat(opencode): show quota usage toast after quota refresh#36
Open
iceteaSA wants to merge 2 commits into
Open
Conversation
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
a69aab5 to
4601bd8
Compare
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)
4601bd8 to
4ad7d49
Compare
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%).
4ad7d49 to
b20b6c0
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 shared
QuotaManagerin@cortexkit/anthropic-auth-coreto unify main/fallback quota caching, serialize and back off usage API calls, persist quota/backoff state, and reduce 429s across the OpenCode plugin and routing.New Features
client.tui.showToastwith bars, % and reset time; highlights the active account; variants info/warning/error; clamps >100%.QuotaManager: unified main/fallback cache with inflight dedup, 1s serial API gate + cross‑process file lock, exponential backoff (60s–15m) for 429/5xx/network errors, seeding from disk, and request‑count trigger (refreshEveryNRequests).failClosedOnUnknownQuotais set, no cached main quota, and the quota API is backed off, return 429 withRetry-After.Refactors
QuotaManagerwithFallbackAccountManagerand OpenCode routing/loader: shared staleness checks, background refresh, and overlay cached fallback quotas for display.AccountStorage.quotawithrefreshEveryNRequests,mainQuota,mainQuotaCheckedAt, andmainLastQuotaApiError; add backoff helpers and messages; addQuotaManagertest suite and update plugin tests.Written for commit b20b6c0. Summary will update on new commits. Review in cubic