Skip to content

fix(opencode): accept the nested usage envelope - #104

Merged
bernardopg merged 3 commits into
mainfrom
fix/opencode-usage-envelope
Nov 8, 2026
Merged

bernardopg merged 3 commits into
mainfrom
fix/opencode-usage-envelope

Conversation

@bernardopg

Copy link
Copy Markdown
Owner

Summary

Supersedes #103 and keeps its commit by @alvorithm unchanged, with one follow-up commit on top.

/zen/go/v1/usage now answers with a nested envelope, usage.{rolling,weekly,monthly}.{status,percent,resetsAt}, where percent is the used share and resetsAt is an absolute ISO 8601 time. The adapter only validated the old flat rollingUsage / resetInSec shape, so every response failed validation. The card then fell back to "Authenticated, quota endpoint unavailable" and none of the three windows from #22 appeared.

  • fix(opencode): accept the nested usage envelope (fix(opencode): accept the nested usage envelope #103): parses both envelopes. The flat one still converts resetInSec to an absolute time.
  • fix(opencode): keep a missing reset null and document the nested envelope:
    • A nested window with no resetsAt, or an empty one, keeps its percentage with a null reset instead of an invented one.
    • New fixtures cover fractional percentages, a rate-limited window, useBalance in the nested shape and an out-of-range nested percentage, which degrades to auth-only like the flat shape.
    • docs/providers.md described only the flat shape. It now names the nested shape first and the flat one as legacy.

Other clients that read this endpoint report the same shape change.

Related issues

Supersedes #103.

Type of change

  • New provider
  • Bug fix
  • Enhancement
  • Documentation / i18n
  • CI / tooling

Checklist

  • plugin.json .version and CHANGELOG.md are consistent (not release-bearing; ## Unreleased bullet)
  • New/changed provider scripts are executable and emit valid JSON
  • i18n/en.json keys have translations in every locale (no new strings)
  • Every commit is signed off (git commit -s) under the DCO
  • CI is green

Local gates: check-metadata, check-changelog, check-dco, bash -n, shellcheck -S warning, qmllint, actionlint, gitleaks, every tests/test-*.sh (including the native widget runtime on Wayland), and AIOC_COVERAGE_MIN=95 scripts/coverage.

alvorithm and others added 3 commits November 8, 2026 15:10
GET /zen/go/v1/usage returns usage.rolling.percent with an absolute resetsAt,
not the flat rollingUsage.usagePercent with a relative resetInSec the adapter
validated. Every response therefore failed validation and the card degraded
to the authenticated-only /models check, hiding all three quota windows.

Both shapes are now accepted, so an older deployment is unchanged.

Signed-off-by: Álvaro Tejero Cantero <[email protected]>
…lope

The nested /zen/go/v1/usage envelope can omit resetsAt or send an empty
string. Cover that case, fractional percentages, a rate-limited window,
useBalance in the nested shape and an out-of-range nested percentage, so
each degrades the way the flat envelope already did.

docs/providers.md still described only the flat rollingUsage/resetInSec
shape; it now names the nested shape first and the flat one as the
legacy form the adapter keeps parsing.

Signed-off-by: Bernardo Pinto Gomes <[email protected]>
@github-actions github-actions Bot added documentation Improvements or additions to documentation area:providers Provider adapters (providers/) area:ci CI, workflows, tooling labels Nov 8, 2026
@bernardopg
bernardopg merged commit 3a0ec4b into main Nov 8, 2026
21 checks passed
@bernardopg
bernardopg deleted the fix/opencode-usage-envelope branch November 8, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, workflows, tooling area:providers Provider adapters (providers/) documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants