Skip to content

feat: Z.AI usage bars in Models settings - #797

Merged
mrubens merged 3 commits into
RooCodeInc:developfrom
pridemusvaire:feat/zai-usage-bar
Jul 26, 2026
Merged

feat: Z.AI usage bars in Models settings#797
mrubens merged 3 commits into
RooCodeInc:developfrom
pridemusvaire:feat/zai-usage-bar

Conversation

@pridemusvaire

@pridemusvaire pridemusvaire commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Poll Z.AI's monitor quota endpoint (/api/monitor/usage/quota/limit) for connected Z.AI and Z.AI Coding Plan providers
  • Render 5-hour / weekly (and monthly tools) usage bars under those rows on Models settings, same surface as Kimi / ChatGPT subscription usage
  • Region-aware host selection: International → api.z.ai, China → open.bigmodel.cn

Implementation

Layer Change
packages/types zai / zai-coding-plan on SubscriptionUsageProviderId; host + path constants
packages/db parseZaiQuotaUsage, fetchZaiUsage, fetchZaiCodingPlanUsage; included in getSubscriptionProviderUsage
apps/web Pass usage into ConnectedProviderRow for both Z.AI providers

Upstream payload (undocumented, same as Coding Plan tools / pi-glm-usage):

{
  "code": 200,
  "data": {
    "level": "lite",
    "limits": [
      { "type": "TOKENS_LIMIT", "unit": 3, "percentage": 16, "nextResetTime": 1777819631597 },
      { "type": "TOKENS_LIMIT", "unit": 6, "percentage": 4, "nextResetTime": 1778262784969 }
    ]
  }
}

Missing credentials or unparseable responses still soft-fail (no bar), matching existing providers.

Test plan

  • Unit tests for parseZaiQuotaUsage and both fetchers (global + china hosts, coding-plan key)
  • Connect Z.AI with an API key → Models settings shows usage bars when the monitor endpoint returns windows
  • Connect Z.AI Coding Plan → same bars under that row
  • China region uses open.bigmodel.cn
  • No key / 401 / empty limits → row stays connected with no usage line (no error toast)

Poll the undocumented monitor quota endpoint with the saved API key
(and region host) so operators can see 5-hour and weekly usage under
connected Z.AI rows, matching Kimi/ChatGPT subscription usage.
@roomote-roomote

roomote-roomote Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

Reviewed b7ffb65

@pridemusvaire
pridemusvaire marked this pull request as draft July 26, 2026 11:48
@pridemusvaire
pridemusvaire marked this pull request as ready for review July 26, 2026 12:02
Add 401 soft-fail and Settings UI regression tests, share the API-key
subscription usage allowlist, align the 5h window label, and add a
changeset for the release notes.
Accept business-error envelopes on HTTP 200, and map TIME_LIMIT
currentValue/usage fields so monthly tools windows render correctly.
@mrubens
mrubens merged commit 1bd7d13 into RooCodeInc:develop Jul 26, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants