Skip to content

feat(opencode): TUI sidebar quota widget#37

Open
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/tui-sidebar
Open

feat(opencode): TUI sidebar quota widget#37
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/tui-sidebar

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.

Adds a TUI sidebar widget showing real-time quota usage for main and fallback accounts.

Displays:

  • Usage bars with percentage and reset times per account
  • Active account indicator (green dot)
  • Route, fast mode, relay status
  • Cache-keepalive tracked sessions

Files:

  • packages/opencode/src/sidebar-state.ts — new, shared state type + file I/O
  • packages/opencode/src/tui.tsx — new, Solid.js sidebar component
  • packages/opencode/scripts/copy-tui.mjs — new, build helper
  • packages/opencode/package.json — TUI deps, oc-plugin field, ./tui export
  • packages/opencode/src/index.tswriteSidebarState() integration
  • packages/core/src/cachekeep.tstrackedCount() getter

Summary by cubic

Adds a TUI sidebar that shows live Claude quota and a shared QuotaManager with caching, backoff, and persistence to reduce 429s and stabilize routing. Improves fallback quota freshness and exposes state for the TUI with minimal polling.

  • New Features

    • TUI sidebar: usage bars (5h/7d) with reset times, active account dot, route, fast mode, relay status, and cache‑keep tracked sessions; server writes tmp sidebar-state.json, TUI polls.
    • QuotaManager in @cortexkit/anthropic-auth-core: shared main+fallback cache, inflight dedupe, serial API gate, cross‑process file‑lock, exponential backoff (60s–15m) for 429/5xx, persisted main quota and backoff (seed/restore from storage), request‑count refresh via refreshEveryNRequests, and integration with FallbackAccountManager for shared staleness and seeding/sync.
    • Plugin routes via QuotaManager; fail‑closed when quota is unknown during backoff (429 with Retry‑After). CacheKeepManager.trackedCount() added for sidebar.
  • Dependencies

    • Add @opentui/core, @opentui/solid, solid-js.
    • Expose TUI via exports["./tui"] and oc-plugin; build emits sidebar-state and copies tui.tsx.
    • Export QuotaManager from @cortexkit/anthropic-auth-core.

Written for commit 9b160a1. 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.

2 issues found across 12 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/opencode/src/tui.tsx Outdated
Comment thread packages/core/src/accounts.ts
@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch 2 times, most recently from 9651130 to 8b20be7 Compare May 21, 2026 20:20
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 21, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch from 8b20be7 to 3c86178 Compare May 22, 2026 16:52
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)
@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch from 3c86178 to 545bea1 Compare May 22, 2026 16:58
Adds a TUI sidebar widget showing real-time quota usage for main and
fallback accounts. Displays usage bars, reset times, relay status,
fast mode, and cache-keepalive state.

New files: sidebar-state.ts, tui.tsx, scripts/copy-tui.mjs
Modified: package.json (TUI deps, exports), index.ts (writeSidebarState)
@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch from 545bea1 to 9b160a1 Compare May 22, 2026 17:08
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