feat: show OpenCode Go subscription rate limits on Mac and iPhone - #12
Merged
Conversation
Query the official GET https://opencode.ai/zen/go/v1/usage endpoint with the opencode-go API key from ~/.local/share/opencode/auth.json and surface the 5-hour rolling / weekly / monthly utilization windows like the existing Claude and Codex limit sections. - OpenCodeGoLimitsProvider: HTTP fetch with explicit User-Agent (the server 403s default tool UAs — verified against production), key read from the shared OPENCODE_DATA_DIR-aware root list, gated on AppEnv.isBundledApp so swift test / raw binaries never spend the user's key on network calls (PTB_PARITY=1 unlocks a live endpoint check) - UsageStore: fetch alongside Claude/Codex limits with a 5-minute minimum poll interval (endpoint is a 3-table join with no cache guidance), feed menu bar line, warning state, highestLimitUtilization, candy windows, notifications and limitsReady - Popover: three limit rows with reset countdowns on the OpenCode tab, rate-limited badge and 15-min stale badge - iPhone payload: new optional opencodeGo{5h,Weekly,Monthly} windows, backward/forward compatible, rendered in the LimitsCard
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.
What
Shows the OpenCode Go plan's usage limits (5-hour rolling / weekly / monthly percentages with reset countdowns) everywhere the Claude/Codex limits already appear:
rate-limited, and the shared 15-min stale badgeOpenCode 41%line (max of the three windows), gated on OpenCode usage today like Claude/CodexGo 5h/Go Weekly/Go Monthlyrows in the LimitsCard, with real reset dates (unlike the flattened Codex rows)highestLimitUtilization, candy-eligible windows, andlimitsReadyall include the new windowsHow
Official endpoint
GET https://opencode.ai/zen/go/v1/usage(shipped upstream 2026-08-11, anomalyco/opencode#16513), authenticated with theopencode-gokey already on disk in~/.local/share/opencode/auth.json— no browser cookies, no workspace ID. Verified live against production during development.Implementation notes:
OpenCodeGoLimitsProviderreusesLocalAdditionalUsageReader.defaultOpenCodeRoots(soOPENCODE_DATA_DIRjust works) and sends an explicitUser-Agent: PokeTokenBar/<version>— the server 403s default tool UAs (reproduced with Python-urllib; regression-tested)Test hermeticity fix (found by the suite)
Adding a third limits provider to
UsageStore.initmade every existing test construction that runsrefresh()without stubbing it hit the live network with the developer's real API key —RareCandyGrantIntegrationTestsfailed with live data leaking into candy windows. Beyond stubbing the affected sites (Grok/RareCandy/UsageStoreTests), the real provider is now gated onAppEnv.isBundledApp(same single gate as notifications/keychain/production logs) soswift testcan never make this class of call by construction.PTB_PARITY=1unlocks a live endpoint smoke test (testLiveOpenCodeGoUsageEndpoint) for schema-drift detection.The env-guard test needed
AppEnvallowlisted for the newPTB_PARITYflag read (AppEnv.isParityRun) — same QA-flag category asCompanionStore'sPTB_STATE_DIR.Verification
swift test: 751 tests, only the documented pre-existingtestHermesAcceptsMillisecondStartedAttimezone failure (fails identically onmain)llvm-cov --show-regions: zero^0regions in the new provider, models, and all touchedUsageStorebranchesPTB_PARITY=1live check:rolling=72 weekly=69 monthly=34decoded correctly end-to-endPokeTokenBarmacOS,PokeTokenBariOSsimulator) buildThe widget intentionally keeps its curated compact limit set (no Opus/Sonnet/Codex-2nd either) — can extend later if wanted.