Skip to content

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

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

feat(opencode): add killswitch indicators to TUI sidebar#39
iceteaSA wants to merge 7 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 a killswitch and a restyled, real-time TUI quota sidebar. Blocks low‑quota requests and shows live quota, backoff, killswitch state, and cache keepalive in the sidebar.

  • New Features

    • Killswitch: per‑account and main 5h/7d thresholds with persisted config; skip killed main and filter killed fallbacks; synthetic 429 with Retry‑After; /claude-killswitch on/off/set/status.
    • TUI sidebar: account status (active/idle/blocked), kill summary; aligned quota bars with right‑aligned reset times; Health shows quota/token backoff and killswitch retry‑at; Cache shows 1h keepalive window and tracked sessions; event‑driven refresh with debounce + poll; LIMITED badge when degraded.
    • Packaging/Docs: export ./tui in @cortexkit/opencode-anthropic-auth, register in oc-plugin; add @opentui/core, @opentui/solid, solid-js; copy tui.tsx at build; @cortexkit/anthropic-auth-core now exports killswitch APIs; READMEs document /claude-killswitch and TUI registration.
  • Bug Fixes

    • Backoff scoped per route (main vs each fallback) to avoid cross‑account blocking.
    • Token‑aware fail‑closed read: bind cached main quota to the access‑token fingerprint; drop snapshots on token change; enforced in getMain().
    • Every‑N refresh: count all replayable requests (including fallback‑first) and restore the process‑scoped counter.
    • Fallback selection: evaluate from the QuotaManager cache as the single source of truth; token‑bind fallback cache entries and invalidate on re‑login.

Written for commit e86d9d3. 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 Outdated
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

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/killswitch-sidebar branch 4 times, most recently from 09b34c3 to 8339edc Compare May 22, 2026 17:08
@iceteaSA iceteaSA force-pushed the feat/killswitch-sidebar branch 3 times, most recently from 9a8f78a to 26466b6 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/killswitch-sidebar branch 5 times, most recently from 903bc95 to eb5f89e Compare June 1, 2026 13:01
iceteaSA added 7 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.
…reshold

Self-review fixes folded in:
- Token-aware fail-closed read: const mainQuota = quotaManager.getMain(auth.access)
  so a previous main account's cached quota can't satisfy the fail-closed check
  or feed the killswitch eval after a main-account switch.
- Removed a stray inner 'let sessionRequestCount = 0' + unconditional increment
  that shadowed the process-scoped counter, which had left the active-route
  fallback every-N refresh reading a never-incremented counter.
Layer killswitch awareness onto the restyled sidebar (killed state in
SidebarState + writeSidebarState via killswitchPassesPolicy, blocked status
word, Killswitch health row, degraded/LIMITED inclusion).

Also restores the process-scoped 'let sessionRequestCount' (a prior cascade
had flipped it to const, which left the active-route fallback every-N refresh
reading a never-incremented counter).
@iceteaSA iceteaSA force-pushed the feat/killswitch-sidebar branch from eb5f89e to e86d9d3 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