@lobehub/lobehub 2.0.0-next.272 → 2.0.0-next.274
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 +59 -0
- package/changelog/v1.json +18 -0
- package/locales/ar/chat.json +7 -0
- package/locales/ar/common.json +1 -1
- package/locales/ar/discover.json +2 -2
- package/locales/ar/models.json +40 -12
- package/locales/ar/onboarding.json +1 -1
- package/locales/ar/plugin.json +22 -1
- package/locales/ar/providers.json +0 -1
- package/locales/bg-BG/chat.json +7 -0
- package/locales/bg-BG/common.json +2 -0
- package/locales/bg-BG/discover.json +2 -2
- package/locales/bg-BG/models.json +48 -13
- package/locales/bg-BG/onboarding.json +1 -1
- package/locales/bg-BG/plugin.json +22 -1
- package/locales/bg-BG/providers.json +0 -1
- package/locales/de-DE/chat.json +7 -0
- package/locales/de-DE/common.json +2 -0
- package/locales/de-DE/discover.json +2 -2
- package/locales/de-DE/models.json +37 -13
- package/locales/de-DE/onboarding.json +3 -0
- package/locales/de-DE/plugin.json +22 -1
- package/locales/de-DE/providers.json +0 -1
- package/locales/en-US/chat.json +7 -0
- package/locales/en-US/discover.json +2 -2
- package/locales/en-US/models.json +15 -15
- package/locales/en-US/plugin.json +22 -1
- package/locales/en-US/providers.json +0 -1
- package/locales/es-ES/chat.json +7 -0
- package/locales/es-ES/common.json +2 -0
- package/locales/es-ES/discover.json +2 -2
- package/locales/es-ES/models.json +32 -14
- package/locales/es-ES/onboarding.json +3 -0
- package/locales/es-ES/plugin.json +22 -1
- package/locales/es-ES/providers.json +0 -1
- package/locales/fa-IR/chat.json +7 -0
- package/locales/fa-IR/common.json +2 -0
- package/locales/fa-IR/discover.json +2 -2
- package/locales/fa-IR/models.json +36 -14
- package/locales/fa-IR/onboarding.json +3 -0
- package/locales/fa-IR/plugin.json +22 -1
- package/locales/fa-IR/providers.json +0 -1
- package/locales/fr-FR/chat.json +7 -0
- package/locales/fr-FR/common.json +2 -0
- package/locales/fr-FR/discover.json +2 -2
- package/locales/fr-FR/models.json +95 -13
- package/locales/fr-FR/onboarding.json +3 -0
- package/locales/fr-FR/plugin.json +22 -1
- package/locales/fr-FR/providers.json +0 -1
- package/locales/it-IT/chat.json +7 -0
- package/locales/it-IT/common.json +2 -0
- package/locales/it-IT/discover.json +2 -2
- package/locales/it-IT/models.json +8 -13
- package/locales/it-IT/onboarding.json +3 -0
- package/locales/it-IT/plugin.json +22 -1
- package/locales/it-IT/providers.json +0 -1
- package/locales/ja-JP/chat.json +7 -0
- package/locales/ja-JP/common.json +2 -0
- package/locales/ja-JP/discover.json +2 -2
- package/locales/ja-JP/models.json +76 -8
- package/locales/ja-JP/onboarding.json +3 -0
- package/locales/ja-JP/plugin.json +22 -1
- package/locales/ja-JP/providers.json +0 -1
- package/locales/ko-KR/chat.json +7 -0
- package/locales/ko-KR/common.json +2 -0
- package/locales/ko-KR/discover.json +2 -2
- package/locales/ko-KR/models.json +8 -15
- package/locales/ko-KR/onboarding.json +3 -0
- package/locales/ko-KR/plugin.json +22 -1
- package/locales/ko-KR/providers.json +0 -1
- package/locales/nl-NL/chat.json +7 -0
- package/locales/nl-NL/common.json +2 -0
- package/locales/nl-NL/discover.json +2 -2
- package/locales/nl-NL/models.json +98 -9
- package/locales/nl-NL/onboarding.json +3 -0
- package/locales/nl-NL/plugin.json +22 -1
- package/locales/nl-NL/providers.json +0 -1
- package/locales/pl-PL/chat.json +7 -0
- package/locales/pl-PL/common.json +2 -0
- package/locales/pl-PL/discover.json +2 -2
- package/locales/pl-PL/models.json +38 -13
- package/locales/pl-PL/onboarding.json +3 -0
- package/locales/pl-PL/plugin.json +22 -1
- package/locales/pl-PL/providers.json +0 -1
- package/locales/pt-BR/chat.json +7 -0
- package/locales/pt-BR/common.json +2 -0
- package/locales/pt-BR/discover.json +2 -2
- package/locales/pt-BR/models.json +50 -13
- package/locales/pt-BR/onboarding.json +3 -0
- package/locales/pt-BR/plugin.json +22 -1
- package/locales/pt-BR/providers.json +0 -1
- package/locales/ru-RU/chat.json +7 -0
- package/locales/ru-RU/common.json +2 -0
- package/locales/ru-RU/discover.json +2 -2
- package/locales/ru-RU/models.json +54 -13
- package/locales/ru-RU/onboarding.json +3 -0
- package/locales/ru-RU/plugin.json +22 -1
- package/locales/ru-RU/providers.json +0 -1
- package/locales/tr-TR/chat.json +7 -0
- package/locales/tr-TR/common.json +2 -0
- package/locales/tr-TR/discover.json +2 -2
- package/locales/tr-TR/models.json +40 -13
- package/locales/tr-TR/onboarding.json +3 -0
- package/locales/tr-TR/plugin.json +22 -1
- package/locales/tr-TR/providers.json +0 -1
- package/locales/vi-VN/chat.json +7 -0
- package/locales/vi-VN/common.json +2 -0
- package/locales/vi-VN/discover.json +2 -2
- package/locales/vi-VN/models.json +8 -8
- package/locales/vi-VN/onboarding.json +3 -0
- package/locales/vi-VN/plugin.json +22 -1
- package/locales/vi-VN/providers.json +0 -1
- package/locales/zh-CN/chat.json +7 -0
- package/locales/zh-CN/discover.json +2 -2
- package/locales/zh-CN/models.json +95 -13
- package/locales/zh-CN/onboarding.json +3 -0
- package/locales/zh-CN/plugin.json +22 -1
- package/locales/zh-CN/providers.json +0 -1
- package/locales/zh-TW/chat.json +7 -0
- package/locales/zh-TW/common.json +2 -0
- package/locales/zh-TW/discover.json +2 -2
- package/locales/zh-TW/models.json +86 -13
- package/locales/zh-TW/onboarding.json +3 -0
- package/locales/zh-TW/plugin.json +22 -1
- package/locales/zh-TW/providers.json +0 -1
- package/package.json +1 -1
- package/packages/builtin-tool-agent-builder/package.json +1 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/GetAvailableModels/index.tsx +66 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/InstallPlugin/index.tsx +63 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/SearchMarketTools/index.tsx +64 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdateConfig/index.tsx +94 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdatePrompt/index.tsx +96 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/index.ts +29 -0
- package/packages/builtin-tool-agent-builder/src/client/index.ts +13 -0
- package/packages/builtin-tool-agent-builder/src/executor.ts +132 -0
- package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/ExecuteCode/index.tsx +5 -14
- package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/RunCommand/index.tsx +5 -13
- package/packages/builtin-tool-group-agent-builder/package.json +7 -1
- package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +331 -87
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/BatchCreateAgents/index.tsx +110 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/CreateAgent/index.tsx +72 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx +57 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx +57 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/SearchAgent/index.tsx +66 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx +120 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroup/index.tsx +87 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroupPrompt/index.tsx +99 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/index.ts +52 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/BatchCreateAgents.tsx +103 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateAgentPrompt/index.tsx +36 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateGroupPrompt/index.tsx +36 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/index.ts +16 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/BatchCreateAgents/index.tsx +88 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateAgentPrompt/index.tsx +37 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateGroupPrompt/index.tsx +35 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/index.ts +22 -0
- package/packages/builtin-tool-group-agent-builder/src/client/index.ts +26 -0
- package/packages/builtin-tool-group-agent-builder/src/executor.ts +284 -0
- package/packages/builtin-tool-group-agent-builder/src/index.ts +1 -14
- package/packages/builtin-tool-group-agent-builder/src/manifest.ts +160 -15
- package/packages/builtin-tool-group-agent-builder/src/systemRole.ts +232 -46
- package/packages/builtin-tool-group-agent-builder/src/types.ts +191 -41
- package/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx +2 -2
- package/packages/builtin-tool-group-management/src/manifest.ts +1 -1
- package/packages/builtin-tool-gtd/src/client/Inspector/ClearTodos/index.tsx +5 -11
- package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/CreatePlan/index.tsx +6 -15
- package/packages/builtin-tool-gtd/src/client/Inspector/CreateTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/ExecTask/index.tsx +6 -17
- package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/UpdatePlan/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/UpdateTodos/index.tsx +3 -9
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +4 -16
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +4 -12
- package/packages/builtin-tool-local-system/src/client/Inspector/GlobLocalFiles/index.tsx +5 -13
- package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +5 -11
- package/packages/builtin-tool-local-system/src/client/Inspector/RunCommand/index.tsx +5 -13
- package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +6 -15
- package/packages/builtin-tool-notebook/src/client/Inspector/CreateDocument/index.tsx +7 -15
- package/packages/builtin-tool-page-agent/src/client/Inspector/EditTitle/index.tsx +5 -14
- package/packages/builtin-tool-page-agent/src/client/Inspector/GetPageContent/index.tsx +7 -8
- package/packages/builtin-tool-page-agent/src/client/Inspector/InitPage/index.tsx +4 -10
- package/packages/builtin-tool-page-agent/src/client/Inspector/ModifyNodes/index.tsx +3 -9
- package/packages/builtin-tool-page-agent/src/client/Inspector/ReplaceText/index.tsx +5 -11
- package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlMultiPages/index.tsx +6 -15
- package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlSinglePage/index.tsx +6 -15
- package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +4 -15
- package/packages/database/src/models/chatGroup.ts +1 -1
- package/packages/model-bank/src/aiModels/aihubmix.ts +2 -1
- package/packages/model-bank/src/aiModels/google.ts +2 -1
- package/packages/model-bank/src/aiModels/infiniai.ts +9 -6
- package/packages/model-bank/src/aiModels/minimax.ts +9 -5
- package/packages/model-bank/src/aiModels/ollamacloud.ts +4 -2
- package/packages/model-bank/src/aiModels/vertexai.ts +2 -1
- package/packages/types/src/agentGroup/index.ts +8 -0
- package/patches/@upstash__qstash.patch +13 -1
- package/src/app/[variants]/(main)/agent/_layout/Sidebar/Header/Nav.tsx +1 -1
- package/src/app/[variants]/(main)/agent/cron/[cronId]/index.tsx +4 -3
- package/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx +1 -1
- package/src/app/[variants]/(main)/agent/profile/features/store/action.ts +18 -21
- package/src/app/[variants]/(main)/group/_layout/GroupIdSync.tsx +6 -1
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/AgentProfilePopup.tsx +29 -21
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMember.tsx +1 -0
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMemberItem.tsx +35 -18
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/AddTopicButon.tsx +2 -10
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/Nav.tsx +10 -2
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/index.tsx +1 -2
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/AgentBuilderProvider.tsx +1 -0
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx +15 -9
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +12 -6
- package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor/AgentHeader.tsx → GroupProfile/GroupHeader.tsx} +22 -29
- package/src/app/[variants]/(main)/group/profile/features/GroupProfile/index.tsx +96 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/AgentBuilderToggle.tsx +3 -4
- package/src/app/[variants]/(main)/group/profile/features/Header/AutoSaveHint.tsx +11 -7
- package/src/app/[variants]/(main)/group/profile/features/Header/ChromeTabs/index.tsx +147 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/index.tsx +104 -13
- package/src/app/[variants]/(main)/group/profile/features/MemberProfile/AgentHeader.tsx +222 -0
- package/src/app/[variants]/(main)/group/profile/features/MemberProfile/index.tsx +155 -0
- package/src/app/[variants]/(main)/group/profile/features/ProfileHydration.tsx +63 -5
- package/src/app/[variants]/(main)/group/profile/index.tsx +34 -37
- package/src/app/[variants]/(mobile)/(home)/_layout/SessionHydration.tsx +1 -1
- package/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/index.tsx +1 -1
- package/src/features/AgentBuilder/index.tsx +16 -1
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx +3 -2
- package/src/features/EditorCanvas/EditorCanvas.test.tsx +206 -0
- package/src/features/EditorCanvas/EditorDataMode.tsx +53 -19
- package/src/features/EditorModal/index.tsx +2 -2
- package/src/features/NavPanel/components/SessionHydration.tsx +1 -1
- package/src/features/ShareModal/ShareImage/ChatList/index.tsx +1 -1
- package/src/features/ShareModal/SharePdf/index.tsx +1 -1
- package/src/hooks/useBidirectionalQuerySync.ts +112 -0
- package/src/locales/default/chat.ts +10 -0
- package/src/locales/default/plugin.ts +22 -1
- package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +45 -45
- package/src/server/modules/KeyVaultsEncrypt/index.ts +6 -6
- package/src/server/modules/S3/index.ts +1 -1
- package/src/server/routers/lambda/agent.ts +24 -0
- package/src/server/routers/lambda/agentGroup.ts +39 -0
- package/src/services/agent.ts +22 -0
- package/src/services/chatGroup/index.ts +14 -0
- package/src/store/agent/selectors/selectors.ts +3 -0
- package/src/store/agentGroup/initialState.ts +6 -0
- package/src/store/agentGroup/selectors/byId.ts +3 -1
- package/src/store/agentGroup/selectors/current.ts +2 -2
- package/src/store/agentGroup/slices/lifecycle.ts +18 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockStore.ts +1 -1
- package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +4 -1
- package/src/store/chat/slices/aiAgent/actions/agentGroup.ts +1 -1
- package/src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts +65 -0
- package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +2 -1
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +1 -1
- package/src/store/chat/slices/builtinTool/actions/index.ts +1 -6
- package/src/store/chat/slices/message/action.test.ts +5 -5
- package/src/store/chat/slices/message/actions/publicApi.ts +5 -5
- package/src/store/chat/slices/message/initialState.ts +0 -5
- package/src/store/chat/slices/message/selectors/displayMessage.test.ts +4 -4
- package/src/store/chat/slices/plugin/action.test.ts +54 -19
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +15 -21
- package/src/store/chat/slices/topic/action.test.ts +74 -24
- package/src/store/chat/slices/topic/action.ts +21 -13
- package/src/store/chat/slices/topic/selectors.test.ts +1 -1
- package/src/store/global/initialState.ts +10 -0
- package/src/store/global/selectors/systemStatus.ts +5 -0
- package/src/store/groupProfile/action.ts +168 -0
- package/src/store/groupProfile/index.ts +16 -0
- package/src/{app/[variants]/(main)/group/profile/features/store → store/groupProfile}/initialState.ts +17 -0
- package/src/store/groupProfile/selectors.ts +13 -0
- package/src/store/tool/slices/builtin/executors/index.ts +4 -0
- package/src/styles/text.ts +16 -0
- package/src/tools/inspectors.ts +13 -0
- package/src/tools/renders.ts +3 -0
- package/src/tools/streamings.ts +8 -0
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/TypoBar.tsx +0 -129
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/index.tsx +0 -138
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/useSlashItems.tsx +0 -139
- package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/index.tsx +0 -82
- package/src/app/[variants]/(main)/group/profile/features/ProfileProvider.tsx +0 -20
- package/src/app/[variants]/(main)/group/profile/features/StoreUpdater.tsx +0 -24
- package/src/app/[variants]/(main)/group/profile/features/store/action.ts +0 -163
- package/src/app/[variants]/(main)/group/profile/features/store/index.ts +0 -23
- package/src/app/[variants]/(main)/group/profile/features/store/selectors.ts +0 -7
- package/src/features/EditorModal/EditorCanvas.tsx +0 -84
- package/src/features/EditorModal/Typobar.tsx +0 -139
- package/src/store/chat/slices/builtinTool/actions/agentBuilder.ts +0 -192
- package/src/store/chat/slices/builtinTool/actions/groupAgentBuilder.ts +0 -242
- package/src/tools/executionRuntimes.ts +0 -14
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/AgentTool.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/MentionDropdown.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/types.ts +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/useMentionItems.tsx +0 -0
|
@@ -1,15 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useEditor, useEditorState } from '@lobehub/editor/react';
|
|
4
|
+
import { useUnmount } from 'ahooks';
|
|
5
|
+
import { memo, useEffect, useRef } from 'react';
|
|
6
|
+
import { createStoreUpdater } from 'zustand-utils';
|
|
4
7
|
|
|
5
|
-
import {
|
|
8
|
+
import { useRegisterFilesHotkeys, useSaveDocumentHotkey } from '@/hooks/useHotkeys';
|
|
9
|
+
import { parseAsString, useQueryState } from '@/hooks/useQueryParam';
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
11
|
+
import { useGroupProfileStore } from '@/store/groupProfile';
|
|
6
12
|
|
|
7
13
|
const ProfileHydration = memo(() => {
|
|
8
|
-
|
|
9
|
-
const
|
|
14
|
+
const editor = useEditor();
|
|
15
|
+
const editorState = useEditorState(editor);
|
|
16
|
+
const flushSave = useGroupProfileStore((s) => s.flushSave);
|
|
17
|
+
|
|
18
|
+
const storeUpdater = createStoreUpdater(useGroupProfileStore);
|
|
19
|
+
|
|
20
|
+
// Sync editor to store
|
|
21
|
+
storeUpdater('editor', editor);
|
|
22
|
+
// Sync editorState to store
|
|
23
|
+
storeUpdater('editorState', editorState);
|
|
24
|
+
// Sync tab query param to store
|
|
25
|
+
const [activeTabId] = useQueryState('tab', parseAsString.withDefault('group'));
|
|
26
|
+
storeUpdater('activeTabId', activeTabId);
|
|
27
|
+
|
|
28
|
+
// Bidirectional sync between URL query 'bt' and chatStore.activeTopicId
|
|
29
|
+
const [builderTopicId, setBuilderTopicId] = useQueryState('bt');
|
|
30
|
+
const activeTopicId = useChatStore((s) => s.activeTopicId);
|
|
31
|
+
|
|
32
|
+
// Track if the change came from URL to prevent sync loops
|
|
33
|
+
const isUrlChangeRef = useRef(false);
|
|
34
|
+
|
|
35
|
+
// Sync URL → Store (when URL changes)
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const urlTopicId = builderTopicId ?? undefined;
|
|
38
|
+
if (urlTopicId !== activeTopicId) {
|
|
39
|
+
isUrlChangeRef.current = true;
|
|
40
|
+
useChatStore.setState({ activeTopicId: urlTopicId });
|
|
41
|
+
}
|
|
42
|
+
}, [builderTopicId]);
|
|
43
|
+
|
|
44
|
+
// Sync Store → URL (when store changes, but not from URL)
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (isUrlChangeRef.current) {
|
|
47
|
+
isUrlChangeRef.current = false;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const urlTopicId = builderTopicId ?? undefined;
|
|
51
|
+
if (activeTopicId !== urlTopicId) {
|
|
52
|
+
setBuilderTopicId(activeTopicId ?? null);
|
|
53
|
+
}
|
|
54
|
+
}, [activeTopicId]);
|
|
55
|
+
|
|
56
|
+
// Register hotkeys
|
|
10
57
|
useRegisterFilesHotkeys();
|
|
11
58
|
useSaveDocumentHotkey(flushSave);
|
|
12
59
|
|
|
60
|
+
// Clear state when unmounting
|
|
61
|
+
useUnmount(() => {
|
|
62
|
+
useGroupProfileStore.setState({
|
|
63
|
+
activeTabId: 'group',
|
|
64
|
+
editor: undefined,
|
|
65
|
+
editorState: undefined,
|
|
66
|
+
saveStateMap: {},
|
|
67
|
+
});
|
|
68
|
+
useChatStore.setState({ activeTopicId: undefined });
|
|
69
|
+
});
|
|
70
|
+
|
|
13
71
|
return null;
|
|
14
72
|
});
|
|
15
73
|
|
|
@@ -7,58 +7,55 @@ import Loading from '@/components/Loading/BrandTextLoading';
|
|
|
7
7
|
import WideScreenContainer from '@/features/WideScreenContainer';
|
|
8
8
|
import { useAgentGroupStore } from '@/store/agentGroup';
|
|
9
9
|
import { agentGroupSelectors } from '@/store/agentGroup/selectors';
|
|
10
|
+
import { useGroupProfileStore } from '@/store/groupProfile';
|
|
10
11
|
|
|
11
12
|
import AgentBuilder from './features/AgentBuilder';
|
|
13
|
+
import GroupProfileSettings from './features/GroupProfile';
|
|
12
14
|
import Header from './features/Header';
|
|
13
|
-
import
|
|
15
|
+
import MemberProfile from './features/MemberProfile';
|
|
14
16
|
import ProfileHydration from './features/ProfileHydration';
|
|
15
|
-
import ProfileProvider from './features/ProfileProvider';
|
|
16
|
-
import { useProfileStore } from './features/store';
|
|
17
17
|
|
|
18
18
|
const ProfileArea = memo(() => {
|
|
19
|
-
const editor =
|
|
19
|
+
const editor = useGroupProfileStore((s) => s.editor);
|
|
20
|
+
const activeTabId = useGroupProfileStore((s) => s.activeTabId);
|
|
20
21
|
const isGroupsLoading = useAgentGroupStore(agentGroupSelectors.isGroupsInit);
|
|
21
22
|
|
|
23
|
+
const isGroupTab = activeTabId === 'group';
|
|
24
|
+
|
|
22
25
|
return (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</Flexbox>
|
|
46
|
-
<Suspense fallback={null}>
|
|
47
|
-
<ProfileHydration />
|
|
48
|
-
</Suspense>
|
|
49
|
-
</>
|
|
26
|
+
<Flexbox flex={1} height={'100%'} style={{ minWidth: 0, overflow: 'hidden' }}>
|
|
27
|
+
{isGroupsLoading ? (
|
|
28
|
+
<Loading debugId="ProfileArea" />
|
|
29
|
+
) : (
|
|
30
|
+
<>
|
|
31
|
+
<Header />
|
|
32
|
+
<Flexbox
|
|
33
|
+
height={'100%'}
|
|
34
|
+
horizontal
|
|
35
|
+
onClick={() => {
|
|
36
|
+
editor?.focus();
|
|
37
|
+
}}
|
|
38
|
+
style={{ cursor: 'text', display: 'flex', overflowY: 'auto', position: 'relative' }}
|
|
39
|
+
width={'100%'}
|
|
40
|
+
>
|
|
41
|
+
<WideScreenContainer>
|
|
42
|
+
{isGroupTab ? <GroupProfileSettings /> : <MemberProfile />}
|
|
43
|
+
</WideScreenContainer>
|
|
44
|
+
</Flexbox>
|
|
45
|
+
</>
|
|
46
|
+
)}
|
|
47
|
+
</Flexbox>
|
|
50
48
|
);
|
|
51
49
|
});
|
|
52
50
|
|
|
53
51
|
const GroupProfile: FC = () => {
|
|
54
52
|
return (
|
|
55
53
|
<Suspense fallback={<Loading debugId="GroupProfile" />}>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</ProfileProvider>
|
|
54
|
+
<ProfileHydration />
|
|
55
|
+
<Flexbox height={'100%'} horizontal width={'100%'}>
|
|
56
|
+
<ProfileArea />
|
|
57
|
+
<AgentBuilder />
|
|
58
|
+
</Flexbox>
|
|
62
59
|
</Suspense>
|
|
63
60
|
);
|
|
64
61
|
};
|
|
@@ -32,7 +32,7 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
|
|
|
32
32
|
|
|
33
33
|
const [active] = useSessionStore((s) => [s.activeId === id]);
|
|
34
34
|
const [loading] = useChatStore((s) => [
|
|
35
|
-
operationSelectors.isAgentRuntimeRunning(s) && id === s.
|
|
35
|
+
operationSelectors.isAgentRuntimeRunning(s) && id === s.activeAgentId,
|
|
36
36
|
]);
|
|
37
37
|
|
|
38
38
|
const [pin, title, avatar, avatarBackground, updateAt, members, model, group, sessionType] =
|
|
@@ -5,6 +5,8 @@ import Loading from '@/components/Loading/BrandTextLoading';
|
|
|
5
5
|
import RightPanel from '@/features/RightPanel';
|
|
6
6
|
import { useAgentStore } from '@/store/agent';
|
|
7
7
|
import { builtinAgentSelectors } from '@/store/agent/selectors';
|
|
8
|
+
import { useGlobalStore } from '@/store/global';
|
|
9
|
+
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
8
10
|
|
|
9
11
|
import AgentBuilderConversation from './AgentBuilderConversation';
|
|
10
12
|
import AgentBuilderProvider from './AgentBuilderProvider';
|
|
@@ -13,11 +15,24 @@ const AgentBuilder = memo(() => {
|
|
|
13
15
|
const agentId = useAgentStore((s) => s.activeAgentId);
|
|
14
16
|
const agentBuilderId = useAgentStore(builtinAgentSelectors.agentBuilderId);
|
|
15
17
|
|
|
18
|
+
const [width, updateSystemStatus] = useGlobalStore((s) => [
|
|
19
|
+
systemStatusSelectors.agentBuilderPanelWidth(s),
|
|
20
|
+
s.updateSystemStatus,
|
|
21
|
+
]);
|
|
22
|
+
|
|
16
23
|
const useInitBuiltinAgent = useAgentStore((s) => s.useInitBuiltinAgent);
|
|
17
24
|
useInitBuiltinAgent(BUILTIN_AGENT_SLUGS.agentBuilder);
|
|
18
25
|
|
|
19
26
|
return (
|
|
20
|
-
<RightPanel
|
|
27
|
+
<RightPanel
|
|
28
|
+
defaultWidth={width}
|
|
29
|
+
onSizeChange={(size) => {
|
|
30
|
+
if (size?.width) {
|
|
31
|
+
const w = typeof size.width === 'string' ? Number.parseInt(size.width) : size.width;
|
|
32
|
+
if (!!w) updateSystemStatus({ agentBuilderPanelWidth: w });
|
|
33
|
+
}
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
21
36
|
{agentId && agentBuilderId ? (
|
|
22
37
|
<AgentBuilderProvider agentId={agentBuilderId}>
|
|
23
38
|
<AgentBuilderConversation agentId={agentBuilderId} />
|
package/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ToolIntervention } from '@lobechat/types';
|
|
2
2
|
import { Block, Icon, Tooltip } from '@lobehub/ui';
|
|
3
3
|
import { cssVar } from 'antd-style';
|
|
4
|
-
import { Ban, Check, HandIcon,
|
|
4
|
+
import { Ban, Check, HandIcon, PauseIcon, X } from 'lucide-react';
|
|
5
5
|
import { memo } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
|
|
8
|
+
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
|
|
8
9
|
import { LOADING_FLAT } from '@/const/message';
|
|
9
10
|
|
|
10
11
|
interface StatusIndicatorProps {
|
|
@@ -43,7 +44,7 @@ const StatusIndicator = memo<StatusIndicatorProps>(({ intervention, result }) =>
|
|
|
43
44
|
} else if (hasResult) {
|
|
44
45
|
icon = <Icon color={cssVar.colorSuccess} icon={Check} />;
|
|
45
46
|
} else {
|
|
46
|
-
icon = <
|
|
47
|
+
icon = <NeuralNetworkLoading size={16} />;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
return (
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vitest-environment happy-dom
|
|
3
|
+
*/
|
|
4
|
+
import { type IEditor } from '@lobehub/editor';
|
|
5
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { EditorCanvas } from './EditorCanvas';
|
|
9
|
+
|
|
10
|
+
// Mock DocumentIdMode
|
|
11
|
+
vi.mock('./DocumentIdMode', () => ({
|
|
12
|
+
default: vi.fn(({ documentId }) => (
|
|
13
|
+
<div data-testid="document-id-mode">DocumentIdMode: {documentId}</div>
|
|
14
|
+
)),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
// Mock EditorDataMode
|
|
18
|
+
vi.mock('./EditorDataMode', () => ({
|
|
19
|
+
default: vi.fn(({ editorData }) => (
|
|
20
|
+
<div data-testid="editor-data-mode">EditorDataMode: {editorData?.content}</div>
|
|
21
|
+
)),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
// Mock InternalEditor
|
|
25
|
+
vi.mock('./InternalEditor', () => ({
|
|
26
|
+
default: vi.fn(() => <div data-testid="internal-editor">InternalEditor</div>),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
// Mock ErrorBoundary to pass through children
|
|
30
|
+
vi.mock('./ErrorBoundary', () => ({
|
|
31
|
+
EditorErrorBoundary: vi.fn(({ children }) => <>{children}</>),
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
describe('EditorCanvas', () => {
|
|
35
|
+
let mockEditor: IEditor;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
mockEditor = {
|
|
39
|
+
getDocument: vi.fn(),
|
|
40
|
+
setDocument: vi.fn(),
|
|
41
|
+
focus: vi.fn(),
|
|
42
|
+
} as unknown as IEditor;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
cleanup();
|
|
47
|
+
vi.clearAllMocks();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('mode selection', () => {
|
|
51
|
+
it('should render DocumentIdMode when documentId is provided', () => {
|
|
52
|
+
render(<EditorCanvas documentId="doc-123" editor={mockEditor} />);
|
|
53
|
+
|
|
54
|
+
expect(screen.getByTestId('document-id-mode')).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText('DocumentIdMode: doc-123')).toBeInTheDocument();
|
|
56
|
+
expect(screen.queryByTestId('editor-data-mode')).not.toBeInTheDocument();
|
|
57
|
+
expect(screen.queryByTestId('internal-editor')).not.toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should render EditorDataMode when editorData is provided', () => {
|
|
61
|
+
render(<EditorCanvas editor={mockEditor} editorData={{ content: 'test content' }} />);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByTestId('editor-data-mode')).toBeInTheDocument();
|
|
64
|
+
expect(screen.getByText('EditorDataMode: test content')).toBeInTheDocument();
|
|
65
|
+
expect(screen.queryByTestId('document-id-mode')).not.toBeInTheDocument();
|
|
66
|
+
expect(screen.queryByTestId('internal-editor')).not.toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should render InternalEditor in basic mode (no documentId or editorData)', () => {
|
|
70
|
+
render(<EditorCanvas editor={mockEditor} />);
|
|
71
|
+
|
|
72
|
+
expect(screen.getByTestId('internal-editor')).toBeInTheDocument();
|
|
73
|
+
expect(screen.queryByTestId('document-id-mode')).not.toBeInTheDocument();
|
|
74
|
+
expect(screen.queryByTestId('editor-data-mode')).not.toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should return null in basic mode when editor is undefined', () => {
|
|
78
|
+
const { container } = render(<EditorCanvas editor={undefined} />);
|
|
79
|
+
|
|
80
|
+
expect(container.firstChild).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('mode priority', () => {
|
|
85
|
+
it('should prioritize documentId over editorData when both are provided', () => {
|
|
86
|
+
render(
|
|
87
|
+
<EditorCanvas
|
|
88
|
+
documentId="doc-123"
|
|
89
|
+
editor={mockEditor}
|
|
90
|
+
editorData={{ content: 'test content' }}
|
|
91
|
+
/>,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(screen.getByTestId('document-id-mode')).toBeInTheDocument();
|
|
95
|
+
expect(screen.queryByTestId('editor-data-mode')).not.toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('props forwarding', () => {
|
|
100
|
+
it('should forward props to DocumentIdMode', async () => {
|
|
101
|
+
const onContentChange = vi.fn();
|
|
102
|
+
const onInit = vi.fn();
|
|
103
|
+
|
|
104
|
+
render(
|
|
105
|
+
<EditorCanvas
|
|
106
|
+
autoSave={false}
|
|
107
|
+
documentId="doc-123"
|
|
108
|
+
editor={mockEditor}
|
|
109
|
+
onContentChange={onContentChange}
|
|
110
|
+
onInit={onInit}
|
|
111
|
+
placeholder="Custom placeholder"
|
|
112
|
+
sourceType="notebook"
|
|
113
|
+
/>,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const DocumentIdMode = await vi.importMock('./DocumentIdMode');
|
|
117
|
+
const lastCall = (DocumentIdMode.default as ReturnType<typeof vi.fn>).mock.calls.at(-1);
|
|
118
|
+
|
|
119
|
+
expect(lastCall?.[0]).toMatchObject({
|
|
120
|
+
autoSave: false,
|
|
121
|
+
documentId: 'doc-123',
|
|
122
|
+
editor: mockEditor,
|
|
123
|
+
onContentChange,
|
|
124
|
+
onInit,
|
|
125
|
+
placeholder: 'Custom placeholder',
|
|
126
|
+
sourceType: 'notebook',
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should forward props to EditorDataMode', async () => {
|
|
131
|
+
const onContentChange = vi.fn();
|
|
132
|
+
const onInit = vi.fn();
|
|
133
|
+
const editorData = { content: 'test', editorData: { blocks: [] } };
|
|
134
|
+
|
|
135
|
+
render(
|
|
136
|
+
<EditorCanvas
|
|
137
|
+
editor={mockEditor}
|
|
138
|
+
editorData={editorData}
|
|
139
|
+
onContentChange={onContentChange}
|
|
140
|
+
onInit={onInit}
|
|
141
|
+
placeholder="Custom placeholder"
|
|
142
|
+
/>,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const EditorDataMode = await vi.importMock('./EditorDataMode');
|
|
146
|
+
const lastCall = (EditorDataMode.default as ReturnType<typeof vi.fn>).mock.calls.at(-1);
|
|
147
|
+
|
|
148
|
+
expect(lastCall?.[0]).toMatchObject({
|
|
149
|
+
editor: mockEditor,
|
|
150
|
+
editorData,
|
|
151
|
+
onContentChange,
|
|
152
|
+
onInit,
|
|
153
|
+
placeholder: 'Custom placeholder',
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should forward props to InternalEditor in basic mode', async () => {
|
|
158
|
+
const onContentChange = vi.fn();
|
|
159
|
+
const onInit = vi.fn();
|
|
160
|
+
|
|
161
|
+
render(
|
|
162
|
+
<EditorCanvas
|
|
163
|
+
editor={mockEditor}
|
|
164
|
+
floatingToolbar={false}
|
|
165
|
+
onContentChange={onContentChange}
|
|
166
|
+
onInit={onInit}
|
|
167
|
+
placeholder="Custom placeholder"
|
|
168
|
+
/>,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const InternalEditor = await vi.importMock('./InternalEditor');
|
|
172
|
+
const lastCall = (InternalEditor.default as ReturnType<typeof vi.fn>).mock.calls.at(-1);
|
|
173
|
+
|
|
174
|
+
expect(lastCall?.[0]).toMatchObject({
|
|
175
|
+
editor: mockEditor,
|
|
176
|
+
floatingToolbar: false,
|
|
177
|
+
onContentChange,
|
|
178
|
+
onInit,
|
|
179
|
+
placeholder: 'Custom placeholder',
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('error boundary wrapping', () => {
|
|
185
|
+
it('should wrap DocumentIdMode with ErrorBoundary', async () => {
|
|
186
|
+
render(<EditorCanvas documentId="doc-123" editor={mockEditor} />);
|
|
187
|
+
|
|
188
|
+
const ErrorBoundary = await vi.importMock('./ErrorBoundary');
|
|
189
|
+
expect(ErrorBoundary.EditorErrorBoundary).toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should wrap EditorDataMode with ErrorBoundary', async () => {
|
|
193
|
+
render(<EditorCanvas editor={mockEditor} editorData={{ content: 'test' }} />);
|
|
194
|
+
|
|
195
|
+
const ErrorBoundary = await vi.importMock('./ErrorBoundary');
|
|
196
|
+
expect(ErrorBoundary.EditorErrorBoundary).toHaveBeenCalled();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should wrap InternalEditor with ErrorBoundary in basic mode', async () => {
|
|
200
|
+
render(<EditorCanvas editor={mockEditor} />);
|
|
201
|
+
|
|
202
|
+
const ErrorBoundary = await vi.importMock('./ErrorBoundary');
|
|
203
|
+
expect(ErrorBoundary.EditorErrorBoundary).toHaveBeenCalled();
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { type IEditor } from '@lobehub/editor';
|
|
4
|
-
import { memo, useEffect,
|
|
4
|
+
import { memo, useCallback, useEffect, useRef } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
7
|
import type { EditorCanvasProps } from './EditorCanvas';
|
|
@@ -12,37 +12,70 @@ export interface EditorDataModeProps extends EditorCanvasProps {
|
|
|
12
12
|
editorData: NonNullable<EditorCanvasProps['editorData']>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const loadEditorContent = (
|
|
16
|
+
editorInstance: IEditor,
|
|
17
|
+
editorData: EditorDataModeProps['editorData'],
|
|
18
|
+
): boolean => {
|
|
19
|
+
const hasValidEditorData =
|
|
20
|
+
editorData.editorData &&
|
|
21
|
+
typeof editorData.editorData === 'object' &&
|
|
22
|
+
Object.keys(editorData.editorData as object).length > 0;
|
|
23
|
+
|
|
24
|
+
if (hasValidEditorData) {
|
|
25
|
+
editorInstance.setDocument('json', JSON.stringify(editorData.editorData));
|
|
26
|
+
return true;
|
|
27
|
+
} else if (editorData.content?.trim()) {
|
|
28
|
+
editorInstance.setDocument('markdown', editorData.content, { keepId: true });
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
15
34
|
/**
|
|
16
35
|
* EditorCanvas with editorData mode - uses provided data directly
|
|
17
36
|
*/
|
|
18
37
|
const EditorDataMode = memo<EditorDataModeProps>(
|
|
19
|
-
({ editor, editorData, onContentChange, style, ...editorProps }) => {
|
|
38
|
+
({ editor, editorData, onContentChange, onInit, style, ...editorProps }) => {
|
|
20
39
|
const { t } = useTranslation('file');
|
|
21
|
-
const
|
|
40
|
+
const isEditorReadyRef = useRef(false);
|
|
41
|
+
// Track loaded content to support re-loading when data changes
|
|
42
|
+
const loadedContentRef = useRef<string | undefined>(undefined);
|
|
22
43
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
if (!editor || isInitialized) return;
|
|
44
|
+
// Check if content has actually changed
|
|
45
|
+
const hasDataChanged = loadedContentRef.current !== editorData.content;
|
|
26
46
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Object.keys(editorData.editorData as object).length > 0;
|
|
47
|
+
const handleInit = useCallback(
|
|
48
|
+
(editorInstance: IEditor) => {
|
|
49
|
+
isEditorReadyRef.current = true;
|
|
31
50
|
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
// Try to load content if editorData is available and hasn't been loaded yet
|
|
52
|
+
if (hasDataChanged) {
|
|
53
|
+
try {
|
|
54
|
+
if (loadEditorContent(editorInstance, editorData)) {
|
|
55
|
+
loadedContentRef.current = editorData.content;
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('[EditorCanvas] Failed to load content:', err);
|
|
59
|
+
}
|
|
39
60
|
}
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
onInit?.(editorInstance);
|
|
63
|
+
},
|
|
64
|
+
[editorData, hasDataChanged, onInit],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Load content when editorData changes after editor is ready
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!editor || !isEditorReadyRef.current || !hasDataChanged) return;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
if (loadEditorContent(editor, editorData)) {
|
|
73
|
+
loadedContentRef.current = editorData.content;
|
|
74
|
+
}
|
|
42
75
|
} catch (err) {
|
|
43
76
|
console.error('[EditorCanvas] Failed to load content:', err);
|
|
44
77
|
}
|
|
45
|
-
}, [
|
|
78
|
+
}, [editor, editorData, hasDataChanged]);
|
|
46
79
|
|
|
47
80
|
if (!editor) return null;
|
|
48
81
|
|
|
@@ -51,6 +84,7 @@ const EditorDataMode = memo<EditorDataModeProps>(
|
|
|
51
84
|
<InternalEditor
|
|
52
85
|
editor={editor}
|
|
53
86
|
onContentChange={onContentChange}
|
|
87
|
+
onInit={handleInit}
|
|
54
88
|
placeholder={editorProps.placeholder || t('pageEditor.editorPlaceholder')}
|
|
55
89
|
{...editorProps}
|
|
56
90
|
/>
|
|
@@ -3,7 +3,7 @@ import { Modal, ModalProps, createRawModal } from '@lobehub/ui';
|
|
|
3
3
|
import { memo, useState } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
|
|
6
|
-
import EditorCanvas from '
|
|
6
|
+
import { EditorCanvas } from '@/features/EditorCanvas';
|
|
7
7
|
|
|
8
8
|
interface EditorModalProps extends ModalProps {
|
|
9
9
|
onConfirm?: (value: string) => Promise<void>;
|
|
@@ -43,7 +43,7 @@ export const EditorModal = memo<EditorModalProps>(({ value, onConfirm, ...rest }
|
|
|
43
43
|
width={'min(90vw, 920px)'}
|
|
44
44
|
{...rest}
|
|
45
45
|
>
|
|
46
|
-
<EditorCanvas
|
|
46
|
+
<EditorCanvas editor={editor} editorData={{ content: value }} />
|
|
47
47
|
</Modal>
|
|
48
48
|
);
|
|
49
49
|
});
|
|
@@ -8,7 +8,7 @@ import { chatSelectors } from '@/store/chat/selectors';
|
|
|
8
8
|
const ChatList = memo(() => {
|
|
9
9
|
const ids = useChatStore(chatSelectors.mainDisplayChatIDs);
|
|
10
10
|
const messages = useChatStore(chatSelectors.activeBaseChats);
|
|
11
|
-
const agentId = useChatStore((s) => s.
|
|
11
|
+
const agentId = useChatStore((s) => s.activeAgentId);
|
|
12
12
|
const topicId = useChatStore((s) => s.activeTopicId);
|
|
13
13
|
|
|
14
14
|
return (
|
|
@@ -75,7 +75,7 @@ const SharePdf = memo((props: { message?: UIChatMessage }) => {
|
|
|
75
75
|
const [systemRole] = useAgentStore((s) => [agentSelectors.currentAgentSystemRole(s)]);
|
|
76
76
|
const messages = useChatStore(chatSelectors.activeBaseChats, isEqual);
|
|
77
77
|
const topic = useChatStore(topicSelectors.currentActiveTopic, isEqual);
|
|
78
|
-
const activeId = useChatStore((s) => s.
|
|
78
|
+
const activeId = useChatStore((s) => s.activeAgentId);
|
|
79
79
|
const topicId = useChatStore((s) => s.activeTopicId);
|
|
80
80
|
|
|
81
81
|
const title = topic?.title || t('shareModal.exportTitle');
|