@lobehub/chat 1.57.0 → 1.57.1
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/package.json +1 -1
- package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Files/FileItem/File.tsx +1 -1
- package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/index.tsx +19 -9
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/index.tsx +1 -2
- package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Main.tsx +15 -1
- package/src/app/[variants]/(main)/chat/(workspace)/_layout/Mobile/ChatHeader/index.tsx +0 -2
- package/src/app/[variants]/(main)/chat/(workspace)/features/AgentSettings/index.tsx +1 -1
- package/src/app/[variants]/(main)/chat/settings/page.tsx +95 -5
- package/src/features/AgentSetting/AgentMeta/index.tsx +19 -9
- package/src/features/AgentSetting/AgentPrompt/index.tsx +32 -2
- package/src/features/AgentSetting/AgentSettings.tsx +4 -5
- package/src/features/AgentSetting/AgentSettingsProvider.tsx +17 -0
- package/src/features/AgentSetting/StoreUpdater.tsx +5 -2
- package/src/features/AgentSetting/index.tsx +1 -1
- package/src/features/AgentSetting/store/initialState.ts +2 -1
- package/src/hooks/useInterceptingRoutes.test.ts +1 -1
- package/src/hooks/useInterceptingRoutes.ts +1 -1
- package/src/layout/GlobalProvider/StoreInitialization.tsx +1 -1
- package/src/store/agent/slices/chat/action.test.ts +3 -3
- package/src/store/agent/slices/chat/action.ts +2 -5
- package/src/app/[variants]/(main)/chat/settings/features/EditPage.tsx +0 -45
- package/src/features/AgentSetting/AgentSettingsStore.tsx +0 -14
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Files/FileItem/Image.tsx +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Files/FileItem/index.tsx +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Files/FileItem/style.ts +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Files/index.tsx +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/InputArea/Container.tsx +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/InputArea/index.tsx +0 -0
- /package/src/{features → app/[variants]/(main)/chat/(workspace)/@conversation/features}/ChatInput/Mobile/Send.tsx +0 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.57.1](https://github.com/lobehub/lobe-chat/compare/v1.57.0...v1.57.1)
|
6
|
+
|
7
|
+
<sup>Released on **2025-02-16**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Fix mobile agent settings not show correctly.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Fix mobile agent settings not show correctly, closes [#6203](https://github.com/lobehub/lobe-chat/issues/6203) ([0285d95](https://github.com/lobehub/lobe-chat/commit/0285d95))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
## [Version 1.57.0](https://github.com/lobehub/lobe-chat/compare/v1.56.5...v1.57.0)
|
6
31
|
|
7
32
|
<sup>Released on **2025-02-16**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.57.
|
3
|
+
"version": "1.57.1",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -8,7 +8,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
import FileIcon from '@/components/FileIcon';
|
9
9
|
import { UploadFileItem } from '@/types/files';
|
10
10
|
|
11
|
-
import UploadDetail from '
|
11
|
+
import UploadDetail from '../../../../../../../../../../../features/ChatInput/components/UploadDetail';
|
12
12
|
|
13
13
|
const useStyles = createStyles(({ css, token }) => ({
|
14
14
|
container: css`
|
@@ -1,8 +1,10 @@
|
|
1
1
|
'use client';
|
2
2
|
|
3
|
+
import { Skeleton } from 'antd';
|
3
4
|
import { useTheme } from 'antd-style';
|
4
5
|
import { TextAreaRef } from 'antd/es/input/TextArea';
|
5
6
|
import { memo, useRef, useState } from 'react';
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
6
8
|
|
7
9
|
import ActionBar from '@/features/ChatInput/ActionBar';
|
8
10
|
import { ActionKeys } from '@/features/ChatInput/ActionBar/config';
|
@@ -12,6 +14,7 @@ import { useSendMessage } from '@/features/ChatInput/useSend';
|
|
12
14
|
import { useChatStore } from '@/store/chat';
|
13
15
|
import { chatSelectors } from '@/store/chat/selectors';
|
14
16
|
|
17
|
+
import { useInitAgentConfig } from '../../../../_layout/useInitAgentConfig';
|
15
18
|
import Files from './Files';
|
16
19
|
import InputArea from './InputArea';
|
17
20
|
import SendButton from './Send';
|
@@ -33,6 +36,7 @@ const MobileChatInput = memo(() => {
|
|
33
36
|
const ref = useRef<TextAreaRef>(null);
|
34
37
|
const [expand, setExpand] = useState<boolean>(false);
|
35
38
|
const { send: sendMessage, canSend } = useSendMessage();
|
39
|
+
const { isLoading } = useInitAgentConfig();
|
36
40
|
|
37
41
|
const [loading, value, onInput, onStop] = useChatStore((s) => [
|
38
42
|
chatSelectors.isAIGenerating(s),
|
@@ -63,15 +67,21 @@ const MobileChatInput = memo(() => {
|
|
63
67
|
<SendButton disabled={!canSend} loading={loading} onSend={sendMessage} onStop={onStop} />
|
64
68
|
}
|
65
69
|
topAddons={
|
66
|
-
|
67
|
-
<
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
isLoading ? (
|
71
|
+
<Flexbox paddingInline={8}>
|
72
|
+
<Skeleton.Button active block size={'small'} />
|
73
|
+
</Flexbox>
|
74
|
+
) : (
|
75
|
+
<>
|
76
|
+
<Files />
|
77
|
+
<ActionBar
|
78
|
+
leftActions={defaultLeftActions}
|
79
|
+
padding={'0 8px'}
|
80
|
+
rightActions={defaultRightActions}
|
81
|
+
rightAreaStartRender={<SaveTopic mobile />}
|
82
|
+
/>
|
83
|
+
</>
|
84
|
+
)
|
75
85
|
}
|
76
86
|
value={value}
|
77
87
|
/>
|
package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/index.tsx
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import MobileChatInput from '@/features/ChatInput/Mobile';
|
2
|
-
|
3
1
|
import DesktopChatInput from './Desktop';
|
2
|
+
import MobileChatInput from './Mobile';
|
4
3
|
|
5
4
|
const ChatInput = ({ mobile }: { mobile: boolean }) => {
|
6
5
|
const Input = mobile ? MobileChatInput : DesktopChatInput;
|
@@ -42,7 +42,21 @@ const Main = memo(() => {
|
|
42
42
|
const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
|
43
43
|
|
44
44
|
return !init ? (
|
45
|
-
<Flexbox horizontal>
|
45
|
+
<Flexbox gap={4} horizontal>
|
46
|
+
{!isPinned && (
|
47
|
+
<ActionIcon
|
48
|
+
aria-label={t('agents')}
|
49
|
+
icon={showSessionPanel ? PanelLeftClose : PanelLeftOpen}
|
50
|
+
onClick={() => {
|
51
|
+
updateSystemStatus({
|
52
|
+
sessionsWidth: showSessionPanel ? 0 : 320,
|
53
|
+
showSessionPanel: !showSessionPanel,
|
54
|
+
});
|
55
|
+
}}
|
56
|
+
size={DESKTOP_HEADER_ICON_SIZE}
|
57
|
+
title={t('agents')}
|
58
|
+
/>
|
59
|
+
)}
|
46
60
|
<Skeleton
|
47
61
|
active
|
48
62
|
avatar={{ shape: 'circle', size: 'default' }}
|
@@ -3,7 +3,6 @@
|
|
3
3
|
import { MobileNavBar } from '@lobehub/ui/mobile';
|
4
4
|
import { memo, useState } from 'react';
|
5
5
|
|
6
|
-
import { useInitAgentConfig } from '@/app/[variants]/(main)/chat/(workspace)/_layout/useInitAgentConfig';
|
7
6
|
import { INBOX_SESSION_ID } from '@/const/session';
|
8
7
|
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
9
8
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
@@ -17,7 +16,6 @@ const MobileHeader = memo(() => {
|
|
17
16
|
const [open, setOpen] = useState(false);
|
18
17
|
|
19
18
|
const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
|
20
|
-
useInitAgentConfig();
|
21
19
|
|
22
20
|
return (
|
23
21
|
<MobileNavBar
|
@@ -101,7 +101,7 @@ const AgentSettings = memo(() => {
|
|
101
101
|
width={'100%'}
|
102
102
|
>
|
103
103
|
{tab === ChatSettingsTabs.Meta && <AgentMeta />}
|
104
|
-
{tab === ChatSettingsTabs.Prompt && <AgentPrompt
|
104
|
+
{tab === ChatSettingsTabs.Prompt && <AgentPrompt />}
|
105
105
|
{tab === ChatSettingsTabs.Chat && <AgentChat />}
|
106
106
|
{tab === ChatSettingsTabs.Modal && <AgentModal />}
|
107
107
|
{tab === ChatSettingsTabs.TTS && <AgentTTS />}
|
@@ -1,7 +1,97 @@
|
|
1
|
-
|
1
|
+
'use client';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
};
|
3
|
+
import { TabsNav } from '@lobehub/ui';
|
4
|
+
import isEqual from 'fast-deep-equal';
|
5
|
+
import { memo, useState } from 'react';
|
6
|
+
import { useTranslation } from 'react-i18next';
|
6
7
|
|
7
|
-
|
8
|
+
import PageTitle from '@/components/PageTitle';
|
9
|
+
import { INBOX_SESSION_ID } from '@/const/session';
|
10
|
+
import { AgentSettingsProvider } from '@/features/AgentSetting';
|
11
|
+
import AgentChat from '@/features/AgentSetting/AgentChat';
|
12
|
+
import AgentMeta from '@/features/AgentSetting/AgentMeta';
|
13
|
+
import AgentModal from '@/features/AgentSetting/AgentModal';
|
14
|
+
import AgentPlugin from '@/features/AgentSetting/AgentPlugin';
|
15
|
+
import AgentPrompt from '@/features/AgentSetting/AgentPrompt';
|
16
|
+
import AgentTTS from '@/features/AgentSetting/AgentTTS';
|
17
|
+
import { useAgentStore } from '@/store/agent';
|
18
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
19
|
+
import { ChatSettingsTabs } from '@/store/global/initialState';
|
20
|
+
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
21
|
+
import { useSessionStore } from '@/store/session';
|
22
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
23
|
+
|
24
|
+
const EditPage = memo(() => {
|
25
|
+
const { t } = useTranslation('setting');
|
26
|
+
const [tab, setTab] = useState(ChatSettingsTabs.Prompt);
|
27
|
+
|
28
|
+
const [id, updateAgentMeta, title] = useSessionStore((s) => [
|
29
|
+
s.activeId,
|
30
|
+
s.updateSessionMeta,
|
31
|
+
sessionMetaSelectors.currentAgentTitle(s),
|
32
|
+
]);
|
33
|
+
const [useFetchAgentConfig, updateAgentConfig] = useAgentStore((s) => [
|
34
|
+
s.useFetchAgentConfig,
|
35
|
+
s.updateAgentConfig,
|
36
|
+
]);
|
37
|
+
|
38
|
+
const config = useAgentStore(agentSelectors.currentAgentConfig, isEqual);
|
39
|
+
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
40
|
+
|
41
|
+
const { isLoading } = useFetchAgentConfig(id);
|
42
|
+
const { enablePlugins } = useServerConfigStore(featureFlagsSelectors);
|
43
|
+
|
44
|
+
return (
|
45
|
+
<>
|
46
|
+
<PageTitle title={t('header.sessionWithName', { name: title })} />
|
47
|
+
|
48
|
+
<TabsNav
|
49
|
+
items={[
|
50
|
+
{
|
51
|
+
key: ChatSettingsTabs.Prompt,
|
52
|
+
label: t('settingAgent.prompt.title'),
|
53
|
+
},
|
54
|
+
(id !== INBOX_SESSION_ID && {
|
55
|
+
key: ChatSettingsTabs.Meta,
|
56
|
+
label: t('settingAgent.title'),
|
57
|
+
}) as any,
|
58
|
+
{
|
59
|
+
key: ChatSettingsTabs.Chat,
|
60
|
+
label: t('settingChat.title'),
|
61
|
+
},
|
62
|
+
{
|
63
|
+
key: ChatSettingsTabs.Modal,
|
64
|
+
label: t('settingModel.title'),
|
65
|
+
},
|
66
|
+
{
|
67
|
+
key: ChatSettingsTabs.TTS,
|
68
|
+
label: t('settingTTS.title'),
|
69
|
+
},
|
70
|
+
(enablePlugins && {
|
71
|
+
key: ChatSettingsTabs.Plugin,
|
72
|
+
label: t('settingPlugin.title'),
|
73
|
+
}) as any,
|
74
|
+
]}
|
75
|
+
onChange={(value) => setTab(value as ChatSettingsTabs)}
|
76
|
+
variant={'compact'}
|
77
|
+
/>
|
78
|
+
<AgentSettingsProvider
|
79
|
+
config={config}
|
80
|
+
id={id}
|
81
|
+
loading={isLoading}
|
82
|
+
meta={meta}
|
83
|
+
onConfigChange={updateAgentConfig}
|
84
|
+
onMetaChange={updateAgentMeta}
|
85
|
+
>
|
86
|
+
{tab === ChatSettingsTabs.Prompt && <AgentPrompt modal />}
|
87
|
+
{tab === ChatSettingsTabs.Meta && <AgentMeta />}
|
88
|
+
{tab === ChatSettingsTabs.Chat && <AgentChat />}
|
89
|
+
{tab === ChatSettingsTabs.Modal && <AgentModal />}
|
90
|
+
{tab === ChatSettingsTabs.TTS && <AgentTTS />}
|
91
|
+
{tab === ChatSettingsTabs.Plugin && <AgentPlugin />}
|
92
|
+
</AgentSettingsProvider>
|
93
|
+
</>
|
94
|
+
);
|
95
|
+
});
|
96
|
+
|
97
|
+
export default EditPage;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use client';
|
2
2
|
|
3
3
|
import { Form, type FormItemProps, Icon, type ItemGroup, Tooltip } from '@lobehub/ui';
|
4
|
-
import { Button } from 'antd';
|
4
|
+
import { Button, Skeleton } from 'antd';
|
5
5
|
import isEqual from 'fast-deep-equal';
|
6
6
|
import { isString } from 'lodash-es';
|
7
7
|
import { Wand2 } from 'lucide-react';
|
@@ -27,7 +27,11 @@ const AgentMeta = memo(() => {
|
|
27
27
|
s.autocompleteMeta,
|
28
28
|
s.autocompleteAllMeta,
|
29
29
|
]);
|
30
|
-
const [isInbox,
|
30
|
+
const [isInbox, isIniting, autocompleteLoading] = useStore((s) => [
|
31
|
+
s.id === INBOX_SESSION_ID,
|
32
|
+
s.loading,
|
33
|
+
s.autocompleteLoading,
|
34
|
+
]);
|
31
35
|
const meta = useStore((s) => s.meta, isEqual);
|
32
36
|
|
33
37
|
if (isInbox) return;
|
@@ -59,10 +63,12 @@ const AgentMeta = memo(() => {
|
|
59
63
|
const autocompleteItems: FormItemProps[] = basic.map((item) => {
|
60
64
|
const AutoGenerate = item.Render;
|
61
65
|
return {
|
62
|
-
children: (
|
66
|
+
children: isIniting ? (
|
67
|
+
<Skeleton.Button active block size={'small'} />
|
68
|
+
) : (
|
63
69
|
<AutoGenerate
|
64
70
|
canAutoGenerate={hasSystemRole}
|
65
|
-
loading={
|
71
|
+
loading={autocompleteLoading[item.key as keyof SessionLoadingState]}
|
66
72
|
onChange={item.onChange}
|
67
73
|
onGenerate={() => {
|
68
74
|
autocompleteMeta(item.key as keyof typeof meta);
|
@@ -78,11 +84,13 @@ const AgentMeta = memo(() => {
|
|
78
84
|
const metaData: ItemGroup = {
|
79
85
|
children: [
|
80
86
|
{
|
81
|
-
children: (
|
87
|
+
children: isIniting ? (
|
88
|
+
<Skeleton.Button active block size={'small'} />
|
89
|
+
) : (
|
82
90
|
<AutoGenerateAvatar
|
83
91
|
background={meta.backgroundColor}
|
84
92
|
canAutoGenerate={hasSystemRole}
|
85
|
-
loading={
|
93
|
+
loading={autocompleteLoading['avatar']}
|
86
94
|
onChange={(avatar) => updateMeta({ avatar })}
|
87
95
|
onGenerate={() => autocompleteMeta('avatar')}
|
88
96
|
value={meta.avatar}
|
@@ -92,7 +100,9 @@ const AgentMeta = memo(() => {
|
|
92
100
|
minWidth: undefined,
|
93
101
|
},
|
94
102
|
{
|
95
|
-
children: (
|
103
|
+
children: isIniting ? (
|
104
|
+
<Skeleton.Button active block size={'small'} />
|
105
|
+
) : (
|
96
106
|
<BackgroundSwatches
|
97
107
|
backgroundColor={meta.backgroundColor}
|
98
108
|
onChange={(backgroundColor) => updateMeta({ backgroundColor })}
|
@@ -103,7 +113,7 @@ const AgentMeta = memo(() => {
|
|
103
113
|
},
|
104
114
|
...autocompleteItems,
|
105
115
|
],
|
106
|
-
extra: (
|
116
|
+
extra: !isIniting && (
|
107
117
|
<Tooltip
|
108
118
|
title={
|
109
119
|
!hasSystemRole
|
@@ -114,7 +124,7 @@ const AgentMeta = memo(() => {
|
|
114
124
|
<Button
|
115
125
|
disabled={!hasSystemRole}
|
116
126
|
icon={<Icon icon={Wand2} />}
|
117
|
-
loading={Object.values(
|
127
|
+
loading={Object.values(autocompleteLoading).some((i) => !!i)}
|
118
128
|
onClick={(e: any) => {
|
119
129
|
e.stopPropagation();
|
120
130
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use client';
|
2
2
|
|
3
3
|
import { EditableMessage, Form } from '@lobehub/ui';
|
4
|
-
import { Button } from 'antd';
|
4
|
+
import { Button, Skeleton } from 'antd';
|
5
5
|
import { createStyles } from 'antd-style';
|
6
6
|
import { memo, useState } from 'react';
|
7
7
|
import { useTranslation } from 'react-i18next';
|
@@ -40,7 +40,37 @@ const AgentPrompt = memo<{ modal?: boolean }>(({ modal }) => {
|
|
40
40
|
const { t } = useTranslation('setting');
|
41
41
|
const { styles } = useStyles();
|
42
42
|
const [editing, setEditing] = useState(false);
|
43
|
-
const [systemRole, updateConfig] = useStore((s) => [
|
43
|
+
const [loading, systemRole, updateConfig] = useStore((s) => [
|
44
|
+
s.loading,
|
45
|
+
s.config.systemRole,
|
46
|
+
s.setAgentConfig,
|
47
|
+
]);
|
48
|
+
|
49
|
+
if (loading) {
|
50
|
+
return (
|
51
|
+
<div className={styles.wrapper}>
|
52
|
+
<Flexbox className={styles.container} padding={4}>
|
53
|
+
<Flexbox horizontal justify={'space-between'} paddingBlock={8} paddingInline={12}>
|
54
|
+
<h1 style={{ fontSize: 18, fontWeight: 'bold', marginBottom: 4 }}>
|
55
|
+
{t('settingAgent.prompt.title')}
|
56
|
+
</h1>
|
57
|
+
</Flexbox>
|
58
|
+
<Flexbox
|
59
|
+
align={'center'}
|
60
|
+
className={styles.content}
|
61
|
+
flex={1}
|
62
|
+
gap={16}
|
63
|
+
horizontal
|
64
|
+
justify={'space-between'}
|
65
|
+
padding={12}
|
66
|
+
wrap={'wrap'}
|
67
|
+
>
|
68
|
+
<Skeleton active style={{ paddingTop: 12 }} title={false} />
|
69
|
+
</Flexbox>
|
70
|
+
</Flexbox>
|
71
|
+
</div>
|
72
|
+
);
|
73
|
+
}
|
44
74
|
|
45
75
|
const content = (
|
46
76
|
<EditableMessage
|
@@ -5,23 +5,22 @@ import AgentMeta from './AgentMeta';
|
|
5
5
|
import AgentModal from './AgentModal';
|
6
6
|
import AgentPlugin from './AgentPlugin';
|
7
7
|
import AgentPrompt from './AgentPrompt';
|
8
|
+
import { AgentSettingsProvider } from './AgentSettingsProvider';
|
8
9
|
import AgentTTS from './AgentTTS';
|
9
|
-
import
|
10
|
-
import { Provider, createStore } from './store';
|
10
|
+
import { StoreUpdaterProps } from './StoreUpdater';
|
11
11
|
|
12
12
|
type AgentSettingsProps = StoreUpdaterProps;
|
13
13
|
|
14
14
|
export const AgentSettings = (props: AgentSettingsProps) => {
|
15
15
|
const { enablePlugins } = useServerConfigStore(featureFlagsSelectors);
|
16
16
|
return (
|
17
|
-
<
|
18
|
-
<StoreUpdater {...props} />
|
17
|
+
<AgentSettingsProvider {...props}>
|
19
18
|
<AgentPrompt />
|
20
19
|
<AgentMeta />
|
21
20
|
<AgentChat />
|
22
21
|
<AgentModal />
|
23
22
|
<AgentTTS />
|
24
23
|
{enablePlugins && <AgentPlugin />}
|
25
|
-
</
|
24
|
+
</AgentSettingsProvider>
|
26
25
|
);
|
27
26
|
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ReactNode, memo } from 'react';
|
2
|
+
|
3
|
+
import StoreUpdater, { StoreUpdaterProps } from './StoreUpdater';
|
4
|
+
import { Provider, createStore } from './store';
|
5
|
+
|
6
|
+
interface AgentSettingsProps extends StoreUpdaterProps {
|
7
|
+
children: ReactNode;
|
8
|
+
}
|
9
|
+
|
10
|
+
export const AgentSettingsProvider = memo<AgentSettingsProps>(({ children, ...props }) => {
|
11
|
+
return (
|
12
|
+
<Provider createStore={createStore}>
|
13
|
+
<StoreUpdater {...props} />
|
14
|
+
{children}
|
15
|
+
</Provider>
|
16
|
+
);
|
17
|
+
});
|
@@ -7,12 +7,14 @@ import { AgentSettingsInstance, useAgentSettings } from './hooks/useAgentSetting
|
|
7
7
|
import { State, useStoreApi } from './store';
|
8
8
|
|
9
9
|
export interface StoreUpdaterProps
|
10
|
-
extends Partial<
|
10
|
+
extends Partial<
|
11
|
+
Pick<State, 'onMetaChange' | 'onConfigChange' | 'meta' | 'config' | 'id' | 'loading'>
|
12
|
+
> {
|
11
13
|
instanceRef?: ForwardedRef<AgentSettingsInstance> | null;
|
12
14
|
}
|
13
15
|
|
14
16
|
const StoreUpdater = memo<StoreUpdaterProps>(
|
15
|
-
({ onConfigChange, instanceRef, id, onMetaChange, meta, config }) => {
|
17
|
+
({ onConfigChange, instanceRef, id, onMetaChange, meta, config, loading }) => {
|
16
18
|
const storeApi = useStoreApi();
|
17
19
|
const useStoreUpdater = createStoreUpdater(storeApi);
|
18
20
|
|
@@ -20,6 +22,7 @@ const StoreUpdater = memo<StoreUpdaterProps>(
|
|
20
22
|
useStoreUpdater('config', config);
|
21
23
|
useStoreUpdater('onConfigChange', onConfigChange);
|
22
24
|
useStoreUpdater('onMetaChange', onMetaChange);
|
25
|
+
useStoreUpdater('loading', loading);
|
23
26
|
useStoreUpdater('id', id);
|
24
27
|
|
25
28
|
const instance = useAgentSettings();
|
@@ -7,8 +7,9 @@ export interface State {
|
|
7
7
|
autocompleteLoading: SessionLoadingState;
|
8
8
|
config: LobeAgentConfig;
|
9
9
|
id?: string;
|
10
|
-
|
10
|
+
loading?: boolean;
|
11
11
|
|
12
|
+
meta: MetaData;
|
12
13
|
onConfigChange?: (config: LobeAgentConfig) => void;
|
13
14
|
onMetaChange?: (meta: MetaData) => void;
|
14
15
|
}
|
@@ -43,7 +43,7 @@ describe('useOpenChatSettings', () => {
|
|
43
43
|
vi.mocked(useSessionStore).mockReturnValue('123');
|
44
44
|
vi.mocked(useIsMobile).mockReturnValue(true);
|
45
45
|
const { result } = renderHook(() => useOpenChatSettings(ChatSettingsTabs.Meta));
|
46
|
-
expect(result.current()).toBe('/chat/settings');
|
46
|
+
expect(result.current()).toBe('/chat/settings?session=123');
|
47
47
|
});
|
48
48
|
|
49
49
|
it('should handle desktop route for chat settings with session and tab', () => {
|
@@ -20,7 +20,7 @@ export const useOpenChatSettings = (tab: ChatSettingsTabs = ChatSettingsTabs.Met
|
|
20
20
|
return () => router.push(urlJoin('/settings', SettingsTabs.Agent));
|
21
21
|
}
|
22
22
|
|
23
|
-
if (isMobile) return () => router.push('/chat/settings');
|
23
|
+
if (isMobile) return () => router.push('/chat/settings', { query: { session: activeId } });
|
24
24
|
|
25
25
|
return () => {
|
26
26
|
useAgentStore.setState({ showAgentSetting: true });
|
@@ -32,7 +32,7 @@ const StoreInitialization = memo(() => {
|
|
32
32
|
|
33
33
|
const useInitSystemStatus = useGlobalStore((s) => s.useInitSystemStatus);
|
34
34
|
|
35
|
-
const useInitAgentStore = useAgentStore((s) => s.
|
35
|
+
const useInitAgentStore = useAgentStore((s) => s.useInitInboxAgentStore);
|
36
36
|
const useInitAiProviderKeyVaults = useAiInfraStore((s) => s.useFetchAiProviderRuntimeState);
|
37
37
|
|
38
38
|
// init the system preference
|
@@ -216,7 +216,7 @@ describe('AgentSlice', () => {
|
|
216
216
|
model: 'gemini-pro',
|
217
217
|
} as any);
|
218
218
|
|
219
|
-
renderHook(() => result.current.
|
219
|
+
renderHook(() => result.current.useInitInboxAgentStore(true));
|
220
220
|
|
221
221
|
await waitFor(async () => {
|
222
222
|
expect(result.current.agentMap[INBOX_SESSION_ID]).toEqual({ model: 'gemini-pro' });
|
@@ -230,7 +230,7 @@ describe('AgentSlice', () => {
|
|
230
230
|
model: 'gemini-pro',
|
231
231
|
} as any);
|
232
232
|
|
233
|
-
renderHook(() => result.current.
|
233
|
+
renderHook(() => result.current.useInitInboxAgentStore(false));
|
234
234
|
|
235
235
|
await waitFor(async () => {
|
236
236
|
expect(result.current.agentMap[INBOX_SESSION_ID]).toBeUndefined();
|
@@ -243,7 +243,7 @@ describe('AgentSlice', () => {
|
|
243
243
|
|
244
244
|
vi.spyOn(globalService, 'getDefaultAgentConfig').mockRejectedValueOnce(new Error());
|
245
245
|
|
246
|
-
renderHook(() => result.current.
|
246
|
+
renderHook(() => result.current.useInitInboxAgentStore(true));
|
247
247
|
|
248
248
|
await waitFor(async () => {
|
249
249
|
expect(result.current.agentMap[INBOX_SESSION_ID]).toBeUndefined();
|
@@ -6,7 +6,6 @@ import { StateCreator } from 'zustand/vanilla';
|
|
6
6
|
|
7
7
|
import { MESSAGE_CANCEL_FLAT } from '@/const/message';
|
8
8
|
import { INBOX_SESSION_ID } from '@/const/session';
|
9
|
-
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
10
9
|
import { useClientDataSWR, useOnlyFetchOnceSWR } from '@/libs/swr';
|
11
10
|
import { agentService } from '@/services/agent';
|
12
11
|
import { sessionService } from '@/services/session';
|
@@ -51,7 +50,7 @@ export interface AgentChatAction {
|
|
51
50
|
updateAgentConfig: (config: DeepPartial<LobeAgentConfig>) => Promise<void>;
|
52
51
|
useFetchAgentConfig: (id: string) => SWRResponse<LobeAgentConfig>;
|
53
52
|
useFetchFilesAndKnowledgeBases: () => SWRResponse<KnowledgeItem[]>;
|
54
|
-
|
53
|
+
useInitInboxAgentStore: (
|
55
54
|
isLogin: boolean | undefined,
|
56
55
|
defaultAgentConfig?: DeepPartial<LobeAgentConfig>,
|
57
56
|
) => SWRResponse<DeepPartial<LobeAgentConfig>>;
|
@@ -164,12 +163,10 @@ export const createChatSlice: StateCreator<
|
|
164
163
|
[FETCH_AGENT_CONFIG_KEY, sessionId],
|
165
164
|
([, id]: string[]) => sessionService.getSessionConfig(id),
|
166
165
|
{
|
167
|
-
fallbackData: DEFAULT_AGENT_CONFIG,
|
168
166
|
onSuccess: (data) => {
|
169
167
|
get().internal_dispatchAgentMap(sessionId, data, 'fetch');
|
170
168
|
set({ activeAgentId: data.id }, false, 'updateActiveAgentId');
|
171
169
|
},
|
172
|
-
suspense: true,
|
173
170
|
},
|
174
171
|
),
|
175
172
|
useFetchFilesAndKnowledgeBases: () => {
|
@@ -183,7 +180,7 @@ export const createChatSlice: StateCreator<
|
|
183
180
|
);
|
184
181
|
},
|
185
182
|
|
186
|
-
|
183
|
+
useInitInboxAgentStore: (isLogin, defaultAgentConfig) =>
|
187
184
|
useOnlyFetchOnceSWR<DeepPartial<LobeAgentConfig>>(
|
188
185
|
!!isLogin ? 'fetchInboxAgentConfig' : null,
|
189
186
|
() => sessionService.getSessionConfig(INBOX_SESSION_ID),
|
@@ -1,45 +0,0 @@
|
|
1
|
-
'use client';
|
2
|
-
|
3
|
-
import isEqual from 'fast-deep-equal';
|
4
|
-
import { memo } from 'react';
|
5
|
-
import { useTranslation } from 'react-i18next';
|
6
|
-
|
7
|
-
import PageTitle from '@/components/PageTitle';
|
8
|
-
import { AgentSettings } from '@/features/AgentSetting';
|
9
|
-
import { useAgentStore } from '@/store/agent';
|
10
|
-
import { agentSelectors } from '@/store/agent/selectors';
|
11
|
-
import { useSessionStore } from '@/store/session';
|
12
|
-
import { sessionMetaSelectors } from '@/store/session/selectors';
|
13
|
-
|
14
|
-
const EditPage = memo(() => {
|
15
|
-
const { t } = useTranslation('setting');
|
16
|
-
const id = useSessionStore((s) => s.activeId);
|
17
|
-
const config = useAgentStore(agentSelectors.currentAgentConfig, isEqual);
|
18
|
-
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
19
|
-
const [useFetchAgentConfig, updateAgentConfig] = useAgentStore((s) => [
|
20
|
-
s.useFetchAgentConfig,
|
21
|
-
s.updateAgentConfig,
|
22
|
-
]);
|
23
|
-
|
24
|
-
const [updateAgentMeta, title] = useSessionStore((s) => [
|
25
|
-
s.updateSessionMeta,
|
26
|
-
sessionMetaSelectors.currentAgentTitle(s),
|
27
|
-
]);
|
28
|
-
|
29
|
-
useFetchAgentConfig(id);
|
30
|
-
|
31
|
-
return (
|
32
|
-
<>
|
33
|
-
<PageTitle title={t('header.sessionWithName', { name: title })} />
|
34
|
-
<AgentSettings
|
35
|
-
config={config}
|
36
|
-
id={id}
|
37
|
-
meta={meta}
|
38
|
-
onConfigChange={updateAgentConfig}
|
39
|
-
onMetaChange={updateAgentMeta}
|
40
|
-
/>
|
41
|
-
</>
|
42
|
-
);
|
43
|
-
});
|
44
|
-
|
45
|
-
export default EditPage;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { memo } from 'react';
|
2
|
-
|
3
|
-
import StoreUpdater, { StoreUpdaterProps } from './StoreUpdater';
|
4
|
-
import { Provider, createStore } from './store';
|
5
|
-
|
6
|
-
type AgentSettingsProps = StoreUpdaterProps;
|
7
|
-
|
8
|
-
export const AgentSettingsStore = memo<AgentSettingsProps>((props) => {
|
9
|
-
return (
|
10
|
-
<Provider createStore={createStore}>
|
11
|
-
<StoreUpdater {...props} />
|
12
|
-
</Provider>
|
13
|
-
);
|
14
|
-
});
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|