Skip to content

fix(usage,tui): /usage while busy; repair every coding-plan probe base normalization - #2537

Merged
topcheer merged 1 commit into
mainfrom
fix/usage-panel-busy-and-zai-coding
Sep 18, 2026
Merged

topcheer merged 1 commit into
mainfrom
fix/usage-panel-busy-and-zai-coding

Conversation

@topcheer

Copy link
Copy Markdown
Owner

用户报告

  1. /usage 忙时不显示:命令被排队到 run 结束才执行
  2. zhipu coding plan 显示'不支持查询';kimi 同样
  3. 用户裁决:'所有的,不要让我指出来你再实现'→ 全量 review 后一次修完所有 probe

根因(系统性)

各 probe 把端点路径直接拼在配置的 chat base 后,未归一化 base 形状 → 404 → 面板显示'不支持':

Probe 修复前 修复后
ZaiProbe coding base 未剥(.../coding/paas/v4/api/monitor 404);只认 open.bigmodel.cn,z.ai 端点漏配 剥 /api/coding/paas/v4、/api/paas/v4、/api/anthropic、/v4;域名补 api.z.ai
KimiProbe MatchesURL 恒 false(#2394 过度纠偏)——但 Kimi Code 平台在独立域名 api.kimi.com(sk-kimi-* key 与开放平台不互通);/coding/v1 base 拼 /v1/usages=双 v1 认领 kimi.com;归一到恒定端点 /coding/v1/usages
DeepSeek base 含 /v1 再拼 /user/balance → /v1/user/balance 404 剥 /v1
Moonshot 同上双 v1 剥 /v1(端点 /v1/users/me/balance 在根)
Minimax /v1、/anthropic base 双拼 remains 路径 剥 /v1、/anthropic
Openrouter /api/v1 base 双拼 credits 剥 /api/v1

另:/usage 加入 shouldExecuteWhileBusy 白名单(纯 UI+异步探测,无 agent 依赖)。

测试

新增 adapters_coding_base_test.go:每 vendor 全 base 形状(ggcode.example.yaml 逐一对照)打 mock server 断言精确请求路径;域名归属断言(kimi.com≠moonshot.* 单一属主);两包测试全绿。

Co-Authored-By: ggcode noreply@ggcode.dev

…e normalization

Two user reports, one systemic root cause.

1. /usage queued behind runs: shouldExecuteWhileBusy whitelist missed
   it, so the panel (pure UI + async vendor probes, zero agent
   dependency) only appeared after the run finished. Added to the
   always-safe list; test pinned.

2. 'Unsupported' panel for coding-plan users (zhipu, kimi): the probes
   appended endpoint paths to the configured chat base WITHOUT
   normalizing it, producing 404 paths:
   - ZaiProbe: .../api/coding/paas/v4 + /api/monitor/... ; also only
     matched open.bigmodel.cn while ggcode.example.yaml ships
     api.z.ai international endpoints, and never stripped
     /api/anthropic entries.
   - KimiProbe: matched NO host at all (#2394 over-correction) even
     though Kimi Code platform lives on its OWN host api.kimi.com
     (keys sk-kimi-*, disjoint from the open platform's
     api.moonshot.cn) and its usage endpoint is the constant
     /coding/v1/usages - the old code appended /v1/usages to the
     /coding/v1 base (double /v1, 404).
   - DeepSeek/Moonshot: chat bases carry /v1, balance endpoints are
     root-anchored -> /v1/user/balance, /v1/v1/users/... 404s.
   - Minimax: /v1 and /anthropic bases doubled into
     /v1/v1/api/openplatform/...
   - Openrouter: /api/v1 bases doubled into /api/v1/api/v1/credits.

   All probes now normalize every base shape from ggcode.example.yaml
   to their endpoint's true anchor. MatchesURL ownership: kimi.com ->
   KimiProbe, moonshot.* -> MoonshotProbe (single-owner rule intact,
   hosts are disjoint). Regression pins cover every base shape per
   vendor, run against mock servers asserting exact request paths.

Tests: internal/usage and internal/tui suites green.

Co-Authored-By: ggcode <noreply@ggcode.dev>
@topcheer
topcheer merged commit d7d0ad9 into main Sep 18, 2026
9 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.

1 participant