feat(console): add go usage endpoint - #16513
Merged
Merged
Conversation
1 task
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
2 tasks
|
Hey, any news on merging this? |
Contributor
Author
|
no clue |
|
+++ |
|
I would like to see this implemented |
|
+1 for implementing this. In the meantime I'm using this hacky solution https://pi.dev/packages/pi-go-bars |
|
I would like to see this implemented |
|
Official support would be nice. If you need usage and quota tracking in opencode, https://github.com/slkiser/opencode-quota |
|
up |
|
I'd employ this feature. |
|
+1 |
|
+1 |
|
Did they truly forget about this? |
|
Would really love this for OpenUsage. A lot of users keep asking, and the local SQL is unreliable. |
|
+1 |
|
+1 pls merge this |
This was referenced May 23, 2026
|
Collaborator
|
sorry for the delay friends: |
d3ara1n
added a commit
to d3ara1n/pi-extensions
that referenced
this pull request
Aug 12, 2026
opencode.ai/zen/go/v1/usage 随 anomalyco/opencode#16513 合并后已上线。 重写 opencodeGoUsage 适配实测响应结构(usage.rolling/weekly/monthly 的 percent + resetsAt ISO 时间戳),并注册回 BUILTIN_PROVIDERS(id 与 pi 内置 provider key 一致,有 key 即自动生效)。
OnesoftQwQ
added a commit
to OnesoftQwQ/opencode-go-copilot
that referenced
this pull request
Aug 12, 2026
Fetch Go plan subscription usage from the official /zen/go/v1/usage endpoint (live since 2026-08-11, anomalyco/opencode#16513) and render it as a section in the token status bar tooltip. - add src/goUsage.ts: usage fetcher with 5-minute TTL cache, lenient field-name parsing (percent/usagePercent, resetsAt/resetInSec), stale cache retention on failure and 401 detection (no active Go plan) - statusBar: tooltip appends usage section (5h/weekly/monthly percent + reset countdown + useBalance + last updated), background polling with configurable interval, click-to-refresh via command binding - add opencodego.checkUsage command: force refresh and show summary - new settings opencodego.showUsageInTooltip (default true) and opencodego.usageRefreshInterval (default 5 min, 1-60) - zh-cn/en localization for all new strings
OnesoftQwQ
added a commit
to OnesoftQwQ/opencode-go-copilot
that referenced
this pull request
Aug 12, 2026
* feat: show OpenCode Go plan usage in the status bar tooltip Fetch Go plan subscription usage from the official /zen/go/v1/usage endpoint (live since 2026-08-11, anomalyco/opencode#16513) and render it as a section in the token status bar tooltip. - add src/goUsage.ts: usage fetcher with 5-minute TTL cache, lenient field-name parsing (percent/usagePercent, resetsAt/resetInSec), stale cache retention on failure and 401 detection (no active Go plan) - statusBar: tooltip appends usage section (5h/weekly/monthly percent + reset countdown + useBalance + last updated), background polling with configurable interval, click-to-refresh via command binding - add opencodego.checkUsage command: force refresh and show summary - new settings opencodego.showUsageInTooltip (default true) and opencodego.usageRefreshInterval (default 5 min, 1-60) - zh-cn/en localization for all new strings * feat: add logging for Go usage fetch and polling Log the usage data fetch lifecycle so the extension output channel shows why the status bar tooltip has or lacks usage data. - goUsage: log successful fetches (goUsage.fetch.ok, info, with url, durationMs, per-window percent and useBalance); split failures into goUsage.fetch.unauthorized (401, no active Go plan) and goUsage.fetch.failed (other); log JSON parse errors as goUsage.fetch.parseError — exactly one log record per attempt - statusBar: debug logs for polling lifecycle (goUsage.poll.start/stop/disabled/skip) - extension: remove unused hasApiKey helper - AGENTS.md: document goUsage.* log tags in the logging conventions * feat: compact Go usage tooltip layout Simplify the Go usage section in the status bar tooltip per user request: no blank separator line, window labels shortened to "5H" / Week / Month with percent only, and a single reset countdown line for the 5h window. - statusBar: render "Go 用量" title, "5H 65%" / "周 30%" / "月 12%" lines and "五小时窗口将在 2H13M 后重置"; drop the useBalance and last-updated lines - goUsage: formatResetDuration now emits compact "2H13M"/"45M"; remove formatAgo and getUsageFetchTimestamp (no longer used) - localize: replace tooltip keys with the compact variants - AGENTS.md: sync function docs * feat: show Go plan usage as the status bar main text The status bar now displays the Go plan usage (5h window) as its main text, e.g. "Go 5H 65%" (or "Go --" while no usage data is cached), instead of the token count. Token input/output details remain in the tooltip alongside the usage windows. - statusBar: add updateStatusBarGoUsageText, use it from initStatusBar, updateContextStatusBar, updateStatusBarWithApiPrompt, refreshGoUsage and refreshGoUsageNow; polling now always runs (status bar text depends on usage data), showUsageInTooltip only gates the tooltip section; drop createProgressBar and the token-based main text - statusBar: updateContextStatusBar drops the unused model parameter; updateStatusBarWithApiPrompt signature simplified to (statusBarItem) - provider: update call sites; drop unused ASK_IMAGE_TOOL_NAME and InterceptedToolCall imports - localize: replace Token Count / Ready / Current model token usage keys with Go usage and token usage - AGENTS.md: sync status bar docs and log tag list * feat: drop Go usage tooltip title, keep status bar numeric icon - statusBar: remove the "Go 用量" title line from the tooltip usage section (windows now follow the token lines directly, no blank line); keep the $(symbol-numeric) icon in the status bar main text ("$(symbol-numeric) Go 5H 65%" / "$(symbol-numeric) Go --") - AGENTS.md: sync docs * feat: join tooltip usage label and percent with em dash Use "——" (no space) between the window label and the percent in the status bar tooltip usage section: "5H——65%" / "周——30%" / "月——12%". * chore: apply prettier-style formatting Reformat src/extension.ts, src/goUsage.ts, src/localize.ts, src/provider.ts and src/statusBar.ts with the prettier code style (tab indentation, long-line wrapping). No logic changes. * Revert "chore: apply prettier-style formatting" This reverts commit bf4c4a3.
3 tasks
This was referenced Aug 12, 2026
7 tasks
ltmoerdani
pushed a commit
to ltmoerdani/opencode-copilot-chat
that referenced
this pull request
Aug 12, 2026
Pure, unit-testable module for the official OpenCode Go usage endpoint (upstream anomalyco/opencode#16513, verified live in production): - fetchGoUsage(): GET /zen/go/v1/usage with the existing opencode-go key as a Bearer token; classifies failures (unauthorized / no-subscription / not-found / network / invalid) so callers can fall back to local estimates. The key is never logged or persisted. - mergeServerUsage(): overlays the server-accurate rolling/weekly/monthly percent + resetsAt onto a locally-computed UsageSummary. The endpoint does not return raw spend, so spent is derived as limit x percent / 100 to keep the status bar and tooltip consistent; today/yesterday and per-session spend stay local. - GO_LIMITS stays the source of the display limits (they match the server's ZEN_LIMITS).
3 tasks
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.
Issue for this PR
Closes #16017
Type of change
What does this PR do?
this PR adds an API endpoint at
/zen/go/v1/usagethat will provide the same opencode go usage data as in the zen workspace dashboard.If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
unfortunately i don't think this is a change i can verify as an outside contributor. i did try running
bun dev:remotebut met with cloudflare api key error.I did copy the pattern in
/zen/v1/modelsand copied the logic from/workspace/[id]/billing/lite-section.tsxScreenshots / recordings
not a ui change
Checklist
i guess running dev server and building counts as testing? but yea i don't think i can test this feature locally
If you do not follow this template your PR will be automatically rejected.