Files
codeg/src/components/agent-icon.tsx
xintaofei 8d97ba6f44 feat(ui): upgrade @lobehub/icons to v5 and update agent icon colors
Upgrade @lobehub/icons from v4 to v5.3.0, adopt new icon components (ClaudeCode, Codex, GeminiCLI) with Color variants, and align fallback AGENT_COLORS with official brand colors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 21:42:22 +08:00

72 lines
1.4 KiB
TypeScript

import type { AgentType } from "@/lib/types"
import { AGENT_COLORS } from "@/lib/types"
import { cn } from "@/lib/utils"
import {
ClaudeCode,
Cline,
Codex,
GeminiCLI,
OpenClaw,
OpenCode,
} from "@lobehub/icons"
interface AgentIconProps {
agentType: AgentType
className?: string
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyIcon = React.ComponentType<any>
const COLOR_ICONS: Partial<Record<AgentType, AnyIcon>> = {
claude_code: ClaudeCode.Color,
codex: Codex.Color,
gemini: GeminiCLI.Color,
open_claw: OpenClaw.Color,
}
const MONO_ICONS: Partial<Record<AgentType, AnyIcon>> = {
open_code: OpenCode,
cline: Cline,
}
// Text-color versions for Mono icons
const AGENT_TEXT_COLORS: Partial<Record<AgentType, string>> = {}
export function AgentIcon({ agentType, className }: AgentIconProps) {
const ColorIcon = COLOR_ICONS[agentType]
if (ColorIcon) {
return (
<span className={cn("inline-flex shrink-0", className)}>
<ColorIcon size="100%" />
</span>
)
}
const MonoIcon = MONO_ICONS[agentType]
if (MonoIcon) {
return (
<span
className={cn(
"inline-flex shrink-0",
AGENT_TEXT_COLORS[agentType],
className
)}
>
<MonoIcon size="100%" />
</span>
)
}
return (
<span
className={cn(
"rounded-full shrink-0",
AGENT_COLORS[agentType],
className
)}
/>
)
}