feat(opencode): add killswitch indicators to TUI sidebar#39
Open
iceteaSA wants to merge 14 commits into
Open
Conversation
There was a problem hiding this comment.
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
84f44e5 to
583586a
Compare
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
09b34c3 to
8339edc
Compare
e86d9d3 to
a8d6404
Compare
a8d6404 to
ecffae9
Compare
4988ae1 to
78b02b4
Compare
5b995dd to
eaf91c9
Compare
…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).
eaf91c9 to
3147ad3
Compare
Integrate the collapsible sidebar with killswitch indicators: - collapsed active-account row shows red \u2298 (blocked) instead of the dot when the active account is killswitch-blocked; % stays usage-toned - resolveActiveAccount returns the killed flag - restore killed prop on expanded AccountBlocks
Contributor
Author
|
Updated: this branch now carries the sidebar quota fix (#57) and the collapsible sidebar (#58), and integrates the collapsed view with the killswitch indicators — the collapsed active-account row shows a red ⊘ (instead of the usage dot) when that account is killswitch-blocked; |
…nged The callback fires on any persisted fallback storage change (token refresh, quota update, or error recording), not only quota fetches. Rename per review feedback for an accurate API name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds killswitch awareness to the TUI sidebar widget (the integration of #35 + the merged sidebar):
blocked(red) state for killswitch-killed main and fallback accounts.Killswitchrow in the Health section and inclusion in theLIMITEDbadge.writeSidebarState()computes killswitch policy for every account using fresh, token-aware QuotaManager reads (never the stale request-start snapshot).Files:
packages/opencode/src/sidebar-state.ts— addskilled+ backoff fieldspackages/opencode/src/tui.tsx— blocked indicator + kill status sectionpackages/opencode/src/index.ts— killswitch-aware sidebar stateSummary by cubic
Adds a killswitch that hard‑blocks accounts below remaining‑quota thresholds and wires it into routing and the TUI sidebar;
/claude-killswitchmanages thresholds. Killed accounts never route, and when none are routable we return a synthetic 429 withretry-after.New Features
getRoutableFallbackAccountsfilter across all routes, and a hard 429 withretry-afterfrom the earliest reset; non‑replayable bodies never fall through to killed accounts.killedflags for main/fallbacks,resolveActiveAccount(), and background fallback storage changes re‑render viaonFallbackStorageChanged./claude-killswitchfor status/on/off/set; changes are persisted via@cortexkit/anthropic-auth-core.Bug Fixes
Written for commit c73b37e. Summary will update on new commits.
Greptile Summary
This PR wires the killswitch feature (#35) into the TUI sidebar and the main fetch handler.
writeSidebarStatenow computes akilledflag for every account via token-awareQuotaManagerreads, and a newrefreshSidebarQuotahelper preserves the last routing decision across async quota refreshes. The fetch handler gains an eager quota-refresh step before the killswitch evaluation, a singlegetRoutableFallbackAccountsfunction used across all routing paths, and a hard 429 withretry-afterwhen no routable account survives.sidebar-state.ts,tui.tsx): adds akilledboolean to main and fallback state, a collapsible header with a collapse/expand toggle, a red⊘indicator in the collapsed row, and aKillswitchrow in the Health section of the expanded view.index.ts): replaces rawgetUsableFallbackAccountscalls withgetRoutableFallbackAccounts(killswitch-aware) on all routing paths; non-replayable bodies with a killed main account correctly 429 immediately./claude-killswitchcommand (killswitch.ts): status/on/off/set sub-commands with per-account threshold overrides, persisted viasetKillswitchPersistent.Confidence Score: 5/5
Safe to merge; the killswitch routing logic is well-tested and the previously flagged issues are addressed.
The core routing changes are correct and covered by targeted integration tests. The only findings are in the /claude-killswitch command text output layer: account IDs not escaped in markdown tables, threshold values above 100 accepted without error, and set sub-command silently enabling the killswitch.
packages/core/src/killswitch.ts — command input parsing and status table rendering
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Incoming Request] --> B{failClosedOnUnknownQuota + no quota + backed off?} B -- Yes --> C[Return 429 Quota API unavailable] B -- No --> D{killswitch enabled?} D -- No --> K[Send to main] D -- Yes --> E[Eager quota refresh if needsRefresh] E --> F[Re-read mainQuota from QuotaManager] F --> G{killswitchPassesPolicy main quota?} G -- Passes --> K G -- Fails / killed --> H{isReplayableRequest?} H -- No --> I[survivingFallbacks = empty] H -- Yes --> J[getRoutableFallbackAccounts usable + killswitch-passing] I --> L{survivingFallbacks length > 0?} J --> L L -- Yes --> M[tryUsableFallbackAccounts] M --> N{fallbackResponse?} N -- Yes --> O[Return fallback response] N -- No --> P[killswitchRetryAfterSeconds] L -- No --> P P --> Q[Return 429 hard-block] K --> R[sendWithAccessToken main]Reviews (10): Last reviewed commit: "Merge branch 'fix/sidebar-fallback-quota..." | Re-trigger Greptile