mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
refactor(usage): fold claude-desktop into claude in the dashboard
The Desktop gateway's proxy traffic is still recorded under its own app_type for route-takeover billing audit (the request detail panel shows the real value), but the dashboard now folds it into `claude` for display. A standalone "Claude Desktop" bucket only ever showed a partial number: Desktop chat usage never passes through the proxy and has no scannable local source, while its Code-tab sessions are just the embedded Claude Code runtime writing into the shared ~/.claude/projects tree — so a separate bucket misled users into reading it as Desktop's full usage. Backend: new `folded_app_type_sql` helper wraps the app_type column in every dashboard read path (10 filter sites + the by-app projection) so `= 'claude'` also matches claude-desktop and GROUP BY merges the two, without changing bound-param counts. Dedup matching and provider-limit checks keep exact comparison; get_request_logs folds only the WHERE filter and keeps the raw app_type in its row projection. Frontend: drop claude-desktop from the dashboard AppType/KNOWN_APP_TYPES filter list, the UsageHero theme, and the now-dead appFilter locale key in all four languages (the managed-app apps.claude-desktop label stays). Adds test_claude_desktop_folds_into_claude_for_display.
This commit is contained in:
@@ -49,11 +49,6 @@ const TITLE_THEMES: Record<AppType | "all", TitleTheme> = {
|
||||
accent: "text-amber-600 dark:text-amber-400",
|
||||
iconBg: "bg-amber-500/10",
|
||||
},
|
||||
"claude-desktop": {
|
||||
// 与 Claude Code 同属 Anthropic 品牌,用更深的 orange 区分
|
||||
accent: "text-orange-600 dark:text-orange-400",
|
||||
iconBg: "bg-orange-500/10",
|
||||
},
|
||||
codex: {
|
||||
// OpenAI/Codex 走黑白单色调;中性灰在深浅模式都能透出方块底色,
|
||||
// 不像纯黑 bg-black/10 在深色背景下会糊掉。
|
||||
|
||||
@@ -1386,7 +1386,6 @@
|
||||
"appFilter": {
|
||||
"all": "All",
|
||||
"claude": "Claude Code",
|
||||
"claude-desktop": "Claude Desktop",
|
||||
"codex": "Codex",
|
||||
"gemini": "Gemini",
|
||||
"opencode": "OpenCode"
|
||||
|
||||
@@ -1386,7 +1386,6 @@
|
||||
"appFilter": {
|
||||
"all": "すべて",
|
||||
"claude": "Claude Code",
|
||||
"claude-desktop": "Claude Desktop",
|
||||
"codex": "Codex",
|
||||
"gemini": "Gemini",
|
||||
"opencode": "OpenCode"
|
||||
|
||||
@@ -1358,7 +1358,6 @@
|
||||
"appFilter": {
|
||||
"all": "全部",
|
||||
"claude": "Claude Code",
|
||||
"claude-desktop": "Claude Desktop",
|
||||
"codex": "Codex",
|
||||
"gemini": "Gemini",
|
||||
"opencode": "OpenCode"
|
||||
|
||||
@@ -1386,7 +1386,6 @@
|
||||
"appFilter": {
|
||||
"all": "全部",
|
||||
"claude": "Claude Code",
|
||||
"claude-desktop": "Claude Desktop",
|
||||
"codex": "Codex",
|
||||
"gemini": "Gemini",
|
||||
"opencode": "OpenCode"
|
||||
|
||||
+11
-13
@@ -141,28 +141,26 @@ export interface UsageRangeSelection {
|
||||
}
|
||||
|
||||
/**
|
||||
* App types whose token usage is reliably collected by the proxy.
|
||||
* App types surfaced as dashboard filter buttons.
|
||||
*
|
||||
* `claude-desktop` was previously hidden because its rows looked like pure
|
||||
* failure noise — that was an accounting bug: streaming/transform usage of
|
||||
* the Desktop gateway was logged under app_type "claude", leaving only
|
||||
* edge-case rows under "claude-desktop". The backend now attributes all
|
||||
* Desktop traffic to "claude-desktop", so it is a first-class filter option.
|
||||
* `claude-desktop` is intentionally NOT listed: the Desktop gateway's proxy
|
||||
* traffic is still recorded under its own `app_type` (preserving route-takeover
|
||||
* billing audit — the request detail panel shows the real value), but the
|
||||
* dashboard folds it into `claude` for display. It is the embedded Claude Code
|
||||
* runtime running inside the Desktop shell, and Desktop *chat* usage never
|
||||
* passes through this app at all, so a separate "Claude Desktop" bucket would
|
||||
* only ever show a partial number and mislead users into reading it as the
|
||||
* Desktop's full usage. The backend collapses `claude-desktop → claude` in
|
||||
* every dashboard query (see `folded_app_type_sql`).
|
||||
* `opencode` / `openclaw` / `hermes` have no proxy handler at all — they
|
||||
* appear only as managed apps elsewhere.
|
||||
*/
|
||||
export type AppType =
|
||||
| "claude"
|
||||
| "claude-desktop"
|
||||
| "codex"
|
||||
| "gemini"
|
||||
| "opencode";
|
||||
export type AppType = "claude" | "codex" | "gemini" | "opencode";
|
||||
|
||||
export type AppTypeFilter = "all" | AppType;
|
||||
|
||||
export const KNOWN_APP_TYPES: ReadonlyArray<AppType> = [
|
||||
"claude",
|
||||
"claude-desktop",
|
||||
"codex",
|
||||
"gemini",
|
||||
"opencode",
|
||||
|
||||
Reference in New Issue
Block a user