π€― 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
π style(topic): identity-first creator avatar in workspace topic rows (#17420)
Arvin Xu219bc1b08be8
diff --git a/src/features/TopicCreatorAvatar/index.test.tsx b/src/features/TopicCreatorAvatar/index.test.tsxindex 41e4b5738f1..2d33dc97d6b 100644--- a/src/features/TopicCreatorAvatar/index.test.tsx+++ b/src/features/TopicCreatorAvatar/index.test.tsx@@ -14,16 +14,19 @@ vi.mock('@/business/client/hooks/useAuthorInfo', () => ({}));vi.mock('@lobehub/ui', () => ({- Avatar: ({ avatar, title }: { avatar?: string; title?: string }) => (- <span data-avatar={avatar ?? ''} data-testid="avatar" data-title={title ?? ''} />+ Avatar: ({ avatar, shape, title }: { avatar?: string; shape?: string; title?: string }) => (+ <span+ data-avatar={avatar ?? ''}+ data-shape={shape ?? ''}+ data-testid="avatar"+ data-title={title ?? ''}+ />),Tooltip: ({ children }: { children?: ReactNode }) => <>{children}</>,}));describe('TopicCreatorAvatar', () => {- it("renders a workspace member's avatar (including the current user's own topics)", () => {- // In a workspace `useAuthorInfo` resolves the creator profile from members β- // for every topic, not just other members'.+ it("renders a workspace member's round avatar (any member, including self)", () => {useAuthorInfoMock.mockReturnValue({ avatar: 'https://x/y.png', fullName: 'Alice' });const { getByTestId } = render(<TopicCreatorAvatar userId="any-member" />);@@ -31,16 +34,41 @@ describe('TopicCreatorAvatar', () => {expect(useAuthorInfoMock).toHaveBeenCalledWith('any-member');const avatar = getByTestId('avatar');expect(avatar.getAttribute('data-avatar')).toBe('https://x/y.png');+ expect(avatar.getAttribute('data-shape')).toBe('circle');expect(avatar.getAttribute('data-title')).toBe('Alice');});+ it('keeps the avatar primary and shrinks the row icon into the corner badge', () => {+ useAuthorInfoMock.mockReturnValue({ avatar: 'https://x/y.png', fullName: 'Alice' });++ const { getByTestId } = render(+ <TopicCreatorAvatar corner={<span data-testid="status-icon" />} userId="any-member" />,+ );++ // Both the full avatar and the corner-badged row icon render.+ expect(getByTestId('avatar')).toBeTruthy();+ expect(getByTestId('status-icon')).toBeTruthy();+ });++ it('renders the bare avatar when no corner node is provided', () => {+ useAuthorInfoMock.mockReturnValue({ avatar: 'https://x/y.png', fullName: 'Alice' });++ const { getByTestId, queryByTestId } = render(<TopicCreatorAvatar userId="any-member" />);++ expect(getByTestId('avatar')).toBeTruthy();+ expect(queryByTestId('status-icon')).toBeNull();+ });+it('renders nothing in personal mode / when the creator is not a resolvable member', () => {- // No active workspace β the slot resolves to undefined β no avatar.useAuthorInfoMock.mockReturnValue(undefined);- const { queryByTestId } = render(<TopicCreatorAvatar userId="someone" />);+ const { queryByTestId } = render(+ <TopicCreatorAvatar corner={<span data-testid="status-icon" />} userId="someone" />,+ );+ // No avatar AND no corner badge β the caller falls back to its own layout.expect(queryByTestId('avatar')).toBeNull();+ expect(queryByTestId('status-icon')).toBeNull();});it('renders nothing when no userId is provided (default / temp topic)', () => {diff --git a/src/features/TopicCreatorAvatar/index.tsx b/src/features/TopicCreatorAvatar/index.tsxindex f3a6eeccbaf..5f354e6c03e 100644--- a/src/features/TopicCreatorAvatar/index.tsx+++ b/src/features/TopicCreatorAvatar/index.tsx@@ -1,11 +1,26 @@'use client';import { Avatar, Tooltip } from '@lobehub/ui';-import { memo } from 'react';+import { cssVar } from 'antd-style';+import { memo, type ReactNode } from 'react';import { useAuthorInfo } from '@/business/client/hooks/useAuthorInfo';+/**+ * Resolves a topic creator's profile from the *active workspace* members.+ * `useAuthorInfo` is a business slot: cloud resolves the member profile, the+ * open-source build is a no-op β and it returns `undefined` without an active+ * workspace, so all creator-avatar UI disappears in personal mode.+ */+export const useTopicCreator = (userId?: string) => useAuthorInfo(userId);+interface TopicCreatorAvatarProps {+ /**+ * Optional mini node (execution status, bot platform icon, PR marker, β¦)+ * overlaid at the avatar's bottom-right corner. The creator stays the+ * primary visual; the row's own icon shrinks into the badge.+ */+ corner?: ReactNode;/** Size of the avatar in px. */size?: number;/** Creator (author) of the topic. */@@ -13,30 +28,66 @@ interface TopicCreatorAvatarProps {}/**- * In a workspace the topic list mixes topics from every member. Show each- * topic's creator avatar as a trailing indicator β including the current user's- * own topics β so the list reads as a shared space.- *- * `useAuthorInfo` is a business slot that resolves the creator profile from the- * *active workspace* members (cloud) or a no-op (open-source). It returns- * `undefined` when there is no active workspace, so this renders nothing in- * personal mode.+ * Round creator avatar for a workspace topic row's leading icon slot β it+ * replaces the default `#` placeholder so the shared list reads like a+ * conversation list. Renders nothing when the creator doesn't resolve+ * (personal mode / unknown member).*/-const TopicCreatorAvatar = memo<TopicCreatorAvatarProps>(({ userId, size = 16 }) => {- const author = useAuthorInfo(userId);+const TopicCreatorAvatar = memo<TopicCreatorAvatarProps>(({ userId, size = 20, corner }) => {+ const author = useTopicCreator(userId);if (!author) return null;- return (+ const avatar = (<Tooltip title={author.fullName}><Avataravatar={author.avatar ?? undefined}+ shape={'circle'}size={size}style={{ flex: 'none' }}title={author.fullName ?? undefined}/></Tooltip>);++ if (!corner) return avatar;++ return (+ <span style={{ display: 'inline-flex', lineHeight: 0, position: 'relative' }}>+ {avatar}+ <span+ style={{+ alignItems: 'center',+ // Solid panel background so the badge glyph reads cleanly instead of+ // colliding with the avatar underneath; the ring blends it into the+ // sidebar like a Slack/Discord presence badge.+ background: cssVar.colorBgLayout,+ borderRadius: '50%',+ bottom: -4,+ boxShadow: `0 0 0 1.5px ${cssVar.colorBgLayout}`,+ display: 'inline-flex',+ height: 13,+ justifyContent: 'center',+ lineHeight: 0,+ position: 'absolute',+ right: -4,+ width: 13,+ }}+ >+ <span+ style={{+ alignItems: 'center',+ display: 'inline-flex',+ justifyContent: 'center',+ transform: 'scale(0.75)',+ transformOrigin: 'center',+ }}+ >+ {corner}+ </span>+ </span>+ </span>+ );});TopicCreatorAvatar.displayName = 'TopicCreatorAvatar';diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/index.tsx b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/index.tsxindex 8e52258a4f8..c1ec27cea44 100644--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/index.tsx+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/Item/index.tsx@@ -23,7 +23,7 @@ import DirIcon from '@/features/ChatInput/ControlBar/DirIcon';import { useHasDraft } from '@/features/ChatInput/draftStorage';import { startTopicDrag } from '@/features/ChatInput/InputEditor/ReferTopic/topicDragData';import NavItem from '@/features/NavPanel/components/NavItem';-import TopicCreatorAvatar from '@/features/TopicCreatorAvatar';+import TopicCreatorAvatar, { useTopicCreator } from '@/features/TopicCreatorAvatar';import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';import { getWorkingDirectoryName } from '@/helpers/workingDirectoryPath';import { getPlatformIcon } from '@/routes/(main)/agent/channel/const';@@ -161,6 +161,16 @@ const TopicItem = memo<TopicItemProps>(const isHeterogeneousAgent = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);const addTab = useElectronStore((s) => s.addTab);const prefetchMessages = useChatStore((s) => s.prefetchMessages);+ // A workspace-private agent is a purely personal conversation space even+ // inside a workspace β its topics all belong to the viewer, so the creator+ // avatar carries no information there. Only workspace-shared (`public`)+ // agents get the avatar treatment.+ const isSharedAgent = useAgentStore(+ (s) => agentSelectors.currentAgentVisibility(s) === 'public',+ );+ // Creator of the topic β resolves only inside an active workspace; drives+ // the identity-first icon layout below.+ const author = useTopicCreator(isSharedAgent ? userId : undefined);const loadingRingColor = isDarkMode? cssVar.colorWarningBorder@@ -352,6 +362,110 @@ const TopicItem = memo<TopicItemProps>(// keeping the row itself clean.const metaCard = getTopicMetaCard(metadata);+ // Execution / attention state. In workspace mode this moves to the row's+ // trailing side so the leading slot can carry the creator identity.+ const statusIconNode = (() => {+ // A scheduled topic hasn't run yet β nothing else can be true of it,+ // so its clock outranks the other states.+ if (isScheduled) {+ const visual = TOPIC_STATUS_VISUALS.scheduled;+ const runAt = metadata?.scheduledRun?.runAt;+ const icon = <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;+ return runAt ? (+ <Tooltip title={t('scheduledStatusTip', { time: dayjs(runAt).format('MM-DD HH:mm') })}>+ {icon}+ </Tooltip>+ ) : (+ icon+ );+ }+ if (isWaitingForHuman) {+ const visual = TOPIC_STATUS_VISUALS.waitingForHuman;+ return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;+ }+ if (shouldShowRunningIcon) {+ return (+ <RingLoadingIcon+ ringColor={loadingRingColor}+ size={14}+ style={{ color: cssVar.colorWarning }}+ />+ );+ }+ if (isFailed) {+ const visual = TOPIC_STATUS_VISUALS.failed;+ return (+ <Tooltip title={t('failedStatusTip')}>+ <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />+ </Tooltip>+ );+ }+ // Unread is the third `pending` attention state (see `resolveStatusBucket`+ // in `@lobechat/utils/client/topic`), so it ranks with its two siblings+ // above β and above the PR marker, which shares this single icon slot.+ if (hasUnread) return unreadIcon;+ // Persisted execution state is the topic's primary status. Keep every+ // non-idle state above git metadata so scheduled / paused / completed+ // topics cannot be mistaken for merely open / merged / closed PRs.+ // `running` is handled exclusively by shouldShowRunningIcon above so+ // the masked post-output tail cannot fall back to a static running icon.+ if (status && status !== 'active' && status !== 'running') {+ const visual = TOPIC_STATUS_VISUALS[status];+ return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;+ }+ return null;+ })();++ // Identity-flavored icons the row owns (bot platform, PR marker) β these+ // keep the leading slot even in workspace mode, with the creator shrunk to+ // a corner badge.+ const identityIconNode = (() => {+ // GitHub PR state marker (open=green, merged=purple, closed=red),+ // like Codex. It is secondary metadata, so only an idle topic uses it+ // as the leading icon.+ if (metaCard?.pullRequest) {+ const prVisual = PR_STATE_VISUAL[getPullRequestState(metaCard.pullRequest)];+ return (+ <Tooltip title={t(prVisual.labelKey)}>+ <Icon icon={prVisual.icon} size={'small'} style={{ color: prVisual.color }} />+ </Tooltip>+ );+ }+ if (metadata?.bot?.platform) {+ const ProviderIcon = getPlatformIcon(metadata.bot!.platform);+ if (ProviderIcon) {+ return <ProviderIcon color={cssVar.colorTextDescription} size={16} />;+ }+ }+ return null;+ })();++ const hashIconNode = (+ <Icon+ icon={HashIcon}+ size={'small'}+ style={{+ color: cssVar.colorTextDescription,+ // Heterogeneous agents (Claude Code, Codex, β¦) have no chat-style+ // topic semantics, so suppress the `#` glyph while keeping its+ // box so the title stays aligned with sibling rows.+ visibility: isHeterogeneousAgent ? 'hidden' : undefined,+ }}+ />+ );++ // Workspace mode (creator resolvable): the creator's round avatar is the+ // primary visual and always leads the row; the row's own icon β execution+ // status first, then identity icons (Discord / WeChat / PR marker) β+ // shrinks into a bottom-right corner badge. Personal mode keeps the+ // original layout untouched.+ const ownIconNode = statusIconNode ?? identityIconNode;+ const leadingIconNode = author ? (+ <TopicCreatorAvatar corner={ownIconNode} userId={userId} />+ ) : (+ (ownIconNode ?? hashIconNode)+ );+const navItem = (<NavItemactions={<Actions dropdownMenu={dropdownMenu} />}@@ -360,98 +474,12 @@ const TopicItem = memo<TopicItemProps>(description={workingDirectoryNode}disabled={editing}draggable={!editing}+ extra={<RunningElapsedTime agentId={activeAgentId} topicId={id} />}href={href}+ icon={leadingIconNode}slots={{ titlePrefix: draftPrefix }}title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}titleColor={cssVar.colorText}- extra={- <>- <RunningElapsedTime agentId={activeAgentId} topicId={id} />- <TopicCreatorAvatar userId={userId} />- </>- }- icon={(() => {- // A scheduled topic hasn't run yet β nothing else can be true of it,- // so its clock outranks the other states.- if (isScheduled) {- const visual = TOPIC_STATUS_VISUALS.scheduled;- const runAt = metadata?.scheduledRun?.runAt;- const icon = <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;- return runAt ? (- <Tooltip- title={t('scheduledStatusTip', { time: dayjs(runAt).format('MM-DD HH:mm') })}- >- {icon}- </Tooltip>- ) : (- icon- );- }- if (isWaitingForHuman) {- const visual = TOPIC_STATUS_VISUALS.waitingForHuman;- return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;- }- if (shouldShowRunningIcon) {- return (- <RingLoadingIcon- ringColor={loadingRingColor}- size={14}- style={{ color: cssVar.colorWarning }}- />- );- }- if (isFailed) {- const visual = TOPIC_STATUS_VISUALS.failed;- return (- <Tooltip title={t('failedStatusTip')}>- <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />- </Tooltip>- );- }- // Unread is the third `pending` attention state (see `resolveStatusBucket`- // in `@lobechat/utils/client/topic`), so it ranks with its two siblings- // above β and above the PR marker, which shares this single icon slot.- if (hasUnread) return unreadIcon;- // Persisted execution state is the topic's primary status. Keep every- // non-idle state above git metadata so scheduled / paused / completed- // topics cannot be mistaken for merely open / merged / closed PRs.- // `running` is handled exclusively by shouldShowRunningIcon above so- // the masked post-output tail cannot fall back to a static running icon.- if (status && status !== 'active' && status !== 'running') {- const visual = TOPIC_STATUS_VISUALS[status];- return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;- }- // GitHub PR state marker (open=green, merged=purple, closed=red),- // like Codex. It is secondary metadata, so only an idle topic uses it- // as the leading icon.- if (metaCard?.pullRequest) {- const prVisual = PR_STATE_VISUAL[getPullRequestState(metaCard.pullRequest)];- return (- <Tooltip title={t(prVisual.labelKey)}>- <Icon icon={prVisual.icon} size={'small'} style={{ color: prVisual.color }} />- </Tooltip>- );- }- if (metadata?.bot?.platform) {- const ProviderIcon = getPlatformIcon(metadata.bot!.platform);- if (ProviderIcon) {- return <ProviderIcon color={cssVar.colorTextDescription} size={16} />;- }- }- return (- <Icon- icon={HashIcon}- size={'small'}- style={{- color: cssVar.colorTextDescription,- // Heterogeneous agents (Claude Code, Codex, β¦) have no chat-style- // topic semantics, so suppress the `#` glyph while keeping its- // box so the title stays aligned with sibling rows.- visibility: isHeterogeneousAgent ? 'hidden' : undefined,- }}- />- );- })()}onClick={handleClick}onDoubleClick={() => void handleDoubleClick()}onDragStart={handleDragStart}diff --git a/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsxindex a0ddef9a030..cddfcc392e7 100644--- a/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx+++ b/src/routes/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx@@ -14,7 +14,7 @@ import RingLoadingIcon from '@/components/RingLoading';import { isDesktop } from '@/const/version';import { useHasDraft } from '@/features/ChatInput/draftStorage';import NavItem from '@/features/NavPanel/components/NavItem';-import TopicCreatorAvatar from '@/features/TopicCreatorAvatar';+import TopicCreatorAvatar, { useTopicCreator } from '@/features/TopicCreatorAvatar';import { useFocusTopicPopup } from '@/features/TopicPopupGuard/useTopicPopupsRegistry';import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';import { useAgentGroupStore } from '@/store/agentGroup';@@ -100,6 +100,16 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId, statconst addTab = useElectronStore((s) => s.addTab);const activeWorkspaceSlug = useActiveWorkspaceSlug();const focusTopicPopup = useFocusTopicPopup({ groupId: activeGroupId });+ // A workspace-private group is a purely personal conversation space even+ // inside a workspace β its topics all belong to the viewer, so the creator+ // avatar carries no information there. Only workspace-shared (`public`)+ // groups get the avatar treatment.+ const isSharedGroup = useAgentGroupStore((s) =>+ s.activeGroupId ? s.groupMap[s.activeGroupId]?.visibility === 'public' : false,+ );+ // Creator of the topic β resolves only inside an active workspace; drives+ // the identity-first icon layout below.+ const author = useTopicCreator(isSharedGroup ? userId : undefined);// Construct href for cmd+click supportconst href = useMemo(() => {@@ -272,6 +282,37 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId, stat);}+ // Execution / attention state. In workspace mode this moves to the row's+ // trailing side so the leading slot can carry the creator identity.+ const statusIconNode = (() => {+ if (isWaitingForHuman) {+ const visual = TOPIC_STATUS_VISUALS.waitingForHuman;+ return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;+ }+ if (isLoading || isRunning) {+ return (+ <RingLoadingIcon+ ringColor={loadingRingColor}+ size={14}+ style={{ color: cssVar.colorWarning }}+ />+ );+ }+ if (isFailed) {+ const visual = TOPIC_STATUS_VISUALS.failed;+ return (+ <Tooltip title={t('failedStatusTip')}>+ <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />+ </Tooltip>+ );+ }+ if (isCompleted) {+ const visual = TOPIC_STATUS_VISUALS.completed;+ return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;+ }+ return null;+ })();+return (<Flexbox style={{ position: 'relative' }}><NavItem@@ -279,40 +320,21 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId, statactive={active && !threadId}contextMenuItems={dropdownMenu}disabled={editing}- extra={<TopicCreatorAvatar userId={userId} />}href={!editing ? href : undefined}title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}titleColor={cssVar.colorText}- icon={(() => {- if (isWaitingForHuman) {- const visual = TOPIC_STATUS_VISUALS.waitingForHuman;- return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;- }- if (isLoading || isRunning) {- return (- <RingLoadingIcon- ringColor={loadingRingColor}- size={14}- style={{ color: cssVar.colorWarning }}- />- );- }- if (isFailed) {- const visual = TOPIC_STATUS_VISUALS.failed;- return (- <Tooltip title={t('failedStatusTip')}>- <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />- </Tooltip>- );- }- if (isCompleted) {- const visual = TOPIC_STATUS_VISUALS.completed;- return <Icon icon={visual.icon} size={'small'} style={{ color: visual.color }} />;- }- return (- <Icon icon={HashIcon} size={'small'} style={{ color: cssVar.colorTextDescription }} />- );- })()}+ icon={+ // Workspace mode: the creator's round avatar is the primary visual;+ // the row's own status icon shrinks into a bottom-right corner+ // badge. Personal mode keeps the original status-first layout.+ author ? (+ <TopicCreatorAvatar corner={statusIconNode} userId={userId} />+ ) : (+ (statusIconNode ?? (+ <Icon icon={HashIcon} size={'small'} style={{ color: cssVar.colorTextDescription }} />+ ))+ )+ }slots={{iconPostfix: unreadNode,titlePrefix: draftPrefix,