Skip to content

feat: 渠道缓存与费用统计及模型价格配置 - #40

Open
zuiho-kai wants to merge 2 commits into
Calcium-Ion:mainfrom
zuiho-kai:codex/channel-cache-cost
Open

zuiho-kai wants to merge 2 commits into
Calcium-Ion:mainfrom
zuiho-kai:codex/channel-cache-cost

Conversation

@zuiho-kai

@zuiho-kai zuiho-kai commented Sep 26, 2026 •

Copy link
Copy Markdown

Agent pull request

背景:针对不同渠道,他们命中率,ttft,tps都可能不相同,为了让不同渠道的信息可对比,所以新增了渠道级别的信息面板

解决:

  1. 理论上看 平均1m开销和缓存命中率、ttft和e2e就差不多能选择一个好渠道了
image image image

Agent

  • Tool: OpenAI Codex(AI-assisted)
  • Tool version: codex-cli 0.155.0-alpha.16.4
  • Model (full id): GPT-6;运行环境未提供完整部署 ID
  • Host: Codex desktop / Windows
  • Date (UTC): 2026-09-26

Links

Out of scope — refuse

  • Matched: no。不是新增订阅提供商或使用问题。
  • If yes: 不适用。

Open gate — do not open unless all are satisfied

  • Out of scope: no
  • Usage / configuration / integration: no
  • Required issue facts present: yes(功能请求 feat: 渠道缓存与费用明细及生效价格展示 #38)
  • Verification uses actual commands and observed results: yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • Open: yes
  • If no: 不适用。

Kind

  • New feature

Issue facts

  • Actual behavior: 已有费用账本/概览,但渠道操作中没有缓存命中和费用明细、当前生效单价及自定义价格表单。
  • Impact: 无法在同一渠道内核对缓存效果、计价依据。
  • Frequency: 不适用,功能请求。
  • Types: desktop/cost;按已有上游 usage 与价格快照计算,不报告具体账单错误。

Change

为渠道操作增加“缓存与费用”图标,按时间和模型展示缓存、费用及性能样本;显示目录价格/渠道覆盖及来源。价格覆盖复用现有定价计算器和账本快照。缺少价格仍标记未计价。

此 PR 含 AI 辅助代码,仅包含费用特性;智力检测独立处理。

Research

Duplicate / prior art

Docs and code

Alternatives considered

  • 从请求主记录直接求和:重试可能重复计数。
  • 从账本终态尝试汇总并关联日志:本 PR 采用此法,缺少样本保持未知。

Files

Path Why
apps/desktop/src/ServiceStatisticsDialog.tsx、pricing-model.ts 统计、有效价格与覆盖表单
ServiceManager.tsx、components/ServiceListRow.tsx 渠道入口与操作栏宽度
apps/desktop/src-tauri/src/、contracts/control-api.openapi.yaml 统计命令与契约
core/internal/controlapi/、storage/、pricing/ 汇总、价格覆盖与快照

Behavior

  • Before: 渠道页没有缓存/费用明细入口。
  • After: 可查看按模型统计、目录分档价格、渠道覆盖和待计价数量。
  • Non-goals: 智力检测、远端余额扣费;不改变已有历史调用价格快照。

Verification

  • bun run build:TypeScript 与生产构建成功。
  • bun run test src/ServiceStatisticsDialog.test.tsx src/pricing-model.test.ts src/ServiceManager.test.tsx:74 项通过;包括目录分档展示、自定义价格优先、未知价格及缓存继承语义。
  • go test ./internal/pricing ./internal/storage/sqlite ./internal/controlapi:三个包通过;统计覆盖重试去重、实际渠道归属和缺失缓存样本,价格测试覆盖历史快照保持。
  • core go vet ./...、contracts go test ./...:通过。
  • Rust cargo clippy --locked --all-targets -- -D warnings、cargo fmt --all -- --check:通过。
  • Oxlint/Prettier、gofmt 和 git diff --check:通过。
  • Manual: 组合版本中核对 Astra 显示两档目录单价,DS 无价格显示“未配置价格”;不是此独立分支的新一轮真实调用。
  • UI screenshot: 未附;用户以 Escape 停止桌面自动化,独立分支原生布局未复测。
  • Platforms: Windows x64、SQLite、模拟上游。
  • Not verified: macOS/Linux 原生 UI;全部提供商。

Risks

  • 费用取本地有效价格与 usage,不等同于提供商实际扣款;未计价不计入金额合计。
  • 不完整的日志可能减少延迟/缓存样本;界面保留有效样本数量。
  • Follow-ups: 与 功能请求:支持对未计价模型配置价格 #34 的更广泛模型价格需求对齐。

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope: no

@zuiho-kai

Copy link
Copy Markdown
Author

@seefs001 @Calcium-Ion

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