🤯 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
🐛 fix(topic): hide bot initiator avatar outside a workspace (#21043)
Arvin Xue47e53ece377
diff --git a/src/features/TopicCreatorAvatar/index.test.tsx b/src/features/TopicCreatorAvatar/index.test.tsxindex 9f73d2b5a46..5270ef18484 100644--- a/src/features/TopicCreatorAvatar/index.test.tsx+++ b/src/features/TopicCreatorAvatar/index.test.tsx@@ -2,15 +2,19 @@* @vitest-environment happy-dom*/import { render } from '@testing-library/react';-import { describe, expect, it, vi } from 'vitest';+import { beforeEach, describe, expect, it, vi } from 'vitest';import TopicCreatorAvatar from './index';const useAuthorInfoMock = vi.hoisted(() => vi.fn());+const hasActiveWorkspaceMock = vi.hoisted(() => ({ value: true }));vi.mock('@/business/client/hooks/useAuthorInfo', () => ({useAuthorInfo: useAuthorInfoMock,}));+vi.mock('@/business/client/hooks/useHasActiveWorkspace', () => ({+ useHasActiveWorkspace: () => hasActiveWorkspaceMock.value,+}));// The identity-preserving wrapper owns the initials/background fallback; this// component's contract is only what it hands over.@@ -37,6 +41,24 @@ vi.mock('@/components/Avatar', () => ({}));describe('TopicCreatorAvatar', () => {+ beforeEach(() => {+ hasActiveWorkspaceMock.value = true;+ });++ it('hides the bot conversation initiator in personal mode', () => {+ hasActiveWorkspaceMock.value = false;+ useAuthorInfoMock.mockReturnValue(undefined);+ const { queryByTestId } = render(+ <TopicCreatorAvatar+ botCreator={{ id: '123', platform: 'wechat', avatar: 'sender.png', fullName: 'ow' }}+ corner={<span data-testid="platform-icon" />}+ userId="owner"+ />,+ );+ expect(queryByTestId('avatar')).toBeNull();+ expect(queryByTestId('platform-icon')).toBeNull();+ });+it('shows the bot conversation initiator instead of the workspace bot owner', () => {useAuthorInfoMock.mockReturnValue({ avatar: 'owner.png', fullName: 'Bot owner' });const { getByTestId } = render(diff --git a/src/features/TopicCreatorAvatar/index.tsx b/src/features/TopicCreatorAvatar/index.tsxindex 1511e4591e0..74130f0a877 100644--- a/src/features/TopicCreatorAvatar/index.tsx+++ b/src/features/TopicCreatorAvatar/index.tsx@@ -5,16 +5,20 @@ import { cssVar, Tooltip } from '@lobehub/ui';import { memo, type ReactNode } from 'react';import { useAuthorInfo } from '@/business/client/hooks/useAuthorInfo';+import { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';import Avatar from '@/components/Avatar';/*** Prefer the bot-channel initiator over the account that owns the bot.* Ordinary topics resolve their creator from active workspace members; the* open-source business slot returns undefined for those member profiles.+ * Creator identity is a workspace-only cue, so personal mode ignores the bot+ * initiator too and the row keeps its own platform icon.*/export const useTopicCreator = (userId?: string, botCreator?: BotSenderMetadata | null) => {const author = useAuthorInfo(userId);- return botCreator+ const hasActiveWorkspace = useHasActiveWorkspace();+ return botCreator && hasActiveWorkspace? {avatar: botCreator.avatar,fullName: botCreator.fullName || botCreator.username || botCreator.id,