@lobehub/lobehub 2.0.0-next.255 → 2.0.0-next.256
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 +25 -0
- package/changelog/v1.json +9 -0
- package/locales/en-US/plugin.json +1 -0
- package/locales/zh-CN/plugin.json +1 -0
- package/package.json +1 -1
- package/packages/builtin-tool-notebook/src/client/Placeholder/CreateDocument.tsx +6 -6
- package/packages/builtin-tool-notebook/src/client/Render/CreateDocument/DocumentCard.tsx +23 -10
- package/packages/builtin-tool-notebook/src/client/Streaming/CreateDocument/index.tsx +1 -1
- package/packages/database/src/models/__tests__/agent.test.ts +91 -4
- package/packages/database/src/models/agent.ts +15 -7
- package/packages/editor-runtime/src/EditorRuntime.ts +1 -1
- package/packages/editor-runtime/src/__tests__/EditorRuntime.real.test.ts +65 -4
- package/packages/editor-runtime/src/__tests__/__snapshots__/EditorRuntime.real.test.ts.snap +108 -17
- package/packages/editor-runtime/src/__tests__/fixtures/remove-then-add.json +636 -0
- package/packages/editor-runtime/src/__tests__/fixtures/remove.json +1 -0
- package/packages/types/src/agent/agentConfig.ts +8 -8
- package/src/app/[variants]/(main)/chat/features/Portal/_layout/Mobile.tsx +2 -1
- package/src/app/[variants]/(main)/group/features/Portal/_layout/Mobile.tsx +2 -1
- package/src/app/[variants]/(main)/home/_layout/hooks/useCreateMenuItems.tsx +2 -2
- package/src/app/[variants]/(main)/page/{features/PageTitle → PageTitle}/index.tsx +0 -1
- package/src/app/[variants]/(main)/page/[id]/index.tsx +43 -1
- package/src/app/[variants]/(main)/page/_layout/Body/AllPagesDrawer/Content.tsx +15 -15
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/Editing.tsx +3 -3
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/index.tsx +7 -12
- package/src/app/[variants]/(main)/page/_layout/Body/List/Item/useDropdownMenu.tsx +5 -5
- package/src/app/[variants]/(main)/page/_layout/Body/List/index.tsx +7 -7
- package/src/app/[variants]/(main)/page/_layout/Body/index.tsx +15 -9
- package/src/app/[variants]/(main)/page/_layout/Body/useDropdownMenu.tsx +3 -3
- package/src/app/[variants]/(main)/page/_layout/DataSync.tsx +15 -0
- package/src/app/[variants]/(main)/page/_layout/Header/AddButton.tsx +2 -2
- package/src/app/[variants]/(main)/page/_layout/index.tsx +2 -0
- package/src/app/[variants]/(main)/page/index.tsx +3 -7
- package/src/components/Editor/AutoSaveHint.tsx +1 -1
- package/src/features/Conversation/Messages/User/Actions/index.tsx +5 -1
- package/src/features/EditorCanvas/AutoSaveHint.tsx +37 -0
- package/src/features/{PageEditor → EditorCanvas}/DiffAllToolbar.tsx +57 -16
- package/src/features/EditorCanvas/DocumentIdMode.tsx +111 -0
- package/src/features/EditorCanvas/EditorCanvas.tsx +148 -0
- package/src/features/EditorCanvas/EditorDataMode.tsx +64 -0
- package/src/features/EditorCanvas/ErrorBoundary.tsx +66 -0
- package/src/features/EditorCanvas/InlineToolbar.tsx +245 -0
- package/src/features/EditorCanvas/InternalEditor.tsx +134 -0
- package/src/features/{PageEditor/EditorCanvas → EditorCanvas}/actions.ts +10 -8
- package/src/features/EditorCanvas/index.ts +9 -0
- package/src/features/PageEditor/EditorCanvas/index.tsx +14 -111
- package/src/features/PageEditor/EditorCanvas/useAskCopilotItem.tsx +95 -0
- package/src/features/PageEditor/EditorCanvas/useSlashItems.tsx +1 -1
- package/src/features/PageEditor/Header/Breadcrumb.tsx +2 -2
- package/src/features/PageEditor/Header/index.tsx +15 -18
- package/src/features/PageEditor/Header/useMenu.tsx +12 -9
- package/src/features/PageEditor/PageEditor.tsx +45 -21
- package/src/features/PageEditor/PageEditorProvider.tsx +13 -1
- package/src/features/PageEditor/PageTitle/index.tsx +2 -2
- package/src/features/PageEditor/StoreUpdater.tsx +35 -308
- package/src/features/PageEditor/{Body/Title.tsx → TitleSection.tsx} +16 -16
- package/src/features/PageEditor/store/action.ts +96 -188
- package/src/features/PageEditor/store/initialState.ts +16 -21
- package/src/features/PageEditor/store/selectors.ts +3 -4
- package/src/features/PageExplorer/PageExplorerPlaceholder.tsx +22 -14
- package/src/features/PageExplorer/index.tsx +34 -67
- package/src/features/Portal/Artifacts/index.ts +0 -2
- package/src/features/Portal/Document/AutoSaveHint.tsx +7 -6
- package/src/features/Portal/Document/Body.tsx +1 -3
- package/src/features/Portal/Document/EditorCanvas.tsx +7 -50
- package/src/features/Portal/Document/Header.tsx +13 -10
- package/src/features/Portal/Document/TodoList.tsx +6 -4
- package/src/features/Portal/Document/Wrapper.tsx +3 -11
- package/src/features/Portal/Document/index.ts +0 -2
- package/src/features/Portal/FilePreview/index.ts +0 -2
- package/src/features/Portal/GroupThread/index.ts +0 -3
- package/src/features/Portal/MessageDetail/index.ts +0 -2
- package/src/features/Portal/Notebook/index.ts +0 -2
- package/src/features/Portal/Plugins/index.ts +0 -2
- package/src/features/Portal/Thread/index.ts +0 -3
- package/src/features/Portal/components/Header.tsx +18 -6
- package/src/features/Portal/router.tsx +34 -97
- package/src/features/Portal/type.ts +0 -2
- package/src/locales/default/plugin.ts +1 -0
- package/src/store/chat/slices/portal/action.test.ts +218 -15
- package/src/store/chat/slices/portal/action.ts +194 -41
- package/src/store/chat/slices/portal/initialState.ts +40 -1
- package/src/store/chat/slices/portal/selectors/thread.ts +44 -3
- package/src/store/chat/slices/portal/selectors.test.ts +119 -17
- package/src/store/chat/slices/portal/selectors.ts +117 -36
- package/src/store/document/index.ts +17 -5
- package/src/store/document/slices/document/action.ts +209 -0
- package/src/store/document/slices/document/index.ts +6 -0
- package/src/store/document/slices/editor/action.test.ts +340 -0
- package/src/store/document/slices/editor/action.ts +133 -149
- package/src/store/document/slices/editor/index.ts +9 -2
- package/src/store/document/slices/editor/initialState.ts +66 -29
- package/src/store/document/slices/editor/reducer.test.ts +217 -0
- package/src/store/document/slices/editor/reducer.ts +67 -0
- package/src/store/document/slices/editor/selectors.test.ts +395 -0
- package/src/store/document/slices/editor/selectors.ts +107 -5
- package/src/store/document/store.ts +12 -13
- package/src/store/file/slices/document/action.ts +19 -188
- package/src/store/file/slices/document/initialState.ts +0 -30
- package/src/store/file/slices/document/selectors.ts +25 -59
- package/src/store/notebook/index.ts +5 -4
- package/src/store/page/index.ts +2 -0
- package/src/store/page/initialState.ts +92 -0
- package/src/store/page/selectors.ts +5 -0
- package/src/store/page/slices/crud/action.ts +477 -0
- package/src/store/page/slices/crud/index.ts +2 -0
- package/src/store/page/slices/crud/initialState.ts +7 -0
- package/src/store/page/slices/internal/action.ts +32 -0
- package/src/store/page/slices/internal/index.ts +2 -0
- package/src/store/page/slices/internal/reducer.ts +105 -0
- package/src/store/page/slices/list/action.ts +206 -0
- package/src/store/page/slices/list/index.ts +3 -0
- package/src/store/page/slices/list/initialState.ts +29 -0
- package/src/store/page/slices/list/selectors.ts +90 -0
- package/src/store/page/slices/selection/action.ts +67 -0
- package/src/store/page/slices/selection/index.ts +2 -0
- package/src/store/page/slices/selection/initialState.ts +11 -0
- package/src/store/page/store.ts +29 -0
- package/src/store/tool/slices/lobehubSkillStore/selectors.ts +10 -20
- package/src/utils/identifier.ts +8 -2
- package/src/features/PageEditor/Body/index.tsx +0 -68
- package/src/features/PageEditor/EditorCanvas/InlineToolbar.tsx +0 -316
- package/src/features/PageEditor/Header/AutoSaveHint.tsx +0 -27
- package/src/features/Portal/Artifacts/useEnable.ts +0 -4
- package/src/features/Portal/Document/DocumentEditorProvider.tsx +0 -34
- package/src/features/Portal/Document/StoreUpdater.tsx +0 -80
- package/src/features/Portal/Document/Title.tsx +0 -54
- package/src/features/Portal/Document/store/action.ts +0 -114
- package/src/features/Portal/Document/store/index.ts +0 -21
- package/src/features/Portal/Document/store/initialState.ts +0 -24
- package/src/features/Portal/Document/useEnable.ts +0 -8
- package/src/features/Portal/FilePreview/useEnable.ts +0 -6
- package/src/features/Portal/GroupThread/hook.ts +0 -9
- package/src/features/Portal/MessageDetail/useEnable.ts +0 -4
- package/src/features/Portal/Notebook/useEnable.ts +0 -6
- package/src/features/Portal/Plugins/useEnable.ts +0 -6
- package/src/features/Portal/Thread/hook.ts +0 -8
- package/src/store/document/slices/notebook/action.ts +0 -119
- package/src/store/document/slices/notebook/index.ts +0 -3
- package/src/store/document/slices/notebook/initialState.ts +0 -12
- package/src/store/document/slices/notebook/selectors.ts +0 -26
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useAgentGroupStore } from '@/store/agentGroup';
|
|
2
|
-
import { useChatStore } from '@/store/chat';
|
|
3
|
-
|
|
4
|
-
export const useEnable = () => useAgentGroupStore((s) => !!s.activeThreadAgentId);
|
|
5
|
-
|
|
6
|
-
export const onClose = () => {
|
|
7
|
-
useAgentGroupStore.setState({ activeThreadAgentId: '' });
|
|
8
|
-
useChatStore.getState().togglePortal(false);
|
|
9
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useChatStore } from '@/store/chat';
|
|
2
|
-
import { portalThreadSelectors } from '@/store/chat/selectors';
|
|
3
|
-
|
|
4
|
-
export const useEnable = () => useChatStore(portalThreadSelectors.showThread);
|
|
5
|
-
|
|
6
|
-
export const onClose = () => {
|
|
7
|
-
useChatStore.setState({ portalThreadId: undefined });
|
|
8
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { type DocumentType } from '@lobechat/builtin-tool-notebook';
|
|
2
|
-
import { type DocumentItem } from '@lobechat/database/schemas';
|
|
3
|
-
import { type NotebookDocument } from '@lobechat/types';
|
|
4
|
-
import isEqual from 'fast-deep-equal';
|
|
5
|
-
import { type SWRResponse, mutate } from 'swr';
|
|
6
|
-
import { type StateCreator } from 'zustand/vanilla';
|
|
7
|
-
|
|
8
|
-
import { useClientDataSWR } from '@/libs/swr';
|
|
9
|
-
import { notebookService } from '@/services/notebook';
|
|
10
|
-
import { useChatStore } from '@/store/chat';
|
|
11
|
-
import { setNamespace } from '@/utils/storeDebug';
|
|
12
|
-
|
|
13
|
-
import type { DocumentStore } from '../../store';
|
|
14
|
-
|
|
15
|
-
const n = setNamespace('document/notebook');
|
|
16
|
-
|
|
17
|
-
const SWR_USE_FETCH_NOTEBOOK_DOCUMENTS = 'SWR_USE_FETCH_NOTEBOOK_DOCUMENTS';
|
|
18
|
-
|
|
19
|
-
type ExtendedDocumentType = DocumentType | 'agent/plan';
|
|
20
|
-
|
|
21
|
-
interface CreateDocumentParams {
|
|
22
|
-
content: string;
|
|
23
|
-
description: string;
|
|
24
|
-
title: string;
|
|
25
|
-
topicId: string;
|
|
26
|
-
type?: ExtendedDocumentType;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface UpdateDocumentParams {
|
|
30
|
-
content?: string;
|
|
31
|
-
description?: string;
|
|
32
|
-
id: string;
|
|
33
|
-
title?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface NotebookAction {
|
|
37
|
-
createDocument: (params: CreateDocumentParams) => Promise<DocumentItem>;
|
|
38
|
-
deleteDocument: (id: string, topicId: string) => Promise<void>;
|
|
39
|
-
refreshDocuments: (topicId: string) => Promise<void>;
|
|
40
|
-
updateDocument: (
|
|
41
|
-
params: UpdateDocumentParams,
|
|
42
|
-
topicId: string,
|
|
43
|
-
) => Promise<DocumentItem | undefined>;
|
|
44
|
-
useFetchDocuments: (topicId: string | undefined) => SWRResponse<NotebookDocument[]>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const createNotebookSlice: StateCreator<
|
|
48
|
-
DocumentStore,
|
|
49
|
-
[['zustand/devtools', never]],
|
|
50
|
-
[],
|
|
51
|
-
NotebookAction
|
|
52
|
-
> = (set, get) => ({
|
|
53
|
-
createDocument: async (params) => {
|
|
54
|
-
const document = await notebookService.createDocument(params);
|
|
55
|
-
|
|
56
|
-
// Refresh the documents list
|
|
57
|
-
await mutate([SWR_USE_FETCH_NOTEBOOK_DOCUMENTS, params.topicId]);
|
|
58
|
-
|
|
59
|
-
return document;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
deleteDocument: async (id, topicId) => {
|
|
63
|
-
// If the deleted document is currently open, close it
|
|
64
|
-
const portalDocumentId = useChatStore.getState().portalDocumentId;
|
|
65
|
-
if (portalDocumentId === id) {
|
|
66
|
-
useChatStore.getState().closeDocument();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Call API to delete
|
|
70
|
-
await notebookService.deleteDocument(id);
|
|
71
|
-
|
|
72
|
-
// Refresh the documents list
|
|
73
|
-
await mutate([SWR_USE_FETCH_NOTEBOOK_DOCUMENTS, topicId]);
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
refreshDocuments: async (topicId) => {
|
|
77
|
-
await mutate([SWR_USE_FETCH_NOTEBOOK_DOCUMENTS, topicId]);
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
updateDocument: async (params, topicId) => {
|
|
81
|
-
const document = await notebookService.updateDocument(params);
|
|
82
|
-
|
|
83
|
-
// Refresh the documents list
|
|
84
|
-
await mutate([SWR_USE_FETCH_NOTEBOOK_DOCUMENTS, topicId]);
|
|
85
|
-
|
|
86
|
-
return document;
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
useFetchDocuments: (topicId) => {
|
|
90
|
-
return useClientDataSWR<NotebookDocument[]>(
|
|
91
|
-
topicId ? [SWR_USE_FETCH_NOTEBOOK_DOCUMENTS, topicId] : null,
|
|
92
|
-
async () => {
|
|
93
|
-
if (!topicId) return [];
|
|
94
|
-
|
|
95
|
-
const result = await notebookService.listDocuments({ topicId });
|
|
96
|
-
|
|
97
|
-
return result.data;
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
onSuccess: (documents) => {
|
|
101
|
-
if (!topicId) return;
|
|
102
|
-
|
|
103
|
-
const currentDocuments = get().notebookMap[topicId];
|
|
104
|
-
|
|
105
|
-
// Skip update if data is the same
|
|
106
|
-
if (currentDocuments && isEqual(documents, currentDocuments)) return;
|
|
107
|
-
|
|
108
|
-
set(
|
|
109
|
-
{
|
|
110
|
-
notebookMap: { ...get().notebookMap, [topicId]: documents },
|
|
111
|
-
},
|
|
112
|
-
false,
|
|
113
|
-
n('useFetchDocuments(onSuccess)', { topicId }),
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type NotebookDocument } from '@lobechat/types';
|
|
2
|
-
|
|
3
|
-
export interface NotebookState {
|
|
4
|
-
/**
|
|
5
|
-
* Map of topicId -> notebook documents list
|
|
6
|
-
*/
|
|
7
|
-
notebookMap: Record<string, NotebookDocument[]>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const initialNotebookState: NotebookState = {
|
|
11
|
-
notebookMap: {},
|
|
12
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { DocumentStore } from '../../store';
|
|
2
|
-
|
|
3
|
-
const getDocumentById =
|
|
4
|
-
(topicId: string | undefined, documentId: string | undefined) => (s: DocumentStore) => {
|
|
5
|
-
if (!topicId || !documentId) return null;
|
|
6
|
-
const docs = s.notebookMap[topicId];
|
|
7
|
-
if (!docs) return null;
|
|
8
|
-
return docs.find((d) => d.id === documentId) || null;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const getDocumentsByTopicId = (topicId: string | undefined) => (s: DocumentStore) => {
|
|
12
|
-
if (!topicId) return [];
|
|
13
|
-
return s.notebookMap[topicId] || [];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const hasDocuments = (topicId: string | undefined) => (s: DocumentStore) => {
|
|
17
|
-
if (!topicId) return false;
|
|
18
|
-
const docs = s.notebookMap[topicId];
|
|
19
|
-
return docs && docs.length > 0;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const notebookSelectors = {
|
|
23
|
-
getDocumentById,
|
|
24
|
-
getDocumentsByTopicId,
|
|
25
|
-
hasDocuments,
|
|
26
|
-
};
|