From 22159430c61e9988ef490e404c3e24e518f2cc2a Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 4 Jul 2026 23:23:25 +0800 Subject: [PATCH] fix(profiles): use camelCase keys for current profile ids in frontend --- src/components/profiles/ProfileSwitcher.tsx | 9 ++++++++- src/lib/api/profiles.ts | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/profiles/ProfileSwitcher.tsx b/src/components/profiles/ProfileSwitcher.tsx index fb615545b..367070d2a 100644 --- a/src/components/profiles/ProfileSwitcher.tsx +++ b/src/components/profiles/ProfileSwitcher.tsx @@ -41,6 +41,13 @@ import { } from "@/lib/query/profiles"; import { ProfileManageDialog } from "./ProfileManageDialog"; import { APP_PROFILE_SCOPE, hasScopeSnapshot } from "./scope"; +import type { CurrentProfileIds, ProfileScope } from "@/lib/api/profiles"; + +const CURRENT_ID_KEY: Record = { + claude: "claude", + "claude-desktop": "claudeDesktop", + codex: "codex", +}; interface ProfileSwitcherProps { activeApp: AppId; @@ -74,7 +81,7 @@ export function ProfileSwitcher({ activeApp }: ProfileSwitcherProps) { } const profiles = data?.profiles ?? []; - const currentId = data?.currentIds?.[scope] ?? null; + const currentId = data?.currentIds?.[CURRENT_ID_KEY[scope]] ?? null; const currentProfile = profiles.find((p) => p.id === currentId); const handleApply = (id: string) => { diff --git a/src/lib/api/profiles.ts b/src/lib/api/profiles.ts index 0bf03327f..07ea7f13f 100644 --- a/src/lib/api/profiles.ts +++ b/src/lib/api/profiles.ts @@ -38,8 +38,16 @@ export interface Profile { updatedAt?: number; } -/** 每个分组当前激活的项目 id(未使用项目时为 null) */ -export type CurrentProfileIds = Record; +/** 每个分组当前激活的项目 id(未使用项目时为 null) + * + * 注意:JSON key 是 camelCase(claudeDesktop),与 ProfileScope 的 kebab-case + * 字符串不同——后者用于命令参数,前者用于响应字段。 + */ +export interface CurrentProfileIds { + claude: string | null; + claudeDesktop: string | null; + codex: string | null; +} export interface ProfilesResponse { profiles: Profile[];