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): refine context menu grouping (#17642)

AmAzing-84ed68825cc1
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
index 22099ac839c..a3c97b993b0 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.test.tsx
@@ -10,6 +10,7 @@ const permissionMock = vi.hoisted(() => ({
create_content: true,
edit_own_content: true,
}));
+const versionMock = vi.hoisted(() => ({ isDesktop: false }));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
@@ -39,7 +40,9 @@ vi.mock('@/components/RenameModal', () => ({
}));
vi.mock('@/const/version', () => ({
- isDesktop: false,
+ get isDesktop() {
+ return versionMock.isDesktop;
+ },
}));
vi.mock('@/features/Electron/titlebar/RecentlyViewed/plugins', () => ({
@@ -104,6 +107,40 @@ describe('useTopicItemDropdownMenu', () => {
beforeEach(() => {
permissionMock.create_content = true;
permissionMock.edit_own_content = true;
+ versionMock.isDesktop = false;
+ });
+
+ it('groups desktop topic actions by intent', () => {
+ versionMock.isDesktop = true;
+
+ const { result } = renderHook(() =>
+ useTopicItemDropdownMenu({ id: 'topic-1', title: 'Topic 1' }),
+ );
+ const items = result.current.dropdownMenu();
+
+ expect(items.map((item) => (item && 'key' in item ? item.key : 'divider'))).toEqual([
+ 'markCompleted',
+ 'favorite',
+ 'divider',
+ 'autoRename',
+ 'rename',
+ 'diagnose',
+ 'divider',
+ 'openInNewTab',
+ 'openInNewWindow',
+ 'divider',
+ 'copySessionId',
+ 'copyLink',
+ 'divider',
+ 'duplicate',
+ 'forwardToAgent',
+ 'moveToAgent',
+ 'divider',
+ 'share',
+ 'divider',
+ 'delete',
+ ]);
+ expect(getMenuItem(items, 'share')).toMatchObject({ label: 'shareModal.title' });
});
it('disables topic management actions for workspace viewers', () => {
diff --git a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
index 14cf13a114c..5ac90a659d7 100644
--- a/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/useDropdownMenu.tsx
@@ -6,6 +6,7 @@ import { App } from 'antd';
import {
Archive,
ArchiveRestore,
+ Download,
ExternalLink,
FolderInput,
Forward,
@@ -14,7 +15,6 @@ import {
LucideCopy,
PanelTop,
PencilLine,
- Share2,
Star,
Stethoscope,
Trash,
@@ -54,7 +54,7 @@ export const useTopicItemDropdownMenu = ({
status,
title,
}: TopicItemDropdownMenuProps) => {
- const { t } = useTranslation(['topic', 'common']);
+ const { t } = useTranslation(['topic', 'common', 'chat']);
const { message } = App.useApp();
const navigate = useWorkspaceAwareNavigate();
const activeWorkspaceSlug = useActiveWorkspaceSlug();
@@ -108,9 +108,6 @@ export const useTopicItemDropdownMenu = ({
}
},
},
- {
- type: 'divider' as const,
- },
{
disabled: !canEditTopic,
icon: <Icon icon={Star} />,
@@ -217,6 +214,9 @@ export const useTopicItemDropdownMenu = ({
message.success(t('actions.copyLinkSuccess'));
},
},
+ {
+ type: 'divider' as const,
+ },
{
disabled: !canCreateTopic,
icon: <Icon icon={LucideCopy} />,
@@ -250,9 +250,9 @@ export const useTopicItemDropdownMenu = ({
},
{
disabled: !canEditTopic,
- icon: <Icon icon={Share2} />,
+ icon: <Icon icon={Download} />,
key: 'share',
- label: t('share', { ns: 'common' }),
+ label: t('shareModal.title', { ns: 'chat' }),
onClick: handleOpenShareModal,
},
{