π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
β¨ feat(agent): draw an Agent's picked character (agent-avatar:<shape>:<color>) (#23624)
Lobehub Coderc30ba13c3ff2
diff --git a/package.json b/package.jsonindex e259a99e47a..6c86cb15ed0 100644--- a/package.json+++ b/package.json@@ -348,7 +348,7 @@"@lobehub/icons": "^6.15.2","@lobehub/market-sdk": "0.46.0","@lobehub/tts": "^6.1.0",- "@lobehub/ui": "^6.16.1",+ "@lobehub/ui": "^6.18.0","@modelcontextprotocol/client": "~2.4.0","@modelcontextprotocol/ext-apps": "^2.0.3","@neondatabase/serverless": "^1.1.0",diff --git a/packages/builtin-tool-agent-management/src/client/Inspector/GetAgentDetail/index.tsx b/packages/builtin-tool-agent-management/src/client/Inspector/GetAgentDetail/index.tsxindex 9ec5609964c..73e51674806 100644--- a/packages/builtin-tool-agent-management/src/client/Inspector/GetAgentDetail/index.tsx+++ b/packages/builtin-tool-agent-management/src/client/Inspector/GetAgentDetail/index.tsx@@ -1,12 +1,11 @@'use client';import type { BuiltinInspectorProps } from '@lobechat/types';-import { Flexbox, Tooltip } from '@lobehub/ui';-import { Avatar } from '@lobehub/ui';-import { createStaticStyles, cx } from '@lobehub/ui';+import { createStaticStyles, cx, Flexbox, Tooltip } from '@lobehub/ui';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { highlightTextStyles, shinyTextStyles } from '@/styles';import type { GetAgentDetailParams, GetAgentDetailState } from '../../../types';diff --git a/packages/builtin-tool-group-agent-builder/src/client/Inspector/GetAgentInfo/index.tsx b/packages/builtin-tool-group-agent-builder/src/client/Inspector/GetAgentInfo/index.tsxindex 851c5e16462..7c37fc0e92d 100644--- a/packages/builtin-tool-group-agent-builder/src/client/Inspector/GetAgentInfo/index.tsx+++ b/packages/builtin-tool-group-agent-builder/src/client/Inspector/GetAgentInfo/index.tsx@@ -1,12 +1,11 @@'use client';import type { BuiltinInspectorProps } from '@lobechat/types';-import { Flexbox } from '@lobehub/ui';-import { Avatar } from '@lobehub/ui';-import { createStaticStyles, cx } from '@lobehub/ui';+import { createStaticStyles, cx, Flexbox } from '@lobehub/ui';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { shinyGroupStyles, shinyTextStyles } from '@/styles';import type { GetAgentInfoParams } from '../../../types';diff --git a/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx b/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsxindex 930f8217aea..498ce365bbc 100644--- a/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx+++ b/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx@@ -1,13 +1,12 @@'use client';import type { BuiltinInspectorProps } from '@lobechat/types';-import { Flexbox } from '@lobehub/ui';-import { Avatar } from '@lobehub/ui';-import { createStaticStyles, cssVar, cx } from '@lobehub/ui';+import { createStaticStyles, cssVar, cx, Flexbox } from '@lobehub/ui';import { Check } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { shinyTextStyles } from '@/styles';import type { InviteAgentParams, InviteAgentState } from '../../../types';diff --git a/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx b/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsxindex d47e58880fa..8ea048d2598 100644--- a/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx+++ b/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx@@ -1,13 +1,12 @@'use client';import type { BuiltinInspectorProps } from '@lobechat/types';-import { Flexbox } from '@lobehub/ui';-import { Avatar } from '@lobehub/ui';-import { createStaticStyles, cssVar, cx } from '@lobehub/ui';+import { createStaticStyles, cssVar, cx, Flexbox } from '@lobehub/ui';import { Check } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { shinyTextStyles } from '@/styles';import type { RemoveAgentParams, RemoveAgentState } from '../../../types';diff --git a/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx b/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsxindex 3bafe9cda3c..39a96425df1 100644--- a/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx+++ b/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx@@ -1,12 +1,11 @@'use client';import type { BuiltinInspectorProps } from '@lobechat/types';-import { Flexbox } from '@lobehub/ui';-import { Avatar, Text } from '@lobehub/ui';-import { createStaticStyles, cssVar, cx } from '@lobehub/ui';+import { createStaticStyles, cssVar, cx, Flexbox, Text } from '@lobehub/ui';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { useAgentGroupStore } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';import { inspectorTextStyles, shinyTextStyles } from '@/styles';diff --git a/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx b/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsxindex de1df5b542d..1dacf0b2140 100644--- a/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx+++ b/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx@@ -5,7 +5,7 @@ import { Avatar, createStaticStyles, cx, Flexbox, useTheme } from '@lobehub/ui';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';-import AgentAvatar, { isDefaultAgentAvatar } from '@/components/AgentAvatar';+import AgentAvatar, { isGeneratedAgentAvatar } from '@/components/AgentAvatar';import { useAgentGroupStore } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';import { shinyTextStyles } from '@/styles';@@ -51,8 +51,9 @@ export const BroadcastInspector = memo<BuiltinInspectorProps<BroadcastParams>>(const avatarItems = useMemo(() =>agents.map((agent) => ({- avatar: isDefaultAgentAvatar(agent.avatar) ? (- <AgentAvatar agentId={agent.id} name={agent.title} size={24} />+ // A picked character is drawn like the generated one, never handed over as text.+ avatar: isGeneratedAgentAvatar(agent.avatar) ? (+ <AgentAvatar agentId={agent.id} avatar={agent.avatar} name={agent.title} size={24} />) : (agent.avatar),diff --git a/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx b/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsxindex 5b40d70397b..80b0f787de4 100644--- a/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx+++ b/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx@@ -6,7 +6,7 @@ import { Avatar, createStaticStyles, cx, Flexbox, useTheme } from '@lobehub/ui';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';-import AgentAvatar, { isDefaultAgentAvatar } from '@/components/AgentAvatar';+import AgentAvatar, { isGeneratedAgentAvatar } from '@/components/AgentAvatar';import { useAgentGroupStore } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';import { shinyTextStyles } from '@/styles';@@ -64,8 +64,9 @@ export const ExecuteAgentTasksInspector = memo<BuiltinInspectorProps<ExecuteTaskconst avatarItems = useMemo(() =>agents.map((agent) => ({- avatar: isDefaultAgentAvatar(agent.avatar) ? (- <AgentAvatar agentId={agent.id} name={agent.title} size={24} />+ // A picked character is drawn like the generated one, never handed over as text.+ avatar: isGeneratedAgentAvatar(agent.avatar) ? (+ <AgentAvatar agentId={agent.id} avatar={agent.avatar} name={agent.title} size={24} />) : (agent.avatar),diff --git a/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTask.tsx b/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTask.tsxindex 607ebcf0144..a957d151117 100644--- a/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTask.tsx+++ b/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTask.tsx@@ -1,7 +1,7 @@'use client';import type { BuiltinInterventionProps } from '@lobechat/types';-import { Avatar, Flexbox, InputNumber, TextArea, Tooltip } from '@lobehub/ui';+import { Flexbox, InputNumber, TextArea, Tooltip } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import isEqual from 'fast-deep-equal';@@ -10,6 +10,7 @@ import type { ChangeEvent } from 'react';import { memo, useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { useAgentGroupStore } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';diff --git a/src/components/AgentAvatar/index.tsx b/src/components/AgentAvatar/index.tsxindex 19b105a6a4b..470b8941910 100644--- a/src/components/AgentAvatar/index.tsx+++ b/src/components/AgentAvatar/index.tsx@@ -7,7 +7,7 @@ import Avatar, { type AvatarProps } from '@/components/Avatar';import { pickDomProps, resolveAgentAvatar } from './resolve';-export { isDefaultAgentAvatar } from './resolve';+export { isDefaultAgentAvatar, isGeneratedAgentAvatar } from './resolve';export interface AgentAvatarProps extends Omit<AvatarProps, 'avatar' | 'brokenFallback' | 'name'> {/**@@ -17,7 +17,10 @@ export interface AgentAvatarProps extends Omit<AvatarProps, 'avatar' | 'brokenFaagentId?: string | null;/** Play the `state` animation of the generated character. */animated?: boolean;- /** Emoji or image URL. Empty (or the legacy default image) draws the generated character. */+ /**+ * Emoji, image URL or a picked character (`agent-avatar:<shape>:<color>`). Empty (or the+ * legacy default image) draws the character generated from the id.+ */avatar?: string | null;/** Display name: labels the avatar and seeds the character when `agentId` is absent. */name?: string | null;@@ -60,6 +63,7 @@ const AgentAvatar = memo<AgentAvatarProps>(onClick={onClick as MouseEventHandler<HTMLSpanElement>}><GeneratedAgentAvatar+ {...(resolved.kind === 'generated' ? resolved.choice : undefined)}animated={animated}name={resolved.label}seed={resolved.seed}diff --git a/src/components/AgentAvatar/resolve.test.ts b/src/components/AgentAvatar/resolve.test.tsindex a7025e0d3ad..e59e4e18b3e 100644--- a/src/components/AgentAvatar/resolve.test.ts+++ b/src/components/AgentAvatar/resolve.test.ts@@ -1,7 +1,12 @@import { DEFAULT_AVATAR } from '@lobechat/const';import { describe, expect, it } from 'vitest';-import { isDefaultAgentAvatar, pickDomProps, resolveAgentAvatar } from './resolve';+import {+ isDefaultAgentAvatar,+ isGeneratedAgentAvatar,+ pickDomProps,+ resolveAgentAvatar,+} from './resolve';describe('isDefaultAgentAvatar', () => {it('treats empty values and the legacy default image as no avatar', () => {@@ -17,7 +22,34 @@ describe('isDefaultAgentAvatar', () => {});});+describe('isGeneratedAgentAvatar', () => {+ it('counts a picked character as the generated one, not as an emoji or image', () => {+ expect(isGeneratedAgentAvatar('agent-avatar:rocket:cyan')).toBe(true);+ expect(isGeneratedAgentAvatar(undefined)).toBe(true);+ expect(isGeneratedAgentAvatar(DEFAULT_AVATAR)).toBe(true);+ });++ it('keeps an emoji, an image and a malformed value as they are', () => {+ expect(isGeneratedAgentAvatar('π€')).toBe(false);+ expect(isGeneratedAgentAvatar('https://example.com/a.png')).toBe(false);+ expect(isGeneratedAgentAvatar('agent-avatar:nope:cyan')).toBe(false);+ });+});+describe('resolveAgentAvatar', () => {+ // A picked character used to fall through as a "custom" avatar, and the plain Avatar+ // printed its raw `agent-avatar:β¦` text.+ it('draws a picked character with its shape and color, still seeded by the id', () => {+ expect(+ resolveAgentAvatar({ agentId: 'agt_1', avatar: 'agent-avatar:rocket:cyan', name: 'Bot' }),+ ).toEqual({+ choice: { color: 'cyan', shape: 'rocket' },+ kind: 'generated',+ label: 'Bot',+ seed: 'agt_1',+ });+ });+it('draws the generated character instead of the legacy default image', () => {expect(resolveAgentAvatar({ agentId: 'agt_1', avatar: DEFAULT_AVATAR, name: 'Researcher' }),diff --git a/src/components/AgentAvatar/resolve.ts b/src/components/AgentAvatar/resolve.tsindex fe9d06d0fc1..f4b04f94038 100644--- a/src/components/AgentAvatar/resolve.ts+++ b/src/components/AgentAvatar/resolve.ts@@ -1,4 +1,5 @@import { DEFAULT_AVATAR } from '@lobechat/const';+import { type AgentAvatarValue, parseAgentAvatar } from '@lobehub/ui';/*** Whether an agent has no avatar of its own. Selectors still fill the legacy@@ -7,6 +8,14 @@ import { DEFAULT_AVATAR } from '@lobechat/const';export const isDefaultAgentAvatar = (avatar?: string | null): boolean =>!avatar || avatar === DEFAULT_AVATAR;+/**+ * Whether an agent wears the generated character: none of its own, or one its+ * owner picked (an `agent-avatar:<shape>:<color>` value, which is no emoji or+ * image and must never reach a plain Avatar as one).+ */+export const isGeneratedAgentAvatar = (avatar?: string | null): boolean =>+ isDefaultAgentAvatar(avatar) || !!parseAgentAvatar(avatar);+interface ResolveAgentAvatarParams {agentId?: string | null;avatar?: string | null;@@ -16,12 +25,18 @@ interface ResolveAgentAvatarParams {export type ResolvedAgentAvatar =| { avatar: string; kind: 'custom'; label?: string; seed?: string }- | { kind: 'generated'; label?: string; seed?: string };+ | {+ /** The shape and color its owner picked; absent = derived from the seed. */+ choice?: AgentAvatarValue;+ kind: 'generated';+ label?: string;+ seed?: string;+ };/*** Decide what an agent avatar draws. The generated character is seeded by the* agent id, so renaming an agent keeps its character; only an agent without an- * id falls back to its name.+ * id falls back to its name. A picked character keeps its shape and color.*/export const resolveAgentAvatar = ({agentId,@@ -32,9 +47,12 @@ export const resolveAgentAvatar = ({const label = name || title || undefined;const seed = agentId || label;- return isDefaultAgentAvatar(avatar)- ? { kind: 'generated', label, seed }- : { avatar: avatar!, kind: 'custom', label, seed };+ if (isDefaultAgentAvatar(avatar)) return { kind: 'generated', label, seed };++ const choice = parseAgentAvatar(avatar);+ if (choice) return { choice, kind: 'generated', label, seed };++ return { avatar: avatar!, kind: 'custom', label, seed };};const DOM_PROP = /^(?:on[A-Z]|aria-|data-)/;diff --git a/src/components/AgentAvatar/stackAvatar.test.ts b/src/components/AgentAvatar/stackAvatar.test.tsindex 9523d589cea..4ba58327f1c 100644--- a/src/components/AgentAvatar/stackAvatar.test.ts+++ b/src/components/AgentAvatar/stackAvatar.test.ts@@ -20,6 +20,14 @@ describe('toStackAvatar', () => {expect(item.background).toBeUndefined();});+ it('draws a picked character with its shape and color', () => {+ const item = toStackAvatar({ avatar: 'agent-avatar:cat:green', seed: 'agent-1' }, 0);+ const props = (item.avatar as ReactElement<{ color: string; seed: string; shape: string }>)+ .props;++ expect(props).toMatchObject({ color: 'green', seed: 'agent-1', shape: 'cat' });+ });+it('keeps members without a seed apart by their position', () => {const seedAt = (index: number) =>(toStackAvatar({}, index).avatar as ReactElement<{ seed: string }>).props.seed;diff --git a/src/components/AgentAvatar/stackAvatar.tsx b/src/components/AgentAvatar/stackAvatar.tsxindex bec87e54273..f5e524c5293 100644--- a/src/components/AgentAvatar/stackAvatar.tsx+++ b/src/components/AgentAvatar/stackAvatar.tsx@@ -1,6 +1,10 @@-import { AgentAvatar as GeneratedAgentAvatar, type GroupAvatarProps } from '@lobehub/ui';+import {+ AgentAvatar as GeneratedAgentAvatar,+ type GroupAvatarProps,+ parseAgentAvatar,+} from '@lobehub/ui';-import { isDefaultAgentAvatar } from './resolve';+import { isGeneratedAgentAvatar } from './resolve';type StackAvatar = Exclude<NonNullable<GroupAvatarProps['avatars']>[number], string>;@@ -8,18 +12,21 @@ const FILL_TILE = { height: '100%', width: '100%' };/*** A member of a `GroupAvatar` stack. Without an avatar of its own it draws the- * generated character; the stack sizes each tile, so the character fills it.+ * generated character (the one its owner picked, if any); the stack sizes each+ * tile, so the character fills it.*/export const toStackAvatar = <T extends StackAvatar & { seed?: string | null }>({ seed, ...member }: T,index: number,): StackAvatar => {const { avatar } = member;- if (typeof avatar !== 'string' ? !!avatar : !isDefaultAgentAvatar(avatar)) return member;+ if (typeof avatar !== 'string' ? !!avatar : !isGeneratedAgentAvatar(avatar)) return member;++ const choice = typeof avatar === 'string' ? parseAgentAvatar(avatar) : undefined;return {...member,- avatar: <GeneratedAgentAvatar seed={seed || `member-${index}`} style={FILL_TILE} />,+ avatar: <GeneratedAgentAvatar {...choice} seed={seed || `member-${index}`} style={FILL_TILE} />,background: undefined,};};diff --git a/src/components/Avatar/index.test.tsx b/src/components/Avatar/index.test.tsxnew file mode 100644index 00000000000..c8d70a64352--- /dev/null+++ b/src/components/Avatar/index.test.tsx@@ -0,0 +1,25 @@+/**+ * @vitest-environment happy-dom+ */+import { render } from '@testing-library/react';+import { describe, expect, it } from 'vitest';++import Avatar from './index';++describe('Avatar', () => {+ // A character picked for an Agent (`agent-avatar:<shape>:<color>`) is no emoji or image: the+ // library Avatar treated it as a broken one and drew its gradient fallback instead.+ it('draws a picked Agent character, not the fallback gradient', () => {+ const { container } = render(<Avatar avatar={'agent-avatar:rocket:cyan'} name={'Bot'} />);++ expect(container.textContent).not.toContain('agent-avatar');+ expect(container.querySelector('.lobe-avatar__fallback')).toBeNull();+ expect(container.querySelector('svg[aria-label="Bot"]')).not.toBeNull();+ });++ it('keeps an emoji as an emoji', () => {+ const { container } = render(<Avatar avatar={'π€'} name={'Bot'} />);++ expect(container.querySelector('svg[aria-label="Bot"]')).toBeNull();+ });+});diff --git a/src/components/Avatar/index.tsx b/src/components/Avatar/index.tsxindex 4123da5d8a7..c7e30b15c61 100644--- a/src/components/Avatar/index.tsx+++ b/src/components/Avatar/index.tsx@@ -1,8 +1,15 @@'use client';-import { Avatar as LobeAvatar, type AvatarProps as LobeAvatarProps } from '@lobehub/ui';+import {+ AgentAvatar as GeneratedAgentAvatar,+ Avatar as LobeAvatar,+ type AvatarProps as LobeAvatarProps,+ parseAgentAvatar,+} from '@lobehub/ui';import { memo, type ReactNode } from 'react';+import { pickDomProps } from '@/components/AgentAvatar/resolve';+import { remoteAvatarSrc, resolveAvatar } from './fallback';import { useBrokenSrc } from './useBrokenSrc';@@ -37,6 +44,20 @@ const Avatar = memo<AvatarProps>(const src = remoteAvatarSrc(avatar);const [isBroken, markBroken] = useBrokenSrc(src);+ // A character picked for an Agent (`agent-avatar:<shape>:<color>`) is no emoji or image:+ // the library's Avatar would print the raw value, so draw the character itself.+ const picked = typeof avatar === 'string' ? parseAgentAvatar(avatar) : undefined;+ if (picked)+ return (+ <span+ {...pickDomProps(rest)}+ className={rest.className}+ style={{ display: 'inline-flex', flex: 'none', ...rest.style }}+ >+ <GeneratedAgentAvatar {...picked} name={name || title} size={size} />+ </span>+ );+if (isBroken && brokenFallback) return brokenFallback;const imgAlt = alt || name || title || 'avatar';diff --git a/src/features/Acceptance/Viewer/Conversation/CollaboratorTopicPanel.tsx b/src/features/Acceptance/Viewer/Conversation/CollaboratorTopicPanel.tsxindex a3e2cd13e05..c5dadd1ba49 100644--- a/src/features/Acceptance/Viewer/Conversation/CollaboratorTopicPanel.tsx+++ b/src/features/Acceptance/Viewer/Conversation/CollaboratorTopicPanel.tsx@@ -1,13 +1,14 @@'use client';import type { UIChatMessage } from '@lobechat/types';-import { ActionIcon, Avatar, Button, Flexbox, Text, TextArea, toast } from '@lobehub/ui';+import { ActionIcon, Button, Flexbox, Text, TextArea, toast } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import { PanelRightClose } from 'lucide-react';import { useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import {type ConversationContext,ConversationProvider,diff --git a/src/features/Acceptance/Viewer/Conversation/TopicPanel.tsx b/src/features/Acceptance/Viewer/Conversation/TopicPanel.tsxindex 98ced95043e..8a92d420c37 100644--- a/src/features/Acceptance/Viewer/Conversation/TopicPanel.tsx+++ b/src/features/Acceptance/Viewer/Conversation/TopicPanel.tsx@@ -1,10 +1,11 @@'use client';-import { ActionIcon, Avatar, cssVar, Flexbox, Text } from '@lobehub/ui';+import { ActionIcon, cssVar, Flexbox, Text } from '@lobehub/ui';import { PanelRightClose } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { TopicChatDrawerBody } from '@/features/AgentTasks/AgentTaskDetail/TopicChatDrawer';import type { OriginTopicPanelProps } from './originConversation';diff --git a/src/features/Acceptance/Viewer/Header/AcceptanceIdentity.tsx b/src/features/Acceptance/Viewer/Header/AcceptanceIdentity.tsxindex 805e9d6f4db..112598e8ad9 100644--- a/src/features/Acceptance/Viewer/Header/AcceptanceIdentity.tsx+++ b/src/features/Acceptance/Viewer/Header/AcceptanceIdentity.tsx@@ -1,11 +1,13 @@'use client';-import { Avatar, Flexbox, Text } from '@lobehub/ui';+import { Flexbox, Text } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import type { ReactNode } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';+import { useAcceptanceScope } from '../AcceptanceScope';import { acceptanceCodingScope } from '../History/codingScope';import { titleRowMarker } from '../markers.stylex';diff --git a/src/features/AgentBuilder/AgentBuilderWelcome.tsx b/src/features/AgentBuilder/AgentBuilderWelcome.tsxindex 5f0a566f229..badad973d17 100644--- a/src/features/AgentBuilder/AgentBuilderWelcome.tsx+++ b/src/features/AgentBuilder/AgentBuilderWelcome.tsx@@ -1,9 +1,10 @@'use client';-import { Avatar, Flexbox, Markdown, Text } from '@lobehub/ui';+import { Flexbox, Markdown, Text } from '@lobehub/ui';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { DEFAULT_INBOX_AVATAR } from '@/const/index';import { conversationSelectors, useConversationStore } from '@/features/Conversation';import { type SuggestMode } from '@/features/SuggestQuestions';diff --git a/src/features/AgentProfileCard/index.tsx b/src/features/AgentProfileCard/index.tsxindex 4e4dfd11b51..8a7af33bb70 100644--- a/src/features/AgentProfileCard/index.tsx+++ b/src/features/AgentProfileCard/index.tsx@@ -3,7 +3,7 @@import { Center, createStaticStyles, cssVar, Flexbox, Skeleton, Text, Tooltip } from '@lobehub/ui';import { memo, type ReactNode } from 'react';-import AgentAvatar, { isDefaultAgentAvatar } from '@/components/AgentAvatar';+import AgentAvatar, { isGeneratedAgentAvatar } from '@/components/AgentAvatar';import { densityVars } from '@/styles/densityVars';const styles = createStaticStyles(({ css, cssVar }) => ({@@ -104,7 +104,7 @@ const AgentProfileCard = memo<AgentProfileCardProps>(size={48}// The generated character has no tile, so a frame would box empty space.style={- isDefaultAgentAvatar(avatar)+ isGeneratedAgentAvatar(avatar)? undefined: { border: `2px solid ${cssVar.colorBgElevated}` }}diff --git a/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx b/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsxindex 790795b95f4..a4fb0b8fdbe 100644--- a/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx@@ -3,7 +3,6 @@ import { useEditor } from '@lobehub/editor/react';import { LexicalRenderer } from '@lobehub/editor/renderer';import {ActionIcon,- Avatar,Block,Button,confirmModal,@@ -19,6 +18,7 @@ import { MessageCircle, MoreHorizontal, Pencil, Trash } from 'lucide-react';import { memo, useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { AttachmentUploadButton } from '@/features/AttachmentInput';import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';import { richTextImageRenderers } from '@/features/Conversation/Messages/User/components/richTextImageRenderers';diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsxindex a1b4bbc83f1..f14fb1679cc 100644--- a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx@@ -4,17 +4,7 @@ import type {TaskDetailActivity,TaskDetailActivityAuthor,} from '@lobechat/types';-import {- Avatar,- Block,- Button,- Collapsible,- cssVar,- Empty,- Flexbox,- Icon,- Text,-} from '@lobehub/ui';+import { Block, Button, Collapsible, cssVar, Empty, Flexbox, Icon, Text } from '@lobehub/ui';import type { TFunction } from 'i18next';import type { LucideIcon } from 'lucide-react';import {@@ -30,6 +20,7 @@ import type { ReactNode } from 'react';import { memo, useCallback, useMemo, useState } from 'react';import { Trans, useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import AgentProfilePopup from '@/features/AgentProfileCard/AgentProfilePopup';import type { BriefItem } from '@/features/DailyBrief/types';import MemberProfilePopup from '@/features/MemberProfileCard/MemberProfilePopup';diff --git a/src/features/AgentViewAll/coverColor.test.ts b/src/features/AgentViewAll/coverColor.test.tsindex aa3ba200079..4d26b1e99c1 100644--- a/src/features/AgentViewAll/coverColor.test.ts+++ b/src/features/AgentViewAll/coverColor.test.ts@@ -1,5 +1,6 @@import { DEFAULT_AVATAR } from '@lobechat/const';import type { SidebarAgentItem } from '@lobechat/types';+import { cssVar } from '@lobehub/ui';import { describe, expect, it } from 'vitest';import {@@ -66,11 +67,17 @@ describe('coverImageSrc', () => {);expect(coverImageSrc(agent({ avatar: 'π€' }))).toBeUndefined();expect(coverImageSrc(agent({ avatar: DEFAULT_AVATAR }))).toBeUndefined();+ expect(coverImageSrc(agent({ avatar: 'agent-avatar:rocket:cyan' }))).toBeUndefined();expect(coverImageSrc(agent({ avatar: null }))).toBeUndefined();});});describe('seedCoverColor', () => {+ it('wears the color of a picked character, not the one the id derives', () => {+ expect(seedCoverColor(agent({ avatar: 'agent-avatar:rocket:green' }))).toBe(cssVar.green);+ expect(seedCoverColor(agent({ avatar: 'agent-avatar:cat:red', id: 'agt_2' }))).toBe(cssVar.red);+ });+it('is stable per agent id', () => {expect(seedCoverColor(agent())).toBe(seedCoverColor(agent({ title: 'Renamed' })));});diff --git a/src/features/AgentViewAll/coverColor.ts b/src/features/AgentViewAll/coverColor.tsindex 16ab0e1e533..ecf68afe359 100644--- a/src/features/AgentViewAll/coverColor.ts+++ b/src/features/AgentViewAll/coverColor.ts@@ -1,5 +1,5 @@import type { SidebarAgentItem } from '@lobechat/types';-import { type AgentAvatarColor, cssVar, getAgentAvatarTraits } from '@lobehub/ui';+import { type AgentAvatarColor, cssVar, getAgentAvatarTraits, parseAgentAvatar } from '@lobehub/ui';import { isDefaultAgentAvatar } from '@/components/AgentAvatar';import { remoteAvatarSrc } from '@/components/Avatar/fallback';@@ -10,22 +10,28 @@ import { remoteAvatarSrc } from '@/components/Avatar/fallback';* readable in either theme.*/const SEED_COLORS: Record<AgentAvatarColor, string> = {+ cyan: cssVar.cyan,geekblue: cssVar.geekblue,gray: cssVar.gray,+ green: cssVar.green,ink: cssVar.gray,magenta: cssVar.magenta,orange: cssVar.orange,purple: cssVar.purple,+ red: cssVar.red,volcano: cssVar.volcano,};/**- * Cover color derived from the agent id: the same color its generated- * character wears, so an agent without an avatar of its own gets a band that- * matches its face, and any other agent still gets a stable one.+ * Cover color of the agent's character: the color its owner picked, else the+ * one derived from the agent id. An agent without an image of its own gets a+ * band that matches its face, and any other agent still gets a stable one.*/-export const seedCoverColor = (item: SidebarAgentItem): string =>- SEED_COLORS[getAgentAvatarTraits(item.id).color];+export const seedCoverColor = (item: SidebarAgentItem): string => {+ const picked = typeof item.avatar === 'string' ? parseAgentAvatar(item.avatar) : undefined;++ return SEED_COLORS[picked?.color ?? getAgentAvatarTraits(item.id).color];+};export const AGENT_COVER_PATTERNS = ['dots',diff --git a/src/features/ArtworkStudio/Content.tsx b/src/features/ArtworkStudio/Content.tsxindex 3049a34acd8..e324be73895 100644--- a/src/features/ArtworkStudio/Content.tsx+++ b/src/features/ArtworkStudio/Content.tsx@@ -11,7 +11,6 @@ import {AccordionTrigger,ActionIcon,Alert,- Avatar,Button,Center,createStaticStyles,@@ -36,6 +35,7 @@ import {import { memo, type MouseEvent, useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { avatarRemountKey, openFilePicker } from '@/features/AgentProfileArtwork/utils';import { CHIEF_AGENT_ARTWORKS, DEFAULT_CHIEF_AGENT_ARTWORK } from '@/features/ChiefAgent/artwork';import { HOME_PORTRAIT_VISIBLE_RATIO } from '@/features/Home/portraitFraming';diff --git a/src/features/ChatInput/ActionBar/Mention/index.tsx b/src/features/ChatInput/ActionBar/Mention/index.tsxindex 7016430e35b..443638d3eb4 100644--- a/src/features/ChatInput/ActionBar/Mention/index.tsx+++ b/src/features/ChatInput/ActionBar/Mention/index.tsx@@ -1,10 +1,10 @@import { agentDisplayName } from '@lobechat/types';import { type ItemType } from '@lobehub/ui';-import { Avatar } from '@lobehub/ui';import { AtSign } from 'lucide-react';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { useMentionStore } from '@/store/mention';import { useSessionStore } from '@/store/session';import { sessionSelectors } from '@/store/session/selectors';diff --git a/src/features/ChatInput/InputEditor/marketMentionItems.tsx b/src/features/ChatInput/InputEditor/marketMentionItems.tsxindex 6698b1bcac3..ca3488b0507 100644--- a/src/features/ChatInput/InputEditor/marketMentionItems.tsx+++ b/src/features/ChatInput/InputEditor/marketMentionItems.tsx@@ -1,7 +1,8 @@import type { ISlashMenuOption } from '@lobehub/editor';-import { Avatar, cssVar, Flexbox } from '@lobehub/ui';+import { cssVar, Flexbox } from '@lobehub/ui';import type { ReactNode } from 'react';+import Avatar from '@/components/Avatar';import { discoverService } from '@/services/discover';import { globalHelpers } from '@/store/global/helpers';import type { DiscoverAssistantItem, DiscoverSkillItem } from '@/types/discover';diff --git a/src/features/ChatInput/InputEditor/useMentionCategories.tsx b/src/features/ChatInput/InputEditor/useMentionCategories.tsxindex 42d3be3efaa..fb3e322627e 100644--- a/src/features/ChatInput/InputEditor/useMentionCategories.tsx+++ b/src/features/ChatInput/InputEditor/useMentionCategories.tsx@@ -1,11 +1,12 @@import { agentDisplayName } from '@lobechat/types';-import { Avatar, Icon } from '@lobehub/ui';+import { Icon } from '@lobehub/ui';import { SkillsIcon } from '@lobehub/ui/icons';import isEqual from 'fast-deep-equal';import { Bot, Lock, MessageSquareText, Users, Wrench } from 'lucide-react';import { useMemo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import type { SidebarAgentItem } from '@/database/repositories/home';import { usePermission } from '@/hooks/usePermission';import { useChatStore } from '@/store/chat';diff --git a/src/features/DeviceManager/DeviceActivity/index.tsx b/src/features/DeviceManager/DeviceActivity/index.tsxindex dbf82ad57e6..3d30982aac5 100644--- a/src/features/DeviceManager/DeviceActivity/index.tsx+++ b/src/features/DeviceManager/DeviceActivity/index.tsx@@ -2,20 +2,12 @@import { AGENT_CHAT_URL } from '@lobechat/const';import { agentDisplayName, type DeviceBoundAgentItem } from '@lobechat/types';-import {- ActionIcon,- Avatar,- createStaticStyles,- cssVar,- Flexbox,- Icon,- Tag,- Text,-} from '@lobehub/ui';+import { ActionIcon, createStaticStyles, cssVar, Flexbox, Icon, Tag, Text } from '@lobehub/ui';import { ArrowUpRightIcon, LockIcon } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import RunningGlyph from '@/features/Home/components/RunningGlyph';import TopicRow, { getTopicChatUrl } from '@/features/HomeInbox/TopicRow';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';diff --git a/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts b/src/features/Electron/ScreenCapture/overlaySnapshot.test.tsindex 3bbd85286df..7af071102eb 100644--- a/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts+++ b/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts@@ -27,6 +27,18 @@ describe('overlaySnapshot', () => {]);});+ // The overlay draws emoji and images only; it showed the picked value's first letter.+ it('hands the overlay no picked Agent character', () => {+ const [inbox, agent] = resolveOverlayAgentOptions({+ agents: [{ avatar: 'agent-avatar:cat:green', id: 'agent-1', title: 'Agent 1' }],+ inboxAgentId: 'inbox-agent',+ inboxMeta: { avatar: 'agent-avatar:rocket:cyan', title: null },+ });++ expect(inbox.avatar).toBe(DEFAULT_INBOX_AVATAR);+ expect(agent.avatar).toBeUndefined();+ });+it('falls back to inbox when the active agent is not selectable in overlay', () => {const agentOptions = resolveOverlayAgentOptions({agents: [{ avatar: 'A', id: 'agent-1', title: 'Agent 1' }],diff --git a/src/features/Electron/ScreenCapture/overlaySnapshot.ts b/src/features/Electron/ScreenCapture/overlaySnapshot.tsindex 1514b5caa61..f20e4f2aab1 100644--- a/src/features/Electron/ScreenCapture/overlaySnapshot.ts+++ b/src/features/Electron/ScreenCapture/overlaySnapshot.ts@@ -2,7 +2,7 @@ import { DEFAULT_INBOX_AVATAR, DEFAULT_INBOX_TITLE } from '@lobechat/const';import type { ScreenCaptureAgentOption } from '@lobechat/electron-client-ipc';import { agentDisplayName } from '@lobechat/types';-import { isDefaultAgentAvatar } from '@/components/AgentAvatar/resolve';+import { isGeneratedAgentAvatar } from '@/components/AgentAvatar/resolve';const LOBE_AI_TITLE = DEFAULT_INBOX_TITLE;const UNTITLED_AGENT_TITLE = 'Untitled Agent';@@ -42,7 +42,7 @@ const toOverlayAgentOption = ({name,title,}: OverlayAgentSource): ScreenCaptureAgentOption => ({- avatar: typeof avatar === 'string' && !isDefaultAgentAvatar(avatar) ? avatar : undefined,+ avatar: typeof avatar === 'string' && !isGeneratedAgentAvatar(avatar) ? avatar : undefined,backgroundColor: backgroundColor ?? undefined,heterogeneousType,id,@@ -53,7 +53,11 @@ const createInboxOverlayAgentOption = (inboxAgentId: string,inboxMeta?: OverlayInboxMeta,): ScreenCaptureAgentOption => ({- avatar: inboxMeta?.avatar || DEFAULT_INBOX_AVATAR,+ // The overlay draws emoji and images only; a picked character falls back to the inbox image.+ avatar:+ inboxMeta?.avatar && !isGeneratedAgentAvatar(inboxMeta.avatar)+ ? inboxMeta.avatar+ : DEFAULT_INBOX_AVATAR,backgroundColor: inboxMeta?.backgroundColor ?? undefined,id: inboxAgentId,title: agentDisplayName(inboxMeta, LOBE_AI_TITLE),diff --git a/src/features/EntityLink/Render/InternalEntityPreview.tsx b/src/features/EntityLink/Render/InternalEntityPreview.tsxindex 7f528c23f4f..4030818c7bb 100644--- a/src/features/EntityLink/Render/InternalEntityPreview.tsx+++ b/src/features/EntityLink/Render/InternalEntityPreview.tsx@@ -1,15 +1,6 @@'use client';-import {- ActionIcon,- Avatar,- createStaticStyles,- Flexbox,- Freeze,- Icon,- Popover,- Text,-} from '@lobehub/ui';+import { ActionIcon, createStaticStyles, Flexbox, Freeze, Icon, Popover, Text } from '@lobehub/ui';import type { TFunction } from 'i18next';import {BadgeCheckIcon,@@ -23,6 +14,7 @@ import {import { memo, type PropsWithChildren, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { ArticleSkeleton } from '@/components/Skeleton';import { goalStatusKey } from '@/features/AgentGoals/goalPresentation';import type { EntityPreview } from '@/store/entityPreview';diff --git a/src/features/Favorites/FavoriteIcon.tsx b/src/features/Favorites/FavoriteIcon.tsxindex c093811a5fe..1fc39f1cf37 100644--- a/src/features/Favorites/FavoriteIcon.tsx+++ b/src/features/Favorites/FavoriteIcon.tsx@@ -1,7 +1,7 @@'use client';import type { FavoriteType } from '@lobechat/types';-import { Avatar, cssVar, Icon } from '@lobehub/ui';+import { cssVar, Icon } from '@lobehub/ui';import {BotIcon,FileTextIcon,@@ -16,6 +16,8 @@ import {} from 'lucide-react';import { memo } from 'react';+import Avatar from '@/components/Avatar';+const TYPE_ICONS: Record<FavoriteType, LucideIcon> = {agent: BotIcon,dashboard: LayoutDashboardIcon,diff --git a/src/features/HomeInbox/NewsList.tsx b/src/features/HomeInbox/NewsList.tsxindex 73015eca00d..360cd10d674 100644--- a/src/features/HomeInbox/NewsList.tsx+++ b/src/features/HomeInbox/NewsList.tsx@@ -1,9 +1,10 @@import { agentDisplayName } from '@lobechat/types';-import { Avatar, Button, createStaticStyles, cssVar, cx, Flexbox, Icon, Text } from '@lobehub/ui';+import { Button, createStaticStyles, cssVar, cx, Flexbox, Icon, Text } from '@lobehub/ui';import { ChevronDownIcon, ChevronRightIcon } from 'lucide-react';import { lazy, memo, Suspense, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import BriefCardArtifacts from '@/features/DailyBrief/BriefCardArtifacts';import BriefIcon from '@/features/DailyBrief/BriefIcon';import BriefPriorityIcon from '@/features/DailyBrief/BriefPriorityIcon';diff --git a/src/features/HomeSidebar/Body/Agent/List/InboxItem.tsx b/src/features/HomeSidebar/Body/Agent/List/InboxItem.tsxindex 9995b6a634c..337d91c8ef4 100644--- a/src/features/HomeSidebar/Body/Agent/List/InboxItem.tsx+++ b/src/features/HomeSidebar/Body/Agent/List/InboxItem.tsx@@ -2,12 +2,13 @@import { DEFAULT_INBOX_AVATAR, DEFAULT_INBOX_TITLE } from '@lobechat/const';import { agentDisplayName } from '@lobechat/types';-import { Avatar, Spin } from '@lobehub/ui';+import { Spin } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import { type CSSProperties } from 'react';import { memo } from 'react';+import Avatar from '@/components/Avatar';import { resolveInboxAgentRouteId } from '@/features/AgentRoute/useResolvedAgentRouteId';import NavItem from '@/features/NavPanel/components/NavItem';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';diff --git a/src/features/Marketplace/Catalog/AgentCatalog.tsx b/src/features/Marketplace/Catalog/AgentCatalog.tsxindex f3f59611736..eefad7451b9 100644--- a/src/features/Marketplace/Catalog/AgentCatalog.tsx+++ b/src/features/Marketplace/Catalog/AgentCatalog.tsx@@ -1,11 +1,12 @@'use client';-import { Avatar, Button, Tag } from '@lobehub/ui';+import { Button, Tag } from '@lobehub/ui';import * as stylex from '@stylexjs/stylex';import { useTranslation } from 'react-i18next';import urlJoin from 'url-join';import AsyncBoundary from '@/components/AsyncBoundary';+import Avatar from '@/components/Avatar';import { CatalogRowsSkeleton } from '@/components/Skeleton/MarketplaceCatalog';import { buildAssistantListQuery } from '@/features/CommunityAgentList/assistantListQuery';import SkillListRow from '@/features/Settings/skill/features/SkillListRow';diff --git a/src/features/PageEditor/Copilot/Welcome.tsx b/src/features/PageEditor/Copilot/Welcome.tsxindex e9cd60faf22..8038a83ad8c 100644--- a/src/features/PageEditor/Copilot/Welcome.tsx+++ b/src/features/PageEditor/Copilot/Welcome.tsx@@ -1,9 +1,10 @@'use client';-import { Avatar, Flexbox, Text } from '@lobehub/ui';+import { Flexbox, Text } from '@lobehub/ui';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { DEFAULT_INBOX_AVATAR } from '@/const/index';import { conversationSelectors, useConversationStore } from '@/features/Conversation';import SuggestQuestions from '@/features/SuggestQuestions';diff --git a/src/features/ResourceTransferRequest/TransferRequestItem.tsx b/src/features/ResourceTransferRequest/TransferRequestItem.tsxindex f8a764fa6a4..3cd3721c997 100644--- a/src/features/ResourceTransferRequest/TransferRequestItem.tsx+++ b/src/features/ResourceTransferRequest/TransferRequestItem.tsx@@ -1,10 +1,11 @@'use client';import { AGENT_CHAT_URL, GROUP_CHAT_URL } from '@lobechat/const';-import { Avatar, Block, Button, Flexbox, Tag, Text, toast } from '@lobehub/ui';+import { Block, Button, Flexbox, Tag, Text, toast } from '@lobehub/ui';import { memo, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { formatNotificationRelativeTime } from '@/features/HomeSidebar/Header/components/InboxModal/formatNotificationRelativeTime';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import type {diff --git a/src/features/Settings/trash/features/TrashList.tsx b/src/features/Settings/trash/features/TrashList.tsxindex 195538b78e6..f824884fada 100644--- a/src/features/Settings/trash/features/TrashList.tsx+++ b/src/features/Settings/trash/features/TrashList.tsx@@ -9,7 +9,6 @@ import type {TrashVisibility,} from '@lobechat/types';import {- Avatar,Button,Center,confirmModal,@@ -33,6 +32,7 @@ import { Trash2Icon } from 'lucide-react';import { useEffect, useRef } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import LiteTable, { type LiteTableColumn } from '@/components/LiteTable';import { useIsMobile } from '@/hooks/useIsMobile';import { usePermission } from '@/hooks/usePermission';diff --git a/src/features/SkillStore/SkillDetail/AgentItem.tsx b/src/features/SkillStore/SkillDetail/AgentItem.tsxindex 960f48feede..2c3f4d9dfca 100644--- a/src/features/SkillStore/SkillDetail/AgentItem.tsx+++ b/src/features/SkillStore/SkillDetail/AgentItem.tsx@@ -1,8 +1,10 @@'use client';-import { Avatar, Block, Flexbox } from '@lobehub/ui';+import { Block, Flexbox } from '@lobehub/ui';import { memo } from 'react';+import Avatar from '@/components/Avatar';+import { itemStyles } from './style';interface AgentItemProps {diff --git a/src/routes/(main)/community/(detail)/agent/features/Header.tsx b/src/routes/(main)/community/(detail)/agent/features/Header.tsxindex c3c1ec12cf1..51fe7357846 100644--- a/src/routes/(main)/community/(detail)/agent/features/Header.tsx+++ b/src/routes/(main)/community/(detail)/agent/features/Header.tsx@@ -3,7 +3,6 @@import { MCP } from '@lobehub/icons';import {ActionIcon,- Avatar,Button,Flexbox,Icon,@@ -28,6 +27,7 @@ import qs from 'query-string';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import PublishedTime from '@/components/PublishedTime';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';diff --git a/src/routes/(main)/community/(detail)/agent/features/Sidebar/Related/Item.tsx b/src/routes/(main)/community/(detail)/agent/features/Sidebar/Related/Item.tsxindex c0668a790be..63e8078948b 100644--- a/src/routes/(main)/community/(detail)/agent/features/Sidebar/Related/Item.tsx+++ b/src/routes/(main)/community/(detail)/agent/features/Sidebar/Related/Item.tsx@@ -1,8 +1,9 @@-import { Avatar, Block, Flexbox, Text } from '@lobehub/ui';+import { Block, Flexbox, Text } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import { memo } from 'react';+import Avatar from '@/components/Avatar';import { densityTokens } from '@/styles/density.stylex';import { type DiscoverAssistantItem } from '@/types/discover';diff --git a/src/routes/(main)/community/(detail)/features/ShareButton.tsx b/src/routes/(main)/community/(detail)/features/ShareButton.tsxindex b04b1dcb825..676be5d3ef0 100644--- a/src/routes/(main)/community/(detail)/features/ShareButton.tsx+++ b/src/routes/(main)/community/(detail)/features/ShareButton.tsx@@ -1,6 +1,5 @@import {ActionIcon,- Avatar,Button,Center,CopyButton,@@ -21,6 +20,7 @@ import { type ComponentProps, type ReactNode } from 'react';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import ImperativeModal from '@/components/ImperativeModal';import SocialShare from '@/features/SocialShare';import { useShare } from '@/hooks/useShare';diff --git a/src/routes/(main)/community/(detail)/group_agent/features/Details/Overview/index.tsx b/src/routes/(main)/community/(detail)/group_agent/features/Details/Overview/index.tsxindex 1e736929081..385a56ca0b0 100644--- a/src/routes/(main)/community/(detail)/group_agent/features/Details/Overview/index.tsx+++ b/src/routes/(main)/community/(detail)/group_agent/features/Details/Overview/index.tsx@@ -1,11 +1,12 @@import { BRANDING_NAME } from '@lobechat/business-const';-import { Accordion, Avatar, Block, Flexbox, Grid, Text, useTheme } from '@lobehub/ui';+import { Accordion, Block, Flexbox, Grid, Text, useTheme } from '@lobehub/ui';import { ChatList } from '@lobehub/ui/chat';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { DEFAULT_USER_AVATAR_URL } from '@/const/meta';import { useUserStore } from '@/store/user';import { authSelectors, userProfileSelectors } from '@/store/user/selectors';diff --git a/src/routes/(main)/community/(detail)/group_agent/features/Header.tsx b/src/routes/(main)/community/(detail)/group_agent/features/Header.tsxindex 84fbb6c709b..bec7df311e6 100644--- a/src/routes/(main)/community/(detail)/group_agent/features/Header.tsx+++ b/src/routes/(main)/community/(detail)/group_agent/features/Header.tsx@@ -2,7 +2,6 @@import {ActionIcon,- Avatar,Button,Flexbox,Icon,@@ -20,6 +19,7 @@ import qs from 'query-string';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import PublishedTime from '@/components/PublishedTime';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';diff --git a/src/routes/(main)/community/(detail)/user/features/UserAgentCard.tsx b/src/routes/(main)/community/(detail)/user/features/UserAgentCard.tsxindex 6cbd1d008c8..14b57c41fd7 100644--- a/src/routes/(main)/community/(detail)/user/features/UserAgentCard.tsx+++ b/src/routes/(main)/community/(detail)/user/features/UserAgentCard.tsx@@ -1,7 +1,6 @@'use client';import {- Avatar,Block,DropdownMenu,Flexbox,@@ -31,6 +30,7 @@ import { useTranslation } from 'react-i18next';import urlJoin from 'url-join';import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';+import Avatar from '@/components/Avatar';import PublishedTime from '@/components/PublishedTime';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';diff --git a/src/routes/(main)/community/(detail)/user/features/UserGroupCard.tsx b/src/routes/(main)/community/(detail)/user/features/UserGroupCard.tsxindex f0ba9ebac45..43be6f35389 100644--- a/src/routes/(main)/community/(detail)/user/features/UserGroupCard.tsx+++ b/src/routes/(main)/community/(detail)/user/features/UserGroupCard.tsx@@ -1,7 +1,6 @@'use client';import {- Avatar,Block,DropdownMenu,Flexbox,@@ -29,6 +28,7 @@ import { memo, useCallback } from 'react';import { useTranslation } from 'react-i18next';import urlJoin from 'url-join';+import Avatar from '@/components/Avatar';import PublishedTime from '@/components/PublishedTime';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';diff --git a/src/routes/(main)/community/(list)/agent/features/List/Item.tsx b/src/routes/(main)/community/(list)/agent/features/List/Item.tsxindex 9a6e026b105..99548528c75 100644--- a/src/routes/(main)/community/(list)/agent/features/List/Item.tsx+++ b/src/routes/(main)/community/(list)/agent/features/List/Item.tsx@@ -1,4 +1,4 @@-import { Avatar, Block, Flexbox, Icon, Tag, Text } from '@lobehub/ui';+import { Block, Flexbox, Icon, Tag, Text } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';import * as stylex from '@stylexjs/stylex';import { ClockIcon } from 'lucide-react';@@ -7,6 +7,7 @@ import React, { memo, useCallback } from 'react';import { useTranslation } from 'react-i18next';import urlJoin from 'url-join';+import Avatar from '@/components/Avatar';import PublishedTime from '@/components/PublishedTime';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import WorkspaceLink from '@/features/Workspace/WorkspaceLink';diff --git a/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx b/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsxindex 81f31cd098a..7a58a2dfe31 100644--- a/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx+++ b/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx@@ -1,7 +1,6 @@'use client';import {- Avatar,createStaticStyles,cx,type DropdownItem,@@ -14,6 +13,7 @@ import { type ReactNode } from 'react';import { memo, useEffect, useRef } from 'react';import { useTranslation } from 'react-i18next';+import Avatar from '@/components/Avatar';import { densityVars } from '@/styles/densityVars';const styles = createStaticStyles(({ css, cssVar: cv }) => ({diff --git a/src/routes/(main)/group/profile/features/MemberProfile/AgentHeader.tsx b/src/routes/(main)/group/profile/features/MemberProfile/AgentHeader.tsxindex 5e4fc774ed1..1f8f6c23905 100644--- a/src/routes/(main)/group/profile/features/MemberProfile/AgentHeader.tsx+++ b/src/routes/(main)/group/profile/features/MemberProfile/AgentHeader.tsx@@ -1,13 +1,23 @@'use client';import { EDITOR_DEBOUNCE_TIME } from '@lobechat/const';-import { Block, Flexbox, Icon, Input, Skeleton, toast, Tooltip } from '@lobehub/ui';+import {+ Block,+ Flexbox,+ Icon,+ Input,+ parseAgentAvatar,+ Skeleton,+ toast,+ Tooltip,+} from '@lobehub/ui';import { debounce } from 'es-toolkit/compat';import isEqual from 'fast-deep-equal';import { PaletteIcon } from 'lucide-react';import { memo, Suspense, useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import AgentAvatar from '@/components/AgentAvatar';import { isDefaultAgentAvatar } from '@/components/AgentAvatar/resolve';import EmojiPicker from '@/components/EmojiPicker';import BackgroundSwatches from '@/features/AgentSetting/AgentMeta/BackgroundSwatches';@@ -177,15 +187,20 @@ const AgentHeader = memo<AgentHeaderProps>(({ readOnly, disabled: disabledProp }: undefined}customRender={- !isDefaultAgentAvatar(agentMeta.avatar)- ? undefined- : () => {- return (+ isDefaultAgentAvatar(agentMeta.avatar)+ ? () => (+ <Block clickable height={72} width={72}>+ <SupervisorAvatar size={72} />+ </Block>+ )+ : // A character picked in Lobot is no emoji or image; the picker would print its text.+ parseAgentAvatar(agentMeta.avatar)+ ? () => (<Block clickable height={72} width={72}>- <SupervisorAvatar size={72} />+ <AgentAvatar agentId={agentId} avatar={agentMeta.avatar} size={72} /></Block>- );- }+ )+ : undefined}customTabs={[{diff --git a/src/store/chat/utils/notificationAvatar.test.ts b/src/store/chat/utils/notificationAvatar.test.tsindex 6e047a2d25e..a5b57d44026 100644--- a/src/store/chat/utils/notificationAvatar.test.ts+++ b/src/store/chat/utils/notificationAvatar.test.ts@@ -60,6 +60,14 @@ describe('renderAvatarToDataUrl', () => {expect(await renderAvatarToDataUrl('no-avatar', {})).toBeUndefined();});+ // Drawn as text, the picked value printed "agent-avatar:rocket:cyan" as the picture.+ it('gives a picked Agent character no picture instead of printing its value', async () => {+ expect(+ await renderAvatarToDataUrl('picked-1', { avatar: 'agent-avatar:rocket:cyan' }),+ ).toBeUndefined();+ expect(context2d.fillText).not.toHaveBeenCalled();+ });+it('draws emoji avatars onto the agent background color', async () => {const result = await renderAvatarToDataUrl('emoji-1', {avatar: 'π€',diff --git a/src/store/chat/utils/notificationAvatar.ts b/src/store/chat/utils/notificationAvatar.tsindex 0e206821fcf..de120ceae17 100644--- a/src/store/chat/utils/notificationAvatar.ts+++ b/src/store/chat/utils/notificationAvatar.ts@@ -1,3 +1,5 @@+import { parseAgentAvatar } from '@lobehub/ui';+const AVATAR_SIZE = 256;const FALLBACK_BACKGROUND = '#EBEBEB';const EMOJI_FONT_RATIO = 0.62;@@ -85,6 +87,9 @@ export const renderAvatarToDataUrl = (): Promise<string | undefined> => {const { avatar, backgroundColor } = meta;if (!avatar || typeof document === 'undefined') return Promise.resolve(undefined);+ // A picked Agent character (`agent-avatar:<shape>:<color>`) is no emoji or image; drawing it+ // as text would print its value. It gets no picture, like the generated character.+ if (parseAgentAvatar(avatar)) return Promise.resolve(undefined);const key = [cacheKey, avatar, backgroundColor].join('|');const cached = avatarCache.get(key);