Skip to content

feat(opencode): TUI sidebar quota widget#37

Merged
ualtinok merged 4 commits into
cortexkit:mainfrom
iceteaSA:feat/tui-sidebar
Jun 1, 2026
Merged

feat(opencode): TUI sidebar quota widget#37
ualtinok merged 4 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 for live Claude quota and unifies quota handling behind QuotaManager for main and fallback accounts to cut 429s and keep state consistent. The sidebar shows usage, health, and cache-keepalive, and updates on events with a debounced refresh plus a 1.5s poll backstop.

  • New Features

    • TUI sidebar: 5h/7d usage with right-aligned reset times; route/fast/relay; cache keepalive (window + tracked sessions); health (quota-API and token-refresh backoff); CLAUDE/LIMITED badges; tone-only theme; bordered panel with section headers; event-driven refresh + 1.5s poll; slot order 160. OpenTUI plugin via @opentui/core/@opentui/solid; README docs with tui.json. Writes tmp sidebar-state.json. Package exposes ./tui via oc-plugin; build copies tui.tsx to dist/.
  • Bug Fixes

    • Token-aware reads: getMain() and fallback cache entries are bound to the live token; cross‑token seeds are dropped.
    • Backoff scoped per route: main and each fallback track their own quota‑API backoff; 401 does not arm backoff.
    • One source of truth: fallback selection evaluates policy from QuotaManager’s cache to match staleness checks.
    • Correct cadence: count all replayable requests (including fallback‑first) so every‑N refresh triggers reliably.

Written for commit 4af7377. 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

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/@opentui/solid@0.3.0npm/entities@6.0.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@6.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch 3 times, most recently from 545bea1 to 9b160a1 Compare May 22, 2026 17:08
@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch 3 times, most recently from d7f7195 to 5c82459 Compare June 1, 2026 09:08
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jun 1, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​opentui/​core@​0.3.0921009298100
Addedsolid-js@​1.9.1310010010095100
Added@​opentui/​solid@​0.3.09710010098100

View full report

@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch 7 times, most recently from 38b3d9b to a9dfa9c Compare June 1, 2026 13:01
iceteaSA added 4 commits June 1, 2026 16:45
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)
Regenerate the lockfile so it resolves @opentui/core, @opentui/solid, and
solid-js added to packages/opencode/package.json, and apply biome formatting
to tui.tsx. Fixes CI 'bun install --frozen-lockfile' and 'format:check'.
Align the quota sidebar with the styling used by other CortexKit OpenCode TUI
tools (e.g. aft):

- Bordered panel with a CLAUDE badge header and a LIMITED badge when degraded
- Reusable SectionHeader and StatRow components; box padding instead of
  leading-space indentation
- Theme tokens only via a tone system (ok/warn/err/muted/accent) — no
  hardcoded hex/named color fallbacks
- Surface previously-missing state: Cache (1h keepalive window + tracked
  sessions) and Health (quota-API / token-refresh backoff)
- Account status words (active/idle) replace the ad-hoc dot glyph
- Event-driven refresh (session/message) with debounce plus a poll backstop
- Slot order 150 -> 160 to match the convention used by other TUI panels

Backoff state is quota-manager-derived and lives in the base sidebar; the
killswitch block display is added separately on the killswitch sidebar branch
so this non-killswitch widget carries no killswitch code.

Documents the sidebar and tui.json registration in the README.
Render each quota window as fixed-width left-aligned columns (label, bar,
percentage) and push the reset time to the right edge so bars/percentages line
up across rows and reset times share a right-aligned column.
@iceteaSA iceteaSA force-pushed the feat/tui-sidebar branch from a9dfa9c to 4af7377 Compare June 1, 2026 14:51
@ualtinok ualtinok merged commit 828d97b into cortexkit:main Jun 1, 2026
3 checks passed
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.

2 participants