mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 08:29:07 +08:00
feat(agent): add avatar support for agent items
Implement getAgentAvatar function to provide avatar images based on agent type. Update AgentItem component to display agent-specific avatars instead of generic ones.
This commit is contained in:
parent
842a6cb178
commit
dbf01652f8
@ -1,4 +1,5 @@
|
||||
import { AgentBase } from '@renderer/types'
|
||||
import ClaudeAvatar from '@renderer/assets/images/models/claude.png'
|
||||
import { AgentBase, AgentEntity } from '@renderer/types'
|
||||
|
||||
// base agent config. no default config for now.
|
||||
const DEFAULT_AGENT_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
@ -9,3 +10,12 @@ const DEFAULT_AGENT_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
export const DEFAULT_CLAUDE_CODE_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
...DEFAULT_AGENT_CONFIG
|
||||
} as const
|
||||
|
||||
export const getAgentAvatar = (type: AgentEntity['type']): string => {
|
||||
switch (type) {
|
||||
case 'claude-code':
|
||||
return ClaudeAvatar
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import { Avatar, cn, useDisclosure } from '@heroui/react'
|
||||
import { loggerService } from '@logger'
|
||||
import { DeleteIcon, EditIcon } from '@renderer/components/Icons'
|
||||
import { AgentModal } from '@renderer/components/Popups/AgentModal'
|
||||
import { getAgentAvatar } from '@renderer/config/agent'
|
||||
import { AgentEntity } from '@renderer/types'
|
||||
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from '@renderer/ui/context-menu'
|
||||
import { FC, memo, useCallback } from 'react'
|
||||
@ -23,13 +24,14 @@ const AgentItem: FC<AgentItemProps> = ({ agent, isActive, onDelete }) => {
|
||||
|
||||
const AgentLabel = useCallback(() => {
|
||||
const displayName = agent.name ?? agent.id
|
||||
const avatar = getAgentAvatar(agent.type)
|
||||
return (
|
||||
<>
|
||||
<Avatar className="h-6 w-6" name={displayName} />
|
||||
<Avatar className="h-6 w-6" src={avatar} name={displayName} />
|
||||
<span className="text-sm">{displayName}</span>
|
||||
</>
|
||||
)
|
||||
}, [agent.id, agent.name])
|
||||
}, [agent.id, agent.name, agent.type])
|
||||
|
||||
const handleClick = () => logger.debug('not implemented')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user