feat(usage): filter-driven Hero with cache-normalized totals

- Normalize OpenAI/Gemini input_tokens semantics in SQL via the new
  fresh_input_sql helper (cache_read subtracted at query time, no data
  migration). Recovers correct cache hit rates for Codex/Gemini.
- Add get_usage_summary_by_app endpoint for per-app split (single
  UNION ALL + GROUP BY, avoids N+1).
- Replace UsageSummaryCards + AppBreakdownRail with a single
  filter-driven UsageHero card; clicking a filter button now truly
  changes the displayed numbers and the title accent color.
- Tighten KNOWN_APP_TYPES to the 3 app_types whose token data is
  reliably collected (claude/codex/gemini); hide claude-desktop,
  hermes, opencode, openclaw filter buttons and i18n keys.
- Flag cache_creation as N/A for OpenAI-style protocols (Codex,
  Gemini); show a "partial" tooltip when the All view mixes both
  protocol families.
This commit is contained in:
Jason
2026-05-13 10:27:29 +08:00
parent c12364a940
commit edf28b6422
17 changed files with 931 additions and 219 deletions
+9 -1
View File
@@ -1135,8 +1135,13 @@
"rangeToday": "Last 24 hours (hourly)",
"rangeLast7Days": "Last 7 days",
"rangeLast30Days": "Last 30 days",
"totalTokens": "Total Tokens",
"totalTokens": "New Tokens (Input+Output)",
"cacheTokens": "Cache Tokens",
"realTotal": "Tokens Processed",
"realTotalHint": "Input + Output + Cache Write + Cache Read",
"tokensSuffix": "tokens",
"freshInput": "Fresh Input",
"cacheHitRate": "Cache Hit Rate",
"requestLogs": "Request Logs",
"providerStats": "Provider Stats",
"modelStats": "Model Stats",
@@ -1165,6 +1170,7 @@
"codex": "Codex",
"gemini": "Gemini"
},
"rawInputLabel": "Raw",
"dataSources": "Data Sources",
"dataSource": {
"proxy": "Routing",
@@ -1225,6 +1231,8 @@
"input": "Input",
"output": "Output",
"cacheWrite": "Creation",
"cacheWriteNotReported": "OpenAI protocol doesn't distinguish cache creation; only cache hits are reported",
"cacheWritePartial": "Some protocols (e.g. OpenAI) don't report cache creation; the value may be incomplete",
"cacheRead": "Hit",
"baseCost": "Base",
"costMultiplier": "Cost Multiplier",
+9 -1
View File
@@ -1135,8 +1135,13 @@
"rangeToday": "直近24時間 (時間別)",
"rangeLast7Days": "過去7日間",
"rangeLast30Days": "過去30日間",
"totalTokens": "トークン",
"totalTokens": "新規トークン (Input+Output)",
"cacheTokens": "キャッシュトークン",
"realTotal": "実消費トークン",
"realTotalHint": "Input + Output + キャッシュ書込 + キャッシュ命中",
"tokensSuffix": "tokens",
"freshInput": "新規入力",
"cacheHitRate": "キャッシュヒット率",
"requestLogs": "リクエストログ",
"providerStats": "プロバイダー統計",
"modelStats": "モデル統計",
@@ -1165,6 +1170,7 @@
"codex": "Codex",
"gemini": "Gemini"
},
"rawInputLabel": "原始",
"dataSources": "データソース",
"dataSource": {
"proxy": "ルーティング",
@@ -1225,6 +1231,8 @@
"input": "Input",
"output": "Output",
"cacheWrite": "作成",
"cacheWriteNotReported": "OpenAI プロトコルはキャッシュ作成を区別せず、キャッシュヒットのみ報告します",
"cacheWritePartial": "一部のプロトコル(OpenAIなど)はキャッシュ作成を報告しないため、値は不完全な可能性があります",
"cacheRead": "ヒット",
"baseCost": "基本",
"costMultiplier": "コスト倍率",
+9 -1
View File
@@ -1135,8 +1135,13 @@
"rangeToday": "过去 24 小时 (按小时)",
"rangeLast7Days": "过去 7 天",
"rangeLast30Days": "过去 30 天",
"totalTokens": " Token ",
"totalTokens": "新生成 Token (Input+Output)",
"cacheTokens": "缓存 Token",
"realTotal": "真实消耗 Tokens",
"realTotalHint": "Input + Output + 缓存写入 + 缓存命中",
"tokensSuffix": "tokens",
"freshInput": "新增输入",
"cacheHitRate": "缓存命中率",
"requestLogs": "请求日志",
"providerStats": "Provider 统计",
"modelStats": "模型统计",
@@ -1165,6 +1170,7 @@
"codex": "Codex",
"gemini": "Gemini"
},
"rawInputLabel": "原始",
"dataSources": "数据来源",
"dataSource": {
"proxy": "路由",
@@ -1225,6 +1231,8 @@
"input": "Input",
"output": "Output",
"cacheWrite": "创建",
"cacheWriteNotReported": "OpenAI 协议不区分缓存写入,仅上报缓存命中",
"cacheWritePartial": "部分协议(如 OpenAI)不上报缓存写入,数值可能偏低",
"cacheRead": "命中",
"baseCost": "基础",
"costMultiplier": "成本倍率",