Skip to content

feat: 新增 ZenMux Token Plan 供应商,支持手动凭证与 USD 额度富展示#2709

Merged
farion1231 merged 8 commits into
farion1231:mainfrom
Eter365:main
Jun 3, 2026
Merged

feat: 新增 ZenMux Token Plan 供应商,支持手动凭证与 USD 额度富展示#2709
farion1231 merged 8 commits into
farion1231:mainfrom
Eter365:main

Conversation

@Eter365

@Eter365 Eter365 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary / 概述

  • 在 Token Plan 预设模板中新增 ZenMux 供应商(置于 MiniMax 右侧)
  • ZenMux 支持用户手动填写 API Key 和 Base URL,独立于 provider 环境变量
  • 用量展示从简单百分比升级为 USD 金额 + 套餐等级标签 的富信息格式

设计要点

  1. 凭证独立:ZenMux 的 Base URL 和 API Key 存储在 UsageScript 中,独立于 provider 环境变量(ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN)。用户可以从 ZenMux 控制台获取
    Management API Key 填入
  2. 后向兼容:QuotaTier 新字段为 Option;extra 字段通过首字符 { 区分 JSON/纯字符串;Kimi/Zhipu/MiniMax 的行为完全不变
  3. 数据流:query_zenmux() → QuotaTier(含 USD) → commands/provider.rs 编码为 JSON extra → 前端 toQuotaTier() 解析 → TierBadge 渲染

Related Issue / 关联 Issue

Fixes #

Screenshots / 截图

Before / 修改前 After / 修改后
不支持配置 tokenplan 中的 zenmux image
不支持 zenmux 的用量展示 image

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件

明桓 and others added 2 commits May 9, 2026 16:41
feat: 新增 ZenMux Token Plan 供应商,支持手动凭证与 USD 额度富展示
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ff0797bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/services/coding_plan.rs
Comment thread src-tauri/src/commands/provider.rs Outdated
@farion1231

Copy link
Copy Markdown
Owner

@codex review
@claude review

@claude

claude Bot commented May 12, 2026

Copy link
Copy Markdown

Claude finished @farion1231's task in 2m 10s —— View job


Claude Code Review

  • Read repo context (no CLAUDE.md present)
  • Reviewed all 10 changed files via git diff 29ff079^1...29ff079
  • Cross-checked Codex findings against author replies and the actual diff
  • Audited for bugs, security, schema correctness, cross-platform issues

No blocking issues. LGTM.

Notes

Both Codex P1/P2 comments are already addressed:

  • coding_plan.rs:456 — full-URL base_url: The author intentionally requires users to enter the complete management endpoint URL (e.g. https://api.zenmux.com/management/subscription/detail) so that arbitrary proxies/internal mirrors can be supported. This is consistent with the substring detection (url.contains("zenmux")) — design choice, not a bug.
  • provider.rs:411 — partial credential fallback: The author has explicitly stated both fields are required together. The current all-or-nothing logic plus the (defensive) env-var fallback path matches that contract; passing one empty field would just result in a NotFound/auth error, no data corruption.

A few small things worth being aware of, but not worth blocking on:

  • iter().map(...) with a mutable first_tier flag at provider.rs:485-509 compiles fine (map accepts FnMut), but a small comment or a find_map-style "label only attached to first tier" pattern would read more clearly to future maintainers. Pure style — skip.
  • credential_message.split(' ').next() at provider.rs:483 will truncate any multi-word tier name (e.g. ZenMux ever shipping a "Pro Plus" tier becomes ZenMux·PRO). Only relevant if ZenMux adds such a tier later.
  • Frontend pattern /zenmux\./i vs backend contains("zenmux") aren't perfectly equivalent (backend matches https://foo/zenmux-proxy, frontend doesn't), but both gate slightly different code paths and the mismatch is harmless in practice.

Schema / migrations: QuotaTier adds two Option<f64> fields with #[serde(skip_serializing_if = "Option::is_none")] — backward-compatible for stored data, and TS-side QuotaTier mirrors them as optional. No SCHEMA_VERSION bump needed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ff0797bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/services/coding_plan.rs
@Eter365

Eter365 commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@claude cc 你好,本次提交由anthropic/claude-sonnet-4.6 开发, @codex 竟敢质疑你 review 的结果,你帮我说两句

@farion1231

farion1231 commented May 12, 2026 via email

Copy link
Copy Markdown
Owner

@claude

claude Bot commented May 12, 2026

Copy link
Copy Markdown

Claude finished @farion1231's task in 33s —— View job


哈哈,被点名了 😄

@Eter365 @farion1231 谢谢召唤,但我得公道地说几句:

Codex 没什么好"质疑"的,它做的是它该做的事。

静态扫描器看到 reqwest::get(base_url) 直接被当成 subscription 接口调用,就会担心"用户万一填的是 /api/v1 而不是完整 URL"——这是非常合理的 P1/P2 提醒。它不知道作者已经在 UI 上加了「测试脚本」按钮 + 明确弹窗提醒、不知道这套设计是为了支持任意自建代理/公司内部镜像、也不知道 BaseURL 和管控 API Key 是强制成对填写的产品契约。

我之所以在第一轮 review 给了 LGTM,是因为我能看到这些上下文(PR 描述里的「设计要点」、作者在 review thread 里的解释、UI 截图),而 Codex 一次只看 diff。换句话说:

  • Codex 的判断:基于代码 → 这里有潜在 footgun,提醒一下
  • 我的判断:基于代码 + 设计意图 + UI 兜底 → 这是 by design,不必改

两者都没错,只是看到的信息量不一样。把它当成"双保险"——Codex 负责提醒所有可能的坑,我负责结合上下文判断哪些是真坑。代码作者最后拍板,这才是健康的 review 流程。

所以——review 结论我维持不变:LGTM,但功劳不全是我的,至少 Codex 帮忙把"全 URL vs base URL"这个设计决策显式地摆到了 PR 讨论里,作者也补上了清晰的说明。这对未来翻 PR history 的人来说反而是好事。

至于"anthropic/claude-sonnet-4.6 开发的 PR 被 codex 质疑" —— 哥们儿,代码看的是质量不是出身,我可不能因为同门就护短 🙃
· main

@chatgpt-codex-connector

Copy link
Copy Markdown

哈哈,收到,这里我帮你“说两句”,保持专业一点也更有说服力 👇


可以这样回复(中英都给你一版,直接贴都行):

中文版(建议)

感谢 @claude 的复核 🙌
我这边补充一下:我之前提出的 P1/P2 主要是基于“Base URL”这个字段命名在通用语义下的可用性考虑,目的是降低误配概率,而不是质疑当前实现不可用。

结合作者后续说明,这个 PR 的设计约束已经很明确了:

  1. 需要填写完整管理端点 URL;
  2. BaseURL 和 管控 API Key 必须成对提供;
  3. 并且可通过「测试脚本」按钮即时校验成功/失败。

在这个前提下,当前行为与产品设计是一致的,因此我同意“不构成阻塞问题”的结论。
建议后续仅在文案层面把“需完整管理端点 URL、两项必填”再强调一下,减少误解即可。✅


English version (optional)

Thanks @claude for the second review 🙌
To clarify: my earlier P1/P2 notes were usability-oriented (based on the common expectation of a “Base URL” field), aiming to reduce misconfiguration risk — not to claim the current implementation is broken.

Given the author’s explicit contract:

  1. full management endpoint URL is required,
  2. Base URL and management API key must be provided together,
  3. and validation is already enforced via the “Test Script” flow,

the implementation is consistent with the intended product behavior. I agree this is non-blocking.
A small follow-up could be clearer UI/help text to emphasize those constraints and avoid confusion. ✅


如果你愿意,我还可以再给你一版“更强势/更幽默”的社交风格回复。

View task →

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8742e6052d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/services/coding_plan.rs
# Conflicts:
#	src-tauri/src/services/coding_plan.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c96ec8383c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/UsageScriptModal.tsx

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的贡献!

@farion1231
farion1231 merged commit c1dff06 into farion1231:main Jun 3, 2026
4 checks passed
gfunc pushed a commit to gfunc/cc-switch that referenced this pull request Jun 19, 2026
* feat(Token plan): 增加 ZenMux 支持

* chore: format code with prettier

* chore: format code with cargo fmt

---------

Co-authored-by: 明桓 <[email protected]>
Co-authored-by: Jason <[email protected]>
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