1 Commits
Author SHA1 Message Date
Jason bbcf0aeaec fix(usage): show account balance when a Zhipu account has no coding plan
Since the token plan template became the default for Zhipu cards, pay-as-you-go
accounts showed "query failed": the quota endpoint answers HTTP 200 with
{"code":500,"msg":"当前用户不存在coding plan","success":false}, which looked like
the provider was broken (#8465).

Show the plan when there is one, otherwise the account balance:

- coding_plan: query_coding_plan returns CodingPlanOutcome, with ZhipuNoPlan
  for the personal plan when msg says the account has no coding plan. Auth
  failures, network errors and other business errors are unchanged.
  get_coding_plan_quota keeps its old result (used by the modal test button).
  The team plan does not fall back: the balance endpoint ignores the
  organization/project headers.
- balance: query_zhipu_balance reads availableBalance from the undocumented
  /api/biz/account/query-customer-account-report, which accepts the inference
  API key (verified on open.bigmodel.cn, CNY). api.z.ai is assumed to share
  the shape and is shown in USD; not verified. Not added to detect_provider so
  it does not compete with the injected token plan template.
- The token_plan branch of query_provider_usage returns the balance result on
  ZhipuNoPlan; the tray already renders it as a balance line.
- UsageFooter only renders token plan data as tiers when every row is a
  percentage, so the fallback balance uses the balance layout.
2026-10-19 18:01:47 +08:00