Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): PI 会话图标不再落成 Claude 像素脸
zqchris78c05f7c7100
diff --git a/apps/desktop/src/renderer/__tests__/sidebarAttentionBadge.test.ts b/apps/desktop/src/renderer/__tests__/sidebarAttentionBadge.test.tsindex 9f7900e43e..fbf8b10278 100644--- a/apps/desktop/src/renderer/__tests__/sidebarAttentionBadge.test.ts+++ b/apps/desktop/src/renderer/__tests__/sidebarAttentionBadge.test.ts@@ -36,6 +36,8 @@ vi.mock('@/hooks/useSessionPausedQueue', () => ({vi.mock('@/components/sidebar/VendorIcon', () => ({VendorIcon: () => createElement('span', { 'data-testid': 'vendor-icon' }),+ agentKindToVendor: (kind: string | null | undefined) =>+ kind === 'codex' ? 'codex' : kind === 'pi' ? 'pi' : 'cc',}));afterEach(() => {diff --git a/apps/desktop/src/renderer/__tests__/vendorIconMapping.test.ts b/apps/desktop/src/renderer/__tests__/vendorIconMapping.test.tsnew file mode 100644index 0000000000..45a2f4f14e--- /dev/null+++ b/apps/desktop/src/renderer/__tests__/vendorIconMapping.test.ts@@ -0,0 +1,23 @@+/**+ * agentKindToVendor 回归 —— 2026-07-30 实测 bug:Dialogues 会话行的 vendor 图标+ * 只写了 `=== 'codex' ? 'codex' : 'cc'`,PI 会话被吞成 Claude 像素脸。+ * 该映射现收敛到 VendorIcon.agentKindToVendor,这里锁死三种 agentKind 的取值+ * 与 null/别名回落,防止再回退成二元三元。+ */+import { describe, expect, it } from 'vitest';++import { agentKindToVendor } from '@/components/sidebar/VendorIcon';++describe('agentKindToVendor', () => {+ it('maps pi sessions to the pi vendor mark (2026-07-30 regression)', () => {+ expect(agentKindToVendor('pi')).toBe('pi');+ });++ it('maps codex to codex and cc/claude-code/null to cc', () => {+ expect(agentKindToVendor('codex')).toBe('codex');+ expect(agentKindToVendor('cc')).toBe('cc');+ expect(agentKindToVendor('claude-code')).toBe('cc');+ expect(agentKindToVendor(null)).toBe('cc');+ expect(agentKindToVendor(undefined)).toBe('cc');+ });+});diff --git a/apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx b/apps/desktop/src/renderer/components/sidebar/VendorIcon.tsxindex 1b8ff34ac9..2660bd7b47 100644--- a/apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx+++ b/apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx@@ -17,8 +17,19 @@ import { cn } from '@/lib/utils';import { ClaudeMark } from '@/components/icons/ClaudeMark';import { CodexMark } from '@/components/icons/CodexMark';+export type VendorIconKind = 'cc' | 'codex' | 'pi';++/**+ * agentKind → VendorIcon vendor 的唯一映射。所有渲染 agent 身份图标的调用点+ * 必须走这里,禁止各自写 `=== 'codex' ? 'codex' : 'cc'` 二元三元(那会把 pi+ * 吞成 Claude 脸,2026-07-30 实测 bug)。兼容 'claude-code' 别名与 null。+ */+export function agentKindToVendor(kind: string | null | undefined): VendorIconKind {+ return kind === 'codex' ? 'codex' : kind === 'pi' ? 'pi' : 'cc';+}+interface VendorIconProps {- vendor: 'cc' | 'codex' | 'pi';+ vendor: VendorIconKind;size?: number;/** true → 切 Thinking Orange + 呼吸动画,复用 .session-status-breathing */running?: boolean;diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsxindex 0bddb7f86b..0ce152190c 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx@@ -13,7 +13,7 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from '@/components/ui/dropdown-menu';-import { VendorIcon } from '@/components/sidebar/VendorIcon';+import { VendorIcon, agentKindToVendor } from '@/components/sidebar/VendorIcon';import type { Session } from '@/lib/ccAgent.types';import type { AutomationScheduleAction, AutomationSessionGroup } from '../lib/automationSidebarGrouping';import {@@ -337,8 +337,8 @@ export function AutomationSessionGroupItem({'cc'。isRunning 只看最新那条,与其子行一致。 */}<span className="flex w-[15px] shrink-0 items-center justify-center"><VendorIcon- vendor={latestSession?.agentKind === 'codex' ? 'codex' : 'cc'}- size={latestSession?.agentKind === 'codex' ? 12 : 13}+ vendor={agentKindToVendor(latestSession?.agentKind)}+ size={agentKindToVendor(latestSession?.agentKind) === 'cc' ? 13 : 12}running={isRunning}colorClassName={hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : undefined}/>diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsxindex 09b368456c..2f359c993f 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx@@ -26,7 +26,7 @@ import { useGhostSessionBusy } from '@/cindy-brain/ghostSessionActivityStore';import { useSessionAttentionKind } from '@/lib/sessionAttentionStore';import { useSessionAttentionUrgency } from '../contexts/SessionAttentionUrgencyContext';import { AttentionDot } from '@/components/sidebar/AttentionDot';-import { VendorIcon } from '@/components/sidebar/VendorIcon';+import { VendorIcon, agentKindToVendor } from '@/components/sidebar/VendorIcon';export interface SessionStatusIconProps {session: Session;@@ -71,7 +71,7 @@ export function SessionStatusIcon({// primitive 订阅(性能不变量同下方 attention hooks)。const isGhostBusy = useGhostSessionBusy(session.id);const isRunning = isAgentRunning || isGhostBusy;- const vendor = session.agentKind === 'codex' ? 'codex' : 'cc';+ const vendor = agentKindToVendor(session.agentKind);const isOrcaLead = isOrcaLeadSession(session);const isArchived = session.status === 'archived';// 角标 tone:error(含定时任务失败的 urgency context)红 > awaiting 蓝 > 完成未读绿。diff --git a/apps/desktop/src/renderer/features/scheduler/components/BoundSessionCard.tsx b/apps/desktop/src/renderer/features/scheduler/components/BoundSessionCard.tsxindex 4d45d6688a..b44f64531e 100644--- a/apps/desktop/src/renderer/features/scheduler/components/BoundSessionCard.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/BoundSessionCard.tsx@@ -15,7 +15,7 @@ import { ExternalLink, Unlink } from 'lucide-react';import { useTranslation } from 'react-i18next';import { cn } from '@/lib/utils';-import { VendorIcon } from '@/components/sidebar/VendorIcon';+import { VendorIcon, agentKindToVendor } from '@/components/sidebar/VendorIcon';import type { SessionReference } from '../../../../shared/sessionReference';export interface BoundSessionCardProps {@@ -42,7 +42,7 @@ export function BoundSessionCard({ sessionId, onUnbind, onOpen, reference }: Bou'border border-[var(--cmd-palette-border)] bg-[var(--chat-input-chip-bg)]',)}>- <VendorIcon vendor={reference?.agentKind === 'codex' ? 'codex' : 'cc'} size={13} />+ <VendorIcon vendor={agentKindToVendor(reference?.agentKind)} size={13} /><span className="min-w-0 flex-1 truncate text-13 font-medium text-[var(--msg-assistant-text)]" title={title}>{title}</span>