Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(scheduler): 自动化详情按 agentKind 正确显示 Pi(#4418) (#4422)

FicoWangeeb1f46e54c9
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/formatters.test.ts b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/formatters.test.ts
index 7d5cfd9c06..5ef67b972b 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/formatters.test.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/formatters.test.ts
@@ -1,7 +1,7 @@
import type { TFunction } from 'i18next';
import { describe, expect, it } from 'vitest';
-import { formatNextRun } from '../formatters';
+import { formatNextRun, humanizeAgentKind } from '../formatters';
const zhTranslate = ((key: string, options?: Record<string, unknown>) => {
const count = Number(options?.count ?? 0);
@@ -20,4 +20,12 @@ describe('scheduler formatters', () => {
expect(formatNextRun(now + 3 * 60 * 60_000, now, zhTranslate)).toContain('(3小时后)');
expect(formatNextRun(now + 2 * 24 * 60 * 60_000, now, zhTranslate)).toContain('(2天后)');
});
+
+ // issue 4418: 详情摘要的 Agent 名称必须与保存的 agentKind 一致;此前只区分 codex,
+ // pi 被错误回落成 Claude。
+ it('humanizes every AgentKind by its own brand instead of falling back to Claude', () => {
+ expect(humanizeAgentKind('claude-code')).toBe('Claude');
+ expect(humanizeAgentKind('codex')).toBe('Codex');
+ expect(humanizeAgentKind('pi')).toBe('Pi');
+ });
});
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/formatters.ts b/apps/desktop/src/renderer/features/scheduler/lib/formatters.ts
index eed41ee342..6a0bba8736 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/formatters.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/formatters.ts
@@ -239,9 +239,24 @@ export function basenameOf(p?: string | null): string | null {
* 'claude-code' → 'Claude'(agent 标识对齐草稿界面 vendor 切换;provider 分离后
* cc agent 统一以 Claude 品牌呈现,路由到哪个供应商由来源选择器单独控制)。
* 'codex' → 'Codex'(保持 OpenAI 原品牌名)。
+ * 'pi' → 'Pi'。三种合法 AgentKind 各自显式映射——之前只区分 codex、其余一律回落
+ * Claude,导致 Pi 自动化的详情摘要显示成 Claude(issue 4418)。仅影响展示文案,不改
+ * 执行路由。
*/
export function humanizeAgentKind(k: AgentKind): string {
- return k === 'codex' ? 'Codex' : 'Claude';
+ switch (k) {
+ case 'claude-code':
+ return 'Claude';
+ case 'codex':
+ return 'Codex';
+ case 'pi':
+ return 'Pi';
+ default: {
+ // 穷尽性检查:AgentKind 新增引擎时这里编译报错,避免再次静默回落成 Claude。
+ const unreachable: never = k;
+ return unreachable;
+ }
+ }
}
/**