Skip to content

feat(opencode): show quota usage toast after quota refresh#36

Open
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/quota-toast
Open

feat(opencode): show quota usage toast after quota refresh#36
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/quota-toast

Conversation

@iceteaSA
Copy link
Copy Markdown
Contributor

@iceteaSA iceteaSA commented May 21, 2026

Dependency: Requires #34 (QuotaManager) to be merged first. Branch is based on feat/quota-manager.

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 per account
  • Toast variant reflects severity: info (<70%), warning (≥70%), error (≥90%)
  • Clamped bar rendering prevents RangeError on >100% utilization

Single file change: packages/opencode/src/index.ts (+127 lines)


Summary by cubic

Shows a quota usage toast after quota refresh, styled to match the TUI sidebar. Integrates the shared QuotaManager from @cortexkit/anthropic-auth-core so routing gets fresh quota without blocking and displays a toast when refresh completes, including background every‑N refreshes.

  • New Features
    • Toast via client.tui.showToast: shows main and enabled fallbacks with shared‑width bars, padded percent, reset time; “active/idle” labels; “7d” label; clamps >100%; info/warning/error variants.
    • Uses QuotaManager cache for main and fallback snapshots; triggers toast after refreshMain and when a background refresh resolves; marks the active account in the message based on current quota policy.

Written for commit 95a1614. Summary will update on new commits.

Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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

Comment thread packages/opencode/src/index.ts Outdated
Comment thread packages/core/src/quota-manager.ts Outdated
Comment thread packages/core/src/quota-manager.ts
@iceteaSA iceteaSA force-pushed the feat/quota-toast branch 5 times, most recently from 4ad7d49 to b20b6c0 Compare May 22, 2026 17:08
@iceteaSA iceteaSA force-pushed the feat/quota-toast branch 7 times, most recently from 3241b3e to 2ec54d4 Compare June 1, 2026 13:01
iceteaSA added 2 commits June 1, 2026 16:45
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%).
Align the quota refresh toast with the sidebar's visual language:

- Replace the emoji status dots with status words (active/idle)
- Use the shared bar width and a padded percentage via a quotaLine helper
- Rename the seven-day label from 1w to 7d to match the sidebar
- Keep severity-driven variant color (info/warning/error)
@iceteaSA iceteaSA force-pushed the feat/quota-toast branch from 2ec54d4 to 95a1614 Compare June 1, 2026 14:51
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