Add an OpenCode collector to the agents panel - #11372
Open
gIvarsDev wants to merge 1 commit into
Open
Conversation
OpenCode Go subscriptions have their own rolling, weekly, and monthly windows, and none of them surface anywhere on the desktop today. A subscription burned through opencode on an OpenCode provider is invisible to the panel: the claude collector only counts opencode sessions that ran on an Anthropic provider, and the codex collector only those that ran on Codex. The collector reads the three windows from the OpenCode Go usage endpoint and the token history from opencode's own message database, the same database the claude collector already scans. omarchy-agent-usage-update discovers it by glob, so nothing else changes. Both sources are optional and independent: without credentials the record still carries local token history and says why the meters are missing; without a database it carries the meters alone.
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
Adds an
opencodecollector to the agents panel, so an OpenCode Go subscription gets the same meters, weekly chart, and model breakdown the other agents already have.Why
OpenCode Go enforces three usage windows — rolling 5-hour, weekly, and monthly — and none of them surface anywhere on the desktop today.
The panel is not blind to opencode in general, but it is blind to this subscription:
omarchy-agent-usage-claudecounts opencode sessions that ran on an Anthropic provider, andomarchy-agent-usage-codexcounts the ones that ran on Codex. A subscription burned entirely throughopencode-gofalls between them and shows up nowhere.How
Following the contract in
shell/plugins/agents/README.md("adding an agent is adding a collector"):bin/omarchy-agent-usage-opencode— the record, from two independent sourcesshell/plugins/agents/assets/opencode{,-light}.svg— the mark, in both surface variantsmanifest.json/README.md— the new agent listed alongside the othersomarchy-agent-usage-updatediscovers the collector by glob, so nothing in the update path or the panel changes.Limits come from the OpenCode Go usage endpoint. Token history comes from opencode's own message database — the same database
omarchy-agent-usage-claudealready scans, filtered to theopencode-goandopencodeproviders instead ofanthropic. The scan mirrors that one: read-only connection, per-row failure isolation, and the same cache so--limits-onlykeeps its freshness promise.One thing worth flagging
The usage endpoint is undocumented.
https://opencode.ai/zen/go/v1/usagereturns exactly the three windows the panel wants, but it is not in OpenCode's published docs and is not referenced by their CLI. I found it by probing route names. It may change or disappear without notice.I built the collector so that costs nothing when it happens: the probe failing leaves
limitsempty, writes a status line into the panel, and the token history below it still renders. Same shape as the claude collector without credentials. But it is a real dependency on an unpublished surface, and you should weigh that rather than discover it later.Two smaller notes:
2for 2%); the panel renderspercent * 100, so the collector divides. Passing the value through paints 2% as 200% and trips the alarm state.403, so the request names itself. Without that header the probe silently fails and the meters never appear — it is commented in place so it does not get tidied away.Testing
./test/all— no regressions. Five files fail on this machine (bar-icon-geometry,config,locate,snapper,unowned-system-paths), and they fail identically on a clean checkout with these changes stashed; they look environment-dependent rather than related to this change. Everything else passes.Also exercised by hand against a live subscription:
Not signed in to OpenCode.+ how to fix; token history still rendersOpenCode usage endpoint unavailable.; meters hidden, history kepthasLocalStats: falseScreenshot