Skip to content

feat(web): simplified Claude/GPT price list on /pricing - #14

Merged
Nanako1900 merged 15 commits into
mainfrom
claude/simplify-model-marketplace-design-bd442f
Nov 8, 2026
Merged

Nanako1900 merged 15 commits into
mainfrom
claude/simplify-model-marketplace-design-bd442f

Conversation

@Nanako1900

Copy link
Copy Markdown
Owner

Agent

  • Tool: Claude Code
  • Tool version: 2.1.201
  • Model (full id): claude-opus-5-5(实现与审查子代理另用 claude-sonnet-5-5、claude-haiku-5-5,提交尾注写明各自模型)
  • Host (CLI / IDE / GitHub coding agent / other): Claude 桌面版(Code 标签页)
  • Date (UTC): 2026-11-08

本 PR 的代码由 AI 辅助生成(提交者不是 new-api 的历史核心开发者)。

Links

User request

  • Verbatim:
    • 「查看本站 前端 模型广场的设计 目前我觉得太繁琐了 因为本站只做claude和gpt的几个模型 你有没有什么思路能简约处理」
    • 「成功率哪些我也想保留」
    • 「这个设计不错 但是还需考虑不同claude渠道或者版本的选择 价格也有所差异 比如官方渠道价格x1.5 kirox0.9这样 分开的 按照系统里面的模型标签来」
    • 「Yes, on groups」「Approve, write spec」「Approve, write plan」「Subagent per task」
    • 「提交了吗」
    • 「Push and open a PR now」
  • Later constraints or corrections from the user:选择题中选择了:充值价格开关「Toggle only with discount (Recommended)」、详情「Keep the existing drawer (Recommended)」、浏览器检查后端「My live site (Recommended)」(未提供站点地址,浏览器检查未做)。「按照系统里面的模型标签来」经确认指分组(group_ratio 倍率挂在分组上,模型标签不带倍率)。

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user: 不适用

Open gate — do not open unless all are satisfied

  • Out of scope (including pass-through-only forwarding): no
  • Usage / configuration / integration (answered instead of opening): no
  • Required issue facts present without invention: 无 issue(分叉仓库内部 PR,见 Links)
  • Verification is actual commands or steps and observed results, not only go build or tests passed: yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • Open: yes
  • If no, what was told to the user: 不适用

Kind

  • Bug fix
  • New feature
  • Performance / refactor
  • Docs
  • Other:

Issue facts

  • Actual behavior:上游模型广场面向 40+ 供应商:侧栏 5 组筛选(分组/供应商/标签/计费类型/端点)、工具栏 5 个控件、信息密集的卡片和分页。本站只有少量 Claude / GPT 模型,筛选几乎不起作用;同一模型在不同渠道(分组,如官方 ×1.5、Kiro ×0.9)的价格不能并排对比。
  • Impact:公开页面 /pricing。
  • Frequency:每次访问。
  • Evidence that the problem is in new-api rather than the client or upstream:web/src/features/pricing/index.tsx、components/pricing-sidebar.tsx、components/pricing-toolbar.tsx、components/model-card.tsx(本 PR 之前的页面)。
  • Applicable types and their fields:frontend — /pricing 页面;billing — 只读显示,不改计费;relay / deployment — 不适用。

Change

  • 新页面(web/src/features/pricing/components/meow/):按家族(Claude / GPT,其余为「其他」)分卡片,卡片内按渠道分段。渠道 = 当前用户可用分组(排除 auto),显示分组描述(经 translateServerText 翻译,空则用分组名)、倍率和可复制的令牌分组名;一个家族只有一个渠道时并入标题行。
  • 每行:模型名(可复制)和上下文长度;输入 / 输出 / 缓存读价格(已乘渠道倍率,复用 formatGroupPrice);按次计费合并为一格(formatFixedPrice);表达式计费合并为一格并复用 ModelPriceCell(阶梯、分时、混合计费说明由它处理)。合并单元格带 aria-colspan=3。
  • 每个渠道单独的近 24 小时成功率、24 格小时状态条、延迟 · 速度:复用 GET /api/perf-metrics?model=X(已按分组返回)。每个模型一个请求,查询键与详情抽屉相同、共享缓存。指标桶可配置为分钟 / 5 分钟 / 小时,状态条按小时取平均;每个模型用自己的时间窗口。
  • 充值价格开关只在 price !== usd_exchange_rate 时显示。点击行打开现有详情抽屉(懒加载)。整页包在 <main> 中。
  • 排序:渠道按倍率降序;模型按 token → 表达式 → 按次分层,层内按基础价降序。
  • web/src/lib/query-client.ts(上游文件,标注 MeowAPI):查询 meta 新增可选 errorPage?: boolean,为 false 时 500 错误不跳 /500。价目表的指标查询设为 false,指标接口故障时价格照常显示、指标显示「—」。其它查询行为不变。
  • web/src/routes/pricing/index.tsx(上游文件):只改导入和 component 两行,validateSearch / beforeLoad 不变。旧 Pricing 组件保留未删除。
  • 7 个语言文件各新增 5 个词条。

Research

Duplicate / prior art

Docs and code

  • https://docs.newapi.ai/ :未查阅(不涉及用法或配置问题)
  • https://deepwiki.com/QuantumNous/new-api :未查阅
  • README / repo docs:按 AGENTS.md、web/AGENTS.md(组件复用、i18n、toIntlLocale、测试规则)执行
  • Code paths and what they imply for this change:
    • controller/pricing.go GetPricing:usable_group 实际是「分组 → 描述字符串」(前端类型声明为对象,两种形态都兼容);group_ratio 已按当前用户的用户组特殊倍率解析。
    • controller/perf_metrics.go、pkg/perf_metrics/metrics.go:单模型接口返回 groups[](含 series),汇总接口不分组,因此不需要新后端接口;setting/perf_metrics_setting 的桶大小可配置。
    • service/group.go:分组描述是由前端翻译的英文源文本(如 "Default group")。
    • web/src/lib/query-client.ts、web/src/main.tsx:任何查询的 500 都会跳转 /500。

Alternatives considered

  • Option A:保留上游页面,只隐藏筛选和工具栏。卡片依旧繁琐,且要改多个上游文件。
  • Option B:家族卡片 + Claude/GPT 切换。品牌感强,但价格不便对比。
  • Why this approach:价目表一眼对比各渠道价格;新 UI 放在 meow-* 文件,上游只改路由两行和查询客户端一个可选字段,便于合并上游。

Files

Path Why
web/src/features/pricing/lib/meow-catalog.ts 家族 → 渠道 → 模型的分组与排序;24 格状态映射
web/src/features/pricing/hooks/use-meow-channel-perf.ts 按模型获取分组指标
web/src/features/pricing/components/meow/* 页面外壳、页面内容、家族卡片、渠道表、模型行、状态条
web/src/routes/pricing/index.tsx 路由指向新页面
web/src/lib/query-client.ts errorPage 可选退出 500 跳转
web/src/i18n/locales/*.json 5 个新词条
web/src/features/pricing/__tests__/meow-*.test.*、web/src/lib/__tests__/meow-query-client-error-page.test.ts 测试

Behavior

  • Before:模型广场为侧栏筛选 + 工具栏 + 卡片/表格 + 分页;价格按所选分组或最低倍率显示。
  • After:价目表按家族和渠道分段,各渠道价格已含倍率并显示该渠道自己的成功率;无搜索、筛选、排序、分页,价格固定为 / 1M tokens。
  • Explicit non-goals / leftover work:
    • /pricing?vendor=… 等旧查询参数(如排行榜的供应商链接)被忽略,显示完整列表。
    • 顶部导航仍显示「模型广场」,页面标题为「模型与价格」。
    • /pricing/$modelId 详情页与旧 Pricing 组件未改。
    • 指标加载中与无数据都显示「—」;整行可点击,价格文字不能选中。
    • 每次访问按模型数发指标请求(约 10 个),计入全局 API 限流;模型很多时应改为批量接口。

Verification

  • Commands and results(web/,HEAD ab031f7):
    • bun run typecheck:无类型错误(1530 个文件)
    • bun run test src/features/pricing src/lib src/routes:28 个文件、421 个测试通过
    • bun run build:成功
    • 改动文件 bunx oxlint -c .oxlintrc.json …:退出码 0;bunx oxfmt -c .oxfmtrc.json --check …:格式正确
    • 全量 bun run test(1db75843,最后几项修复之前):245 个文件、2752 个测试通过。实现子代理的两次全量运行中有不相关文件偶发失败(usage-logs/audit/viewer 等),单独运行及在基线提交上均通过。
    • git diff --numstat 语言文件:7 个文件各 5 0;受保护的转义 key footer.newapi… 未变。
  • Manual steps and observed result:
    • 有意破坏后重跑测试,确认测试会失败:充值开关条件改为恒真、指标按错误分组索引、删除抽屉、删除 errorPage: false、删除 500 跳转、删除 channelModel 的 enable_groups 固定 —— 对应测试均失败,恢复后通过。
    • 每个任务由独立子代理做规格审查和代码质量审查,最后做全分支审查;确认的问题(小时桶聚合、表达式计费丢阶梯、ARIA 列错位、倍率标签对比度、500 跳转、分组描述未翻译、缺 <main>)均已修复并补测试。
  • UI: screenshot or recording (or why none):无。未在浏览器中查看(未提供线上站点地址)。
  • Tests added or updated, or why none:meow-catalog.test.ts、meow-family-card.test.tsx、meow-pricing-catalog.test.tsx(使用真实 createAppQueryClient,只 mock HTTP)、meow-pricing-route.test.ts、meow-query-client-error-page.test.ts。
  • Databases / providers / platforms exercised:不涉及后端和数据库改动;jsdom(Vitest)。
  • Not verified:真实浏览器渲染(桌面 / 手机宽度 / 深色模式);真实站点数据(分组、倍率、指标);Firefox / Safari 中复制按钮在整行点击层之上的点击。

Risks

  • Failure modes:指标接口失败 → 显示「—」,不提示、不跳转;定价接口失败 → 页面显示错误和重试按钮(同时有全局 toast)。共享查询键的 meta 后写者生效,仅从抽屉触发的失败仍可能提示或跳转 500。
  • Billing / quota / auth impact:不涉及计费和额度(只读显示);不涉及认证。
  • Follow-ups:浏览器检查;是否把导航「模型广场」改名;旧 ?vendor= 链接;模型增多时的批量指标接口。

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope (Coding Plan / reverse-engineered channel / third-party wrapper / Codex / pass-through-only forwarding): no

🤖 Generated with Claude Code

Hongyu Qi and others added 15 commits November 8, 2026 00:01
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mantics

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…dows per model

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
… drawer

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-marketplace-design-bd442f

# Conflicts:
#	web/src/i18n/locales/en.json
#	web/src/i18n/locales/fr.json
#	web/src/i18n/locales/ja.json
#	web/src/i18n/locales/ru.json
#	web/src/i18n/locales/vi.json
#	web/src/i18n/locales/zh-TW.json
#	web/src/i18n/locales/zh.json
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