Skip to content

feat(opencode): add killswitch indicators to TUI sidebar#39

Open
iceteaSA wants to merge 5 commits into
cortexkit:mainfrom
iceteaSA:feat/killswitch-sidebar
Open

feat(opencode): add killswitch indicators to TUI sidebar#39
iceteaSA wants to merge 5 commits into
cortexkit:mainfrom
iceteaSA:feat/killswitch-sidebar

Conversation

@iceteaSA
Copy link
Copy Markdown
Contributor

@iceteaSA iceteaSA commented May 21, 2026

Dependencies: Requires #35 (killswitch) and #37 (TUI sidebar) to be merged first.

Adds killswitch awareness to the TUI sidebar widget:

  • Red dot for killed accounts, green for active
  • Quota/refresh backoff state display
  • Kill summary section showing which accounts are blocked
  • writeSidebarState() computes killswitch policy for all accounts

Files:

  • packages/opencode/src/sidebar-state.ts — adds killed, backoff fields
  • packages/opencode/src/tui.tsx — killed indicator, kill status section
  • packages/opencode/src/index.ts — killswitch-aware sidebar state

Summary by cubic

Adds killswitch status to the TUI sidebar and introduces a shared core QuotaManager for real-time quota/backoff with persistence and cross-process dedupe. Also writes a sidebar state file and exposes ./tui so the UI can render without extra fetches.

  • New Features
    • Killswitch: blocks accounts below 5h/7d thresholds, synthetic 429 with Retry-After from earliest reset, eager first-request refresh, skip-main routing when killed, per-account overrides.
    • TUI sidebar: per-account status dot (green/red), kill summary, quota bars with reset times, and quota/refresh backoff indicators with “retry at” timestamps.
    • QuotaManager: unified cache for main+fallbacks, inflight dedupe, exponential backoff (60s–15m), persisted main quota/backoff, cross-process file lock, request-count-based refresh, seeds from storage, integrates with FallbackAccountManager.
    • Sidebar state: writeSidebarState() persists killswitch/quota/backoff for main and fallbacks and includes tracked session count for cache-keepalive.
    • Commands/Packaging: /claude-killswitch to view/enable/disable and set thresholds; exports TUI via @cortexkit/opencode-anthropic-auth ./tui, copies tui.tsx at build, and registers both entries in oc-plugin.

Written for commit 8339edc. 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 16 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Fix all with cubic | Re-trigger cubic

Comment thread packages/core/src/accounts.ts
Comment thread packages/opencode/src/tui.tsx Outdated
@iceteaSA iceteaSA force-pushed the feat/killswitch-sidebar branch 2 times, most recently from 84f44e5 to 583586a 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/killswitch-sidebar branch 2 times, most recently from e747750 to 2b2c0e3 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/killswitch-sidebar branch from 2b2c0e3 to 09b34c3 Compare May 22, 2026 16:58
iceteaSA added 4 commits May 22, 2026 19:06
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)
…reshold

Per-account request blocking when remaining quota drops below configurable
thresholds. Returns synthetic 429 when all accounts (main + fallbacks) are
below their thresholds. Includes /claude-killswitch slash command for
runtime management.

Features:
- Per-account threshold overrides (5h and 7d windows)
- Eager quota refresh on first request for killswitch evaluation
- Skip-main routing when main is killed (try surviving fallbacks)
- Filter killed accounts from reactive fallback path
- Retry-After header with earliest quota reset time
Shows killed account status (red dot), quota/refresh backoff state,
and kill summary in the sidebar widget.
@iceteaSA iceteaSA force-pushed the feat/killswitch-sidebar branch from 09b34c3 to 8339edc 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