Skip to content

🀯 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.

πŸ’„ style(topic): hide creator avatar when only my topics are shown (#21528)

Arvin Xu788348259196
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
index 658e9878408..2ac99900c73 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
@@ -3,7 +3,7 @@
*/
import { render, screen, waitFor } from '@testing-library/react';
import type { ReactNode } from 'react';
-import { afterEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { TopicListScopeContext } from '../../TopicListScope';
import TopicItem from './index';
@@ -17,6 +17,8 @@ const activeTopicIdMock = vi.hoisted(() => ({ value: undefined as string | undef
const agentRuntimeRunningMock = vi.hoisted(() => ({ value: false }));
const runningStartTimeMock = vi.hoisted(() => ({ value: undefined as number | undefined }));
const topicUnreadCompletedMock = vi.hoisted(() => ({ value: false }));
+const onlyMineMock = vi.hoisted(() => ({ value: false }));
+const currentUserIdMock = vi.hoisted(() => ({ value: 'user-1' as string | undefined }));
const topicMetaCardMock = vi.hoisted(() => ({
value: undefined as
| { pullRequest?: { ciStatus?: 'failure' | 'pending' | 'success' | 'unknown'; state: string } }
@@ -92,7 +94,25 @@ vi.mock('@/store/agent', () => ({
agentMap: Record<string, unknown>;
builtinAgentIdMap: Record<string, string>;
}) => unknown,
- ) => selector({ activeAgentId: 'agt_test', agentMap: {}, builtinAgentIdMap: {} }),
+ ) =>
+ selector({
+ activeAgentId: 'agt_test',
+ agentMap: { agt_test: { visibility: 'public' } },
+ builtinAgentIdMap: {},
+ }),
+}));
+vi.mock('@/store/user', () => ({
+ useUserStore: (selector: (state: unknown) => unknown) => selector({}),
+}));
+vi.mock('@/store/user/selectors', () => ({
+ userProfileSelectors: { userId: () => currentUserIdMock.value },
+}));
+vi.mock('@/hooks/useTopicOnlyMine', () => ({ useTopicOnlyMine: () => onlyMineMock.value }));
+vi.mock('@/features/TopicCreatorAvatar', () => ({
+ default: ({ userId }: { userId?: string }) => (
+ <div data-testid="creator-avatar" data-user-id={userId} />
+ ),
+ useTopicCreator: (userId?: string) => (userId ? { fullName: 'Member' } : undefined),
}));
vi.mock('@/store/chat', () => {
const useChatStore = (
@@ -166,9 +186,46 @@ describe('TopicItem active state', () => {
runningStartTimeMock.value = undefined;
topicUnreadCompletedMock.value = false;
topicMetaCardMock.value = undefined;
+ onlyMineMock.value = false;
+ currentUserIdMock.value = 'user-1';
vi.useRealTimers();
});
+ describe('creator avatar', () => {
+ beforeEach(() => {
+ useTopicNavigationMock.mockReturnValue({
+ focusTopicPopup: vi.fn(),
+ isInAgentSubRoute: false,
+ isInTopicContextRoute: false,
+ navigateToTopic: vi.fn(),
+ routeTopicId: undefined,
+ urlTopicId: undefined,
+ });
+ });
+
+ it('shows the creator avatar on a shared agent topic', () => {
+ render(<TopicItem id="tpc_test" title="Topic" userId="user-1" />);
+
+ expect(screen.getByTestId('creator-avatar')).toHaveAttribute('data-user-id', 'user-1');
+ });
+
+ it('hides the creator avatar on my own topic when only my topics are shown', () => {
+ onlyMineMock.value = true;
+
+ render(<TopicItem id="tpc_test" title="Topic" userId="user-1" />);
+
+ expect(screen.queryByTestId('creator-avatar')).not.toBeInTheDocument();
+ });
+
+ it('keeps the creator avatar on a retained teammate topic when only my topics are shown', () => {
+ onlyMineMock.value = true;
+
+ render(<TopicItem id="tpc_test" title="Topic" userId="user-2" />);
+
+ expect(screen.getByTestId('creator-avatar')).toHaveAttribute('data-user-id', 'user-2');
+ });
+ });
+
it('renders the Project row Agent avatar and keeps its link in the Project', () => {
scopedTopicMock.value = {
agentId: 'other-agent',
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index 3f05f655165..056344e8b86 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -41,11 +41,14 @@ import { getProjectConversationPath } from '@/features/Projects/Layout/navigatio
import TopicCreatorAvatar, { useTopicCreator } from '@/features/TopicCreatorAvatar';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
import { getWorkingDirectoryName } from '@/helpers/workingDirectoryPath';
+import { useTopicOnlyMine } from '@/hooks/useTopicOnlyMine';
import { useAgentStore } from '@/store/agent';
import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
import { operationSelectors } from '@/store/chat/selectors';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
+import { useUserStore } from '@/store/user';
+import { userProfileSelectors } from '@/store/user/selectors';
import { markSidebarTopicActivation } from '../../hooks/useScrollActiveTopicIntoView';
import { useTopicNavigation } from '../../hooks/useTopicNavigation';
@@ -279,10 +282,16 @@ const TopicItemRow = memo<TopicItemRowProps>(
const activeWorkspaceSlug = useActiveWorkspaceSlug();
// Creator of the topic β€” resolves only inside an active workspace; drives
// the identity-first icon layout below.
- const author = useTopicCreator(
- isSharedAgent && !metadata?.bot ? userId : undefined,
- metadata?.botCreator,
- );
+ // "Only my topics" makes the viewer's own rows self-evident, so the creator
+ // avatar carries no information there β€” drop it and fall back to the
+ // personal-mode row. A teammate's topic can still be listed (the active
+ // topic is retained under the filter) and keeps its ownership cue. Bot
+ // topics still resolve their initiator via `botCreator`.
+ const onlyMine = useTopicOnlyMine();
+ const currentUserId = useUserStore(userProfileSelectors.userId);
+ const hideOwnCreator = onlyMine && userId === currentUserId;
+ const creatorUserId = isSharedAgent && !metadata?.bot && !hideOwnCreator ? userId : undefined;
+ const author = useTopicCreator(creatorUserId, metadata?.botCreator);
const loadingRingColor = isDarkMode
? cssVar.colorWarningBorder
@@ -574,7 +583,7 @@ const TopicItemRow = memo<TopicItemRowProps>(
<TopicCreatorAvatar
botCreator={metadata?.botCreator}
corner={ownIconNode}
- userId={userId}
+ userId={creatorUserId}
/>
) : (
(ownIconNode ?? idleIconPlaceholder)