@lobehub/lobehub 2.0.0-next.187 → 2.0.0-next.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/changelog/v1.json +18 -0
- package/e2e/CLAUDE.md +109 -2
- package/e2e/docs/llm-mock.md +68 -0
- package/e2e/docs/local-setup.md +354 -0
- package/e2e/docs/testing-tips.md +94 -0
- package/e2e/src/features/journeys/agent/agent-conversation.feature +0 -32
- package/e2e/src/mocks/llm/index.ts +6 -6
- package/e2e/src/steps/agent/conversation.steps.ts +3 -471
- package/locales/ar/models.json +89 -5
- package/locales/ar/plugin.json +5 -0
- package/locales/ar/providers.json +1 -0
- package/locales/bg-BG/models.json +68 -0
- package/locales/bg-BG/plugin.json +5 -0
- package/locales/bg-BG/providers.json +1 -0
- package/locales/de-DE/models.json +85 -0
- package/locales/de-DE/plugin.json +5 -0
- package/locales/de-DE/providers.json +1 -0
- package/locales/en-US/models.json +11 -10
- package/locales/en-US/plugin.json +5 -0
- package/locales/en-US/providers.json +1 -0
- package/locales/es-ES/models.json +72 -0
- package/locales/es-ES/plugin.json +5 -0
- package/locales/es-ES/providers.json +1 -0
- package/locales/fa-IR/models.json +86 -0
- package/locales/fa-IR/plugin.json +5 -0
- package/locales/fa-IR/providers.json +1 -0
- package/locales/fr-FR/models.json +49 -0
- package/locales/fr-FR/plugin.json +5 -0
- package/locales/fr-FR/providers.json +1 -0
- package/locales/it-IT/models.json +82 -0
- package/locales/it-IT/plugin.json +5 -0
- package/locales/it-IT/providers.json +1 -0
- package/locales/ja-JP/models.json +42 -5
- package/locales/ja-JP/plugin.json +5 -0
- package/locales/ja-JP/providers.json +1 -0
- package/locales/ko-KR/models.json +54 -0
- package/locales/ko-KR/plugin.json +5 -0
- package/locales/ko-KR/providers.json +1 -0
- package/locales/nl-NL/models.json +12 -1
- package/locales/nl-NL/plugin.json +5 -0
- package/locales/nl-NL/providers.json +1 -0
- package/locales/pl-PL/models.json +46 -0
- package/locales/pl-PL/plugin.json +5 -0
- package/locales/pl-PL/providers.json +1 -0
- package/locales/pt-BR/models.json +59 -0
- package/locales/pt-BR/plugin.json +5 -0
- package/locales/pt-BR/providers.json +1 -0
- package/locales/ru-RU/models.json +85 -0
- package/locales/ru-RU/plugin.json +5 -0
- package/locales/ru-RU/providers.json +1 -0
- package/locales/tr-TR/models.json +81 -0
- package/locales/tr-TR/plugin.json +5 -0
- package/locales/tr-TR/providers.json +1 -0
- package/locales/vi-VN/models.json +54 -0
- package/locales/vi-VN/plugin.json +5 -0
- package/locales/vi-VN/providers.json +1 -0
- package/locales/zh-CN/models.json +42 -5
- package/locales/zh-CN/plugin.json +5 -0
- package/locales/zh-CN/providers.json +1 -0
- package/locales/zh-TW/models.json +85 -0
- package/locales/zh-TW/plugin.json +5 -0
- package/locales/zh-TW/providers.json +1 -0
- package/package.json +2 -2
- package/packages/builtin-tool-gtd/src/manifest.ts +13 -8
- package/packages/builtin-tool-gtd/src/systemRole.ts +54 -19
- package/packages/builtin-tool-knowledge-base/package.json +1 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +97 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +75 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/index.ts +11 -0
- package/packages/builtin-tool-knowledge-base/src/client/Render/ReadKnowledge/FileCard.tsx +12 -12
- package/packages/builtin-tool-knowledge-base/src/client/Render/ReadKnowledge/index.tsx +16 -25
- package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/Item/index.tsx +21 -47
- package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/index.tsx +19 -31
- package/packages/builtin-tool-knowledge-base/src/client/Render/index.ts +0 -5
- package/packages/builtin-tool-knowledge-base/src/client/index.ts +5 -1
- package/packages/builtin-tool-knowledge-base/src/executor/index.ts +119 -0
- package/packages/builtin-tool-local-system/package.json +1 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +44 -29
- package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +20 -18
- package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +76 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +8 -32
- package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +62 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +17 -11
- package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +61 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/index.ts +6 -0
- package/packages/builtin-tool-local-system/src/client/Render/EditLocalFile/index.tsx +6 -1
- package/packages/builtin-tool-local-system/src/client/Render/SearchFiles/SearchQuery/SearchView.tsx +19 -31
- package/packages/builtin-tool-local-system/src/client/Render/SearchFiles/SearchQuery/index.tsx +2 -42
- package/packages/builtin-tool-local-system/src/client/Render/index.ts +0 -2
- package/packages/builtin-tool-local-system/src/client/components/FilePathDisplay.tsx +56 -0
- package/packages/builtin-tool-local-system/src/client/components/index.ts +2 -0
- package/packages/builtin-tool-local-system/src/executor/index.ts +435 -0
- package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +32 -5
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +84 -0
- package/packages/model-runtime/src/core/contextBuilders/google.ts +37 -1
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/List/Item/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/List/Item/index.tsx +23 -29
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/List/Item/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx +10 -18
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/ActionButton/AddAgent.tsx +47 -27
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentCard.tsx +4 -3
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/List/Item/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx +23 -29
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/List/Item/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx +10 -18
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx +18 -20
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentGroupItem/index.tsx +19 -25
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentItem/index.tsx +21 -26
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Item/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Item/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/Item.tsx +8 -15
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/home/_layout/Header/components/AddButton.tsx +3 -4
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/index.tsx +13 -20
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/Item/Actions.tsx +4 -13
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/Item/index.tsx +16 -23
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/Item/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx +4 -6
- package/src/features/AgentBuilder/TopicSelector.tsx +18 -17
- package/src/features/Conversation/ChatItem/style.ts +7 -0
- package/src/features/Conversation/Messages/Assistant/Actions/Error.tsx +1 -3
- package/src/features/Conversation/Messages/Assistant/Actions/index.tsx +37 -16
- package/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx +36 -17
- package/src/features/Conversation/Messages/Supervisor/Actions/index.tsx +36 -17
- package/src/features/Conversation/Messages/Task/Actions/Error.tsx +1 -3
- package/src/features/Conversation/Messages/Task/Actions/index.tsx +31 -15
- package/src/features/Conversation/Messages/User/Actions/index.tsx +1 -1
- package/src/features/Conversation/Messages/index.tsx +8 -59
- package/src/features/Conversation/components/ShareMessageModal/index.tsx +1 -1
- package/src/features/Conversation/hooks/useChatItemContextMenu.tsx +313 -83
- package/src/features/NavPanel/components/NavItem.tsx +33 -3
- package/src/features/PageEditor/Copilot/TopicSelector/Actions.tsx +6 -14
- package/src/features/PageEditor/Copilot/TopicSelector/TopicItem.tsx +1 -0
- package/src/features/PageEditor/Copilot/TopicSelector/useDropdownMenu.tsx +6 -3
- package/src/features/ResourceManager/components/Explorer/ItemDropdown/DropdownMenu.tsx +12 -35
- package/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx +4 -8
- package/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx +162 -160
- package/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx +16 -8
- package/src/features/ResourceManager/components/Explorer/ToolBar/ActionIconWithChevron.tsx +4 -3
- package/src/features/ResourceManager/components/Explorer/ToolBar/BatchActionsDropdown.tsx +6 -12
- package/src/features/ResourceManager/components/Explorer/ToolBar/SortDropdown.tsx +8 -8
- package/src/features/ResourceManager/components/Explorer/ToolBar/ViewSwitcher.tsx +8 -11
- package/src/features/ResourceManager/components/Tree/index.tsx +121 -122
- package/src/helpers/toolEngineering/index.ts +1 -1
- package/src/layout/GlobalProvider/index.tsx +5 -2
- package/src/locales/default/plugin.ts +6 -0
- package/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts +1 -1
- package/src/server/modules/Mecha/AgentToolsEngine/index.ts +1 -1
- package/src/store/chat/slices/builtinTool/actions/index.ts +1 -11
- package/src/store/tool/slices/builtin/executors/index.ts +4 -0
- package/src/styles/global.ts +6 -0
- package/src/styles/text.ts +1 -1
- package/src/tools/executionRuntimes.ts +3 -8
- package/src/tools/identifiers.ts +1 -1
- package/src/tools/index.ts +1 -1
- package/src/tools/inspectors.ts +5 -0
- package/src/tools/renders.ts +6 -12
- package/packages/builtin-tool-local-system/src/client/Render/RenameLocalFile/index.tsx +0 -37
- package/src/features/Conversation/components/ContextMenu.tsx +0 -418
- package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +0 -201
- package/src/store/chat/slices/builtinTool/actions/knowledgeBase.ts +0 -163
- package/src/store/chat/slices/builtinTool/actions/localSystem.ts +0 -241
- package/src/tools/knowledge-base/ExecutionRuntime/index.ts +0 -25
- package/src/tools/knowledge-base/Render/ReadKnowledge/index.tsx +0 -29
- package/src/tools/knowledge-base/Render/SearchKnowledgeBase/index.tsx +0 -29
- package/src/tools/knowledge-base/Render/index.ts +0 -7
- package/src/tools/knowledge-base/index.ts +0 -12
- package/src/tools/local-system/ExecutionRuntime/index.ts +0 -9
- package/src/tools/local-system/systemRole.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SESSION_CHAT_URL } from '@lobechat/const';
|
|
2
2
|
import type { SidebarAgentItem } from '@lobechat/types';
|
|
3
|
-
import { ActionIcon,
|
|
3
|
+
import { ActionIcon, Icon } from '@lobehub/ui';
|
|
4
4
|
import { cssVar } from 'antd-style';
|
|
5
5
|
import { Loader2, PinIcon } from 'lucide-react';
|
|
6
6
|
import { type CSSProperties, type DragEvent, memo, useCallback, useMemo } from 'react';
|
|
@@ -96,7 +96,7 @@ const AgentItem = memo<AgentItemProps>(({ item, style, className }) => {
|
|
|
96
96
|
return <Avatar avatar={typeof avatar === 'string' ? avatar : undefined} />;
|
|
97
97
|
}, [isUpdating, avatar]);
|
|
98
98
|
|
|
99
|
-
const dropdownMenu
|
|
99
|
+
const dropdownMenu = useDropdownMenu({
|
|
100
100
|
group: undefined, // TODO: pass group from parent if needed
|
|
101
101
|
id,
|
|
102
102
|
openCreateGroupModal: handleOpenCreateGroupModal,
|
|
@@ -108,30 +108,25 @@ const AgentItem = memo<AgentItemProps>(({ item, style, className }) => {
|
|
|
108
108
|
|
|
109
109
|
return (
|
|
110
110
|
<>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
style={style}
|
|
131
|
-
title={displayTitle}
|
|
132
|
-
/>
|
|
133
|
-
</Link>
|
|
134
|
-
</Dropdown>
|
|
111
|
+
<Link aria-label={id} to={agentUrl}>
|
|
112
|
+
<NavItem
|
|
113
|
+
actions={<Actions dropdownMenu={dropdownMenu} />}
|
|
114
|
+
className={className}
|
|
115
|
+
contextMenuItems={dropdownMenu}
|
|
116
|
+
disabled={editing || isUpdating}
|
|
117
|
+
draggable={!editing && !isUpdating}
|
|
118
|
+
extra={pinIcon}
|
|
119
|
+
icon={avatarIcon}
|
|
120
|
+
key={id}
|
|
121
|
+
loading={isLoading}
|
|
122
|
+
onDoubleClick={handleDoubleClick}
|
|
123
|
+
onDragEnd={handleDragEnd}
|
|
124
|
+
onDragStart={handleDragStart}
|
|
125
|
+
style={style}
|
|
126
|
+
title={displayTitle}
|
|
127
|
+
/>
|
|
128
|
+
</Link>
|
|
129
|
+
|
|
135
130
|
<Editing
|
|
136
131
|
avatar={typeof avatar === 'string' ? avatar : undefined}
|
|
137
132
|
id={id}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { ActionIcon,
|
|
1
|
+
import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
|
|
2
2
|
import { MoreHorizontalIcon } from 'lucide-react';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ActionProps {
|
|
6
|
-
dropdownMenu:
|
|
6
|
+
dropdownMenu: DropdownItem[] | (() => DropdownItem[]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const Actions = memo<ActionProps>(({ dropdownMenu }) => {
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
12
|
-
arrow={false}
|
|
13
|
-
menu={{
|
|
14
|
-
items: dropdownMenu,
|
|
15
|
-
onClick: ({ domEvent }) => {
|
|
16
|
-
domEvent.stopPropagation();
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
trigger={['click']}
|
|
20
|
-
>
|
|
11
|
+
<DropdownMenu items={dropdownMenu}>
|
|
21
12
|
<ActionIcon icon={MoreHorizontalIcon} size={'small'} />
|
|
22
|
-
</
|
|
13
|
+
</DropdownMenu>
|
|
23
14
|
);
|
|
24
15
|
});
|
|
25
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MenuProps } from '@lobehub/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
import { useSessionItemMenuItems } from '../../../../hooks';
|
|
5
5
|
|
|
@@ -21,7 +21,7 @@ export const useDropdownMenu = ({
|
|
|
21
21
|
pinned,
|
|
22
22
|
sessionType,
|
|
23
23
|
toggleEditing,
|
|
24
|
-
}: ActionProps): MenuProps['items'] => {
|
|
24
|
+
}: ActionProps): (() => MenuProps['items']) => {
|
|
25
25
|
const {
|
|
26
26
|
pinMenuItem,
|
|
27
27
|
renameMenuItem,
|
|
@@ -31,7 +31,7 @@ export const useDropdownMenu = ({
|
|
|
31
31
|
deleteMenuItem,
|
|
32
32
|
} = useSessionItemMenuItems();
|
|
33
33
|
|
|
34
|
-
return
|
|
34
|
+
return useCallback(
|
|
35
35
|
() =>
|
|
36
36
|
[
|
|
37
37
|
pinMenuItem(id, pinned, parentType),
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { ActionIcon,
|
|
1
|
+
import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
|
|
2
2
|
import { MoreHorizontalIcon } from 'lucide-react';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ActionsProps {
|
|
6
|
-
dropdownMenu:
|
|
6
|
+
dropdownMenu: DropdownItem[] | (() => DropdownItem[]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const Actions = memo<ActionsProps>(({ dropdownMenu }) => {
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
12
|
-
arrow={false}
|
|
13
|
-
menu={{
|
|
14
|
-
items: dropdownMenu,
|
|
15
|
-
onClick: ({ domEvent }) => {
|
|
16
|
-
domEvent.stopPropagation();
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
trigger={['click']}
|
|
20
|
-
>
|
|
11
|
+
<DropdownMenu items={dropdownMenu}>
|
|
21
12
|
<ActionIcon icon={MoreHorizontalIcon} size={'small'} />
|
|
22
|
-
</
|
|
13
|
+
</DropdownMenu>
|
|
23
14
|
);
|
|
24
15
|
});
|
|
25
16
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Dropdown } from '@lobehub/ui';
|
|
2
1
|
import { BoxIcon } from 'lucide-react';
|
|
3
2
|
import { memo, useCallback } from 'react';
|
|
4
3
|
|
|
@@ -39,20 +38,14 @@ const ProjectItem = memo<ProjectItemProps>(({ id, name }) => {
|
|
|
39
38
|
|
|
40
39
|
return (
|
|
41
40
|
<>
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
disabled={editing || isUpdating}
|
|
51
|
-
icon={BoxIcon}
|
|
52
|
-
loading={isLoading || isUpdating}
|
|
53
|
-
title={name}
|
|
54
|
-
/>
|
|
55
|
-
</Dropdown>
|
|
41
|
+
<NavItem
|
|
42
|
+
actions={<Actions dropdownMenu={dropdownMenu} />}
|
|
43
|
+
contextMenuItems={dropdownMenu}
|
|
44
|
+
disabled={editing || isUpdating}
|
|
45
|
+
icon={BoxIcon}
|
|
46
|
+
loading={isLoading || isUpdating}
|
|
47
|
+
title={name}
|
|
48
|
+
/>
|
|
56
49
|
<Editing id={id} name={name} toggleEditing={toggleEditing} />
|
|
57
50
|
</>
|
|
58
51
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Icon, type MenuProps } from '@lobehub/ui';
|
|
2
2
|
import { App } from 'antd';
|
|
3
3
|
import { PencilLine, Trash } from 'lucide-react';
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
|
@@ -14,12 +14,12 @@ interface ProjectItemDropdownMenuProps {
|
|
|
14
14
|
export const useProjectItemDropdownMenu = ({
|
|
15
15
|
id,
|
|
16
16
|
toggleEditing,
|
|
17
|
-
}: ProjectItemDropdownMenuProps): MenuProps['items'] => {
|
|
17
|
+
}: ProjectItemDropdownMenuProps): (() => MenuProps['items']) => {
|
|
18
18
|
const { t } = useTranslation(['home', 'common']);
|
|
19
19
|
const [removeKnowledgeBase] = useKnowledgeBaseStore((s) => [s.removeKnowledgeBase]);
|
|
20
20
|
const { modal } = App.useApp();
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return useCallback(
|
|
23
23
|
() => [
|
|
24
24
|
{
|
|
25
25
|
icon: <Icon icon={PencilLine} />,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ActionIcon, Flexbox } from '@lobehub/ui';
|
|
1
|
+
import { ActionIcon, DropdownMenu, Flexbox } from '@lobehub/ui';
|
|
2
2
|
import { CreateBotIcon } from '@lobehub/ui/icons';
|
|
3
|
-
import { Dropdown } from 'antd';
|
|
4
3
|
import { cssVar } from 'antd-style';
|
|
5
4
|
import { ChevronDownIcon } from 'lucide-react';
|
|
6
5
|
import React, { memo, useCallback, useMemo } from 'react';
|
|
@@ -45,7 +44,7 @@ const AddButton = memo(() => {
|
|
|
45
44
|
size={DESKTOP_HEADER_ICON_SIZE}
|
|
46
45
|
title={tChat('newAgent')}
|
|
47
46
|
/>
|
|
48
|
-
<
|
|
47
|
+
<DropdownMenu items={dropdownItems}>
|
|
49
48
|
<ActionIcon
|
|
50
49
|
color={cssVar.colorTextQuaternary}
|
|
51
50
|
icon={ChevronDownIcon}
|
|
@@ -54,7 +53,7 @@ const AddButton = memo(() => {
|
|
|
54
53
|
width: 16,
|
|
55
54
|
}}
|
|
56
55
|
/>
|
|
57
|
-
</
|
|
56
|
+
</DropdownMenu>
|
|
58
57
|
</Flexbox>
|
|
59
58
|
);
|
|
60
59
|
});
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { ActionIcon,
|
|
1
|
+
import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
|
|
2
2
|
import { MoreHorizontalIcon } from 'lucide-react';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ActionProps {
|
|
6
|
-
dropdownMenu:
|
|
6
|
+
dropdownMenu: DropdownItem[] | (() => DropdownItem[]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const Actions = memo<ActionProps>(({ dropdownMenu }) => {
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
12
|
-
arrow={false}
|
|
13
|
-
menu={{
|
|
14
|
-
items: dropdownMenu,
|
|
15
|
-
onClick: ({ domEvent }) => {
|
|
16
|
-
domEvent.stopPropagation();
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
trigger={['click']}
|
|
20
|
-
>
|
|
11
|
+
<DropdownMenu items={dropdownMenu}>
|
|
21
12
|
<ActionIcon icon={MoreHorizontalIcon} size={'small'} />
|
|
22
|
-
</
|
|
13
|
+
</DropdownMenu>
|
|
23
14
|
);
|
|
24
15
|
});
|
|
25
16
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Avatar
|
|
2
|
-
import { Dropdown } from '@lobehub/ui';
|
|
1
|
+
import { Avatar } from '@lobehub/ui';
|
|
3
2
|
import { FileTextIcon } from 'lucide-react';
|
|
4
3
|
import { memo, useCallback, useMemo } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
@@ -56,7 +55,7 @@ const PageListItem = memo<DocumentItemProps>(({ pageId, className }) => {
|
|
|
56
55
|
return FileTextIcon;
|
|
57
56
|
}, [emoji]);
|
|
58
57
|
|
|
59
|
-
const dropdownMenu
|
|
58
|
+
const dropdownMenu = useDropdownMenu({
|
|
60
59
|
documentContent: document?.content || undefined,
|
|
61
60
|
pageId,
|
|
62
61
|
toggleEditing,
|
|
@@ -64,23 +63,17 @@ const PageListItem = memo<DocumentItemProps>(({ pageId, className }) => {
|
|
|
64
63
|
|
|
65
64
|
return (
|
|
66
65
|
<>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
icon={icon}
|
|
79
|
-
key={pageId}
|
|
80
|
-
onClick={handleClick}
|
|
81
|
-
title={title}
|
|
82
|
-
/>
|
|
83
|
-
</Dropdown>
|
|
66
|
+
<NavItem
|
|
67
|
+
actions={<Actions dropdownMenu={dropdownMenu} />}
|
|
68
|
+
active={active}
|
|
69
|
+
className={className}
|
|
70
|
+
contextMenuItems={dropdownMenu}
|
|
71
|
+
disabled={editing}
|
|
72
|
+
icon={icon}
|
|
73
|
+
key={pageId}
|
|
74
|
+
onClick={handleClick}
|
|
75
|
+
title={title}
|
|
76
|
+
/>
|
|
84
77
|
<Editing
|
|
85
78
|
currentEmoji={emoji}
|
|
86
79
|
documentId={pageId}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Icon, type MenuProps } from '@lobehub/ui';
|
|
2
2
|
import { App } from 'antd';
|
|
3
3
|
import { Copy, CopyPlus, Pencil, Trash2 } from 'lucide-react';
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import { useFileStore } from '@/store/file';
|
|
@@ -16,7 +16,7 @@ export const useDropdownMenu = ({
|
|
|
16
16
|
documentContent,
|
|
17
17
|
pageId,
|
|
18
18
|
toggleEditing,
|
|
19
|
-
}: ActionProps): MenuProps['items'] => {
|
|
19
|
+
}: ActionProps): (() => MenuProps['items']) => {
|
|
20
20
|
const { t } = useTranslation(['common', 'file']);
|
|
21
21
|
const { message, modal } = App.useApp();
|
|
22
22
|
const removeDocument = useFileStore((s) => s.removeDocument);
|
|
@@ -59,7 +59,7 @@ export const useDropdownMenu = ({
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
return
|
|
62
|
+
return useCallback(
|
|
63
63
|
() =>
|
|
64
64
|
[
|
|
65
65
|
{
|
package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/Item/Actions.tsx
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { ActionIcon,
|
|
1
|
+
import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
|
|
2
2
|
import { MoreHorizontalIcon } from 'lucide-react';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ActionProps {
|
|
6
|
-
dropdownMenu:
|
|
6
|
+
dropdownMenu: DropdownItem[] | (() => DropdownItem[]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const Actions = memo<ActionProps>(({ dropdownMenu }) => {
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
12
|
-
arrow={false}
|
|
13
|
-
menu={{
|
|
14
|
-
items: dropdownMenu,
|
|
15
|
-
onClick: ({ domEvent }) => {
|
|
16
|
-
domEvent.stopPropagation();
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
trigger={['click']}
|
|
20
|
-
>
|
|
11
|
+
<DropdownMenu items={dropdownMenu}>
|
|
21
12
|
<ActionIcon icon={MoreHorizontalIcon} size={'small'} />
|
|
22
|
-
</
|
|
13
|
+
</DropdownMenu>
|
|
23
14
|
);
|
|
24
15
|
});
|
|
25
16
|
|
package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/Item/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Icon
|
|
2
|
-
import { Dropdown } from '@lobehub/ui';
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
|
3
2
|
import { cssVar } from 'antd-style';
|
|
4
3
|
import { Loader2Icon } from 'lucide-react';
|
|
5
4
|
import React, { type CSSProperties, memo, useCallback, useMemo } from 'react';
|
|
@@ -66,33 +65,27 @@ const KnowledgeBaseItem = memo<KnowledgeBaseItemProps>(({ id, name, active, styl
|
|
|
66
65
|
return <RepoIcon size={18} />;
|
|
67
66
|
}, [isLoading]);
|
|
68
67
|
|
|
69
|
-
const dropdownMenu
|
|
68
|
+
const dropdownMenu = useDropdownMenu({
|
|
70
69
|
id,
|
|
71
70
|
toggleEditing,
|
|
72
71
|
});
|
|
73
72
|
|
|
74
73
|
return (
|
|
75
74
|
<>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onClick={handleClick}
|
|
91
|
-
onDoubleClick={handleDoubleClick}
|
|
92
|
-
style={style}
|
|
93
|
-
title={name}
|
|
94
|
-
/>
|
|
95
|
-
</Dropdown>
|
|
75
|
+
<NavItem
|
|
76
|
+
actions={<Actions dropdownMenu={dropdownMenu} />}
|
|
77
|
+
active={active}
|
|
78
|
+
className={className}
|
|
79
|
+
contextMenuItems={dropdownMenu}
|
|
80
|
+
disabled={editing}
|
|
81
|
+
icon={icon}
|
|
82
|
+
key={id}
|
|
83
|
+
loading={isLoading}
|
|
84
|
+
onClick={handleClick}
|
|
85
|
+
onDoubleClick={handleDoubleClick}
|
|
86
|
+
style={style}
|
|
87
|
+
title={name}
|
|
88
|
+
/>
|
|
96
89
|
<Editing id={id} name={name} toggleEditing={toggleEditing} />
|
|
97
90
|
</>
|
|
98
91
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Icon, type MenuProps } from '@lobehub/ui';
|
|
2
2
|
import { App } from 'antd';
|
|
3
3
|
import { PencilLine, Trash } from 'lucide-react';
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
|
@@ -11,7 +11,7 @@ interface ActionProps {
|
|
|
11
11
|
toggleEditing: (visible?: boolean) => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const useDropdownMenu = ({ id, toggleEditing }: ActionProps): MenuProps['items'] => {
|
|
14
|
+
export const useDropdownMenu = ({ id, toggleEditing }: ActionProps): (() => MenuProps['items']) => {
|
|
15
15
|
const { t } = useTranslation(['file', 'common']);
|
|
16
16
|
const { modal } = App.useApp();
|
|
17
17
|
const removeKnowledgeBase = useKnowledgeBaseStore((s) => s.removeKnowledgeBase);
|
|
@@ -29,7 +29,7 @@ export const useDropdownMenu = ({ id, toggleEditing }: ActionProps): MenuProps['
|
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return useCallback(
|
|
33
33
|
() =>
|
|
34
34
|
[
|
|
35
35
|
{
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useDroppable } from '@dnd-kit/core';
|
|
4
|
-
import { Center, Flexbox, Skeleton, Text } from '@lobehub/ui';
|
|
5
|
-
import { Dropdown } from 'antd';
|
|
6
|
-
import type { MenuProps } from 'antd';
|
|
4
|
+
import { Center, type DropdownItem, DropdownMenu, Flexbox, Skeleton, Text } from '@lobehub/ui';
|
|
7
5
|
import { createStaticStyles, cx } from 'antd-style';
|
|
8
6
|
import { ChevronsUpDown } from 'lucide-react';
|
|
9
7
|
import { memo, useCallback, useMemo } from 'react';
|
|
@@ -81,7 +79,7 @@ const Head = memo<{ id: string }>(({ id }) => {
|
|
|
81
79
|
[navigate, setMode],
|
|
82
80
|
);
|
|
83
81
|
|
|
84
|
-
const menuItems
|
|
82
|
+
const menuItems = useMemo<DropdownItem[]>(() => {
|
|
85
83
|
if (!libraries) return [];
|
|
86
84
|
|
|
87
85
|
return libraries.map((library) => ({
|
|
@@ -120,14 +118,14 @@ const Head = memo<{ id: string }>(({ id }) => {
|
|
|
120
118
|
</Flexbox>
|
|
121
119
|
)}
|
|
122
120
|
{name && (
|
|
123
|
-
<
|
|
121
|
+
<DropdownMenu items={menuItems} placement="bottomRight">
|
|
124
122
|
<ChevronsUpDown
|
|
125
123
|
className={styles.icon}
|
|
126
124
|
onClick={(e) => e.stopPropagation()}
|
|
127
125
|
size={16}
|
|
128
126
|
style={{ cursor: 'pointer', flex: 'none' }}
|
|
129
127
|
/>
|
|
130
|
-
</
|
|
128
|
+
</DropdownMenu>
|
|
131
129
|
)}
|
|
132
130
|
</Flexbox>
|
|
133
131
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ActionIcon, Flexbox } from '@lobehub/ui';
|
|
2
|
-
import { Dropdown } from 'antd';
|
|
1
|
+
import { ActionIcon, DropdownMenu, type DropdownMenuCheckboxItem, Flexbox } from '@lobehub/ui';
|
|
3
2
|
import { createStaticStyles } from 'antd-style';
|
|
4
|
-
import type { ItemType } from 'antd/es/menu/interface';
|
|
5
3
|
import dayjs from 'dayjs';
|
|
6
4
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
7
5
|
import { Clock3Icon, PlusIcon } from 'lucide-react';
|
|
@@ -53,7 +51,7 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId }) => {
|
|
|
53
51
|
[topics, activeTopicId],
|
|
54
52
|
);
|
|
55
53
|
|
|
56
|
-
const items = useMemo<
|
|
54
|
+
const items = useMemo<DropdownMenuCheckboxItem[]>(
|
|
57
55
|
() =>
|
|
58
56
|
(topics || []).map((topic) => {
|
|
59
57
|
const displayTime =
|
|
@@ -62,6 +60,8 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId }) => {
|
|
|
62
60
|
: dayjs(topic.updatedAt).format('YYYY-MM-DD');
|
|
63
61
|
|
|
64
62
|
return {
|
|
63
|
+
checked: topic.id === activeTopicId,
|
|
64
|
+
closeOnClick: true,
|
|
65
65
|
key: topic.id,
|
|
66
66
|
label: (
|
|
67
67
|
<Flexbox align="center" gap={4} horizontal justify="space-between" width="100%">
|
|
@@ -69,11 +69,17 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId }) => {
|
|
|
69
69
|
<span className={styles.time}>{displayTime}</span>
|
|
70
70
|
</Flexbox>
|
|
71
71
|
),
|
|
72
|
-
|
|
72
|
+
onCheckedChange: (checked) => {
|
|
73
|
+
if (checked) {
|
|
74
|
+
switchTopic(topic.id);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
type: 'checkbox',
|
|
73
78
|
};
|
|
74
79
|
}),
|
|
75
|
-
[topics, switchTopic, styles],
|
|
80
|
+
[topics, switchTopic, styles, activeTopicId],
|
|
76
81
|
);
|
|
82
|
+
const isEmpty = !topics || topics.length === 0;
|
|
77
83
|
|
|
78
84
|
return (
|
|
79
85
|
<NavHeader
|
|
@@ -88,19 +94,14 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId }) => {
|
|
|
88
94
|
size={DESKTOP_HEADER_ICON_SIZE}
|
|
89
95
|
title={t('actions.addNewTopic')}
|
|
90
96
|
/>
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
menu={{
|
|
94
|
-
items,
|
|
95
|
-
selectedKeys: activeTopicId ? [activeTopicId] : [],
|
|
96
|
-
style: { maxHeight: 400, overflowY: 'auto' },
|
|
97
|
-
}}
|
|
98
|
-
overlayStyle={{ minWidth: 280 }}
|
|
97
|
+
<DropdownMenu
|
|
98
|
+
items={items}
|
|
99
99
|
placement="bottomRight"
|
|
100
|
-
|
|
100
|
+
popupProps={{ style: { maxHeight: 400, minWidth: 280, overflowY: 'auto' } }}
|
|
101
|
+
triggerProps={{ disabled: isEmpty }}
|
|
101
102
|
>
|
|
102
|
-
<ActionIcon disabled={
|
|
103
|
-
</
|
|
103
|
+
<ActionIcon disabled={isEmpty} icon={Clock3Icon} />
|
|
104
|
+
</DropdownMenu>
|
|
104
105
|
</>
|
|
105
106
|
}
|
|
106
107
|
showTogglePanelButton={false}
|
|
@@ -15,9 +15,7 @@ export const ErrorActionsBar = memo<ErrorActionsBarProps>(({ actions, onActionCl
|
|
|
15
15
|
return (
|
|
16
16
|
<ActionIconGroup
|
|
17
17
|
items={[regenerate, del]}
|
|
18
|
-
menu={
|
|
19
|
-
items: [edit, copy, divider, del],
|
|
20
|
-
}}
|
|
18
|
+
menu={[edit, copy, divider, del]}
|
|
21
19
|
onActionClick={onActionClick}
|
|
22
20
|
/>
|
|
23
21
|
);
|