@lobehub/chat 0.150.9 → 0.150.10

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.json +1 -1
  3. package/src/app/chat/(desktop)/features/ChatHeader/Tags.tsx +3 -3
  4. package/src/app/chat/(desktop)/features/ChatInput/Footer/DragUpload.tsx +3 -3
  5. package/src/app/chat/(desktop)/features/ChatInput/Footer/SendMore.tsx +3 -3
  6. package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +3 -3
  7. package/src/app/chat/(desktop)/features/ChatInput/TextArea.test.tsx +5 -5
  8. package/src/app/chat/(desktop)/features/ChatInput/TextArea.tsx +3 -3
  9. package/src/app/chat/(mobile)/features/SessionHeader.tsx +3 -3
  10. package/src/app/chat/features/ShareButton/ShareModal.tsx +3 -3
  11. package/src/app/chat/features/TelemetryNotification/index.tsx +2 -2
  12. package/src/app/chat/features/TopicListContent/Topic/index.tsx +2 -2
  13. package/src/app/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +3 -3
  14. package/src/app/settings/(mobile)/index.tsx +3 -3
  15. package/src/app/settings/about/Analytics.tsx +4 -4
  16. package/src/app/settings/agent/Agent.tsx +4 -4
  17. package/src/app/settings/common/Common.tsx +4 -4
  18. package/src/app/settings/common/Theme.tsx +4 -4
  19. package/src/app/settings/features/ThemeSwatches/ThemeSwatchesNeutral.tsx +3 -3
  20. package/src/app/settings/features/ThemeSwatches/ThemeSwatchesPrimary.tsx +3 -3
  21. package/src/app/settings/hooks/useSyncSettings.ts +3 -3
  22. package/src/app/settings/llm/Azure/index.tsx +3 -3
  23. package/src/app/settings/llm/components/ProviderConfig/index.tsx +3 -3
  24. package/src/app/settings/llm/components/ProviderModelList/CustomModelOption.tsx +4 -4
  25. package/src/app/settings/llm/components/ProviderModelList/ModelConfigModal.tsx +4 -4
  26. package/src/app/settings/llm/components/ProviderModelList/ModelFetcher.tsx +6 -6
  27. package/src/app/settings/llm/components/ProviderModelList/Option.tsx +3 -3
  28. package/src/app/settings/llm/components/ProviderModelList/index.tsx +6 -6
  29. package/src/app/settings/sync/Alert.tsx +3 -3
  30. package/src/app/settings/sync/DeviceInfo/DeviceName.tsx +3 -3
  31. package/src/app/settings/sync/WebRTC/index.tsx +2 -2
  32. package/src/app/settings/tts/TTS/index.tsx +4 -4
  33. package/src/chains/__tests__/summaryAgentName.test.ts +2 -2
  34. package/src/chains/__tests__/summaryDescription.test.ts +2 -2
  35. package/src/chains/__tests__/summaryTags.test.ts +2 -2
  36. package/src/chains/__tests__/summaryTitle.test.ts +2 -2
  37. package/src/chains/summaryAgentName.ts +1 -1
  38. package/src/chains/summaryDescription.ts +1 -1
  39. package/src/chains/summaryTags.ts +1 -1
  40. package/src/chains/summaryTitle.ts +1 -1
  41. package/src/features/AgentSetting/AgentConfig/ModelSelect.tsx +3 -6
  42. package/src/features/AgentSetting/AgentMeta/index.tsx +3 -3
  43. package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +4 -4
  44. package/src/features/AgentSetting/AgentTTS/index.tsx +3 -3
  45. package/src/features/AvatarWithUpload/index.tsx +3 -3
  46. package/src/features/ChatInput/ActionBar/FileUpload.tsx +3 -3
  47. package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +4 -4
  48. package/src/features/ChatInput/ActionBar/Token/index.tsx +3 -3
  49. package/src/features/ChatInput/ActionBar/Tools/index.tsx +3 -3
  50. package/src/features/ChatInput/STT/browser.tsx +4 -4
  51. package/src/features/ChatInput/STT/index.tsx +3 -3
  52. package/src/features/ChatInput/STT/openai.tsx +4 -4
  53. package/src/features/ChatInput/useChatInput.ts +3 -3
  54. package/src/features/Conversation/Error/APIKeyForm/Bedrock.tsx +3 -3
  55. package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +3 -3
  56. package/src/features/Conversation/Error/AccessCodeForm.tsx +3 -3
  57. package/src/features/Conversation/Extras/TTS/index.tsx +3 -3
  58. package/src/features/Conversation/Plugins/Render/MarkdownType/index.tsx +3 -3
  59. package/src/features/Conversation/components/ChatItem/index.tsx +3 -3
  60. package/src/features/ModelSwitchPanel/index.tsx +3 -6
  61. package/src/features/PluginDevModal/LocalForm.tsx +3 -3
  62. package/src/features/SyncStatusInspector/DisableSync.tsx +3 -3
  63. package/src/features/SyncStatusInspector/EnableSync.tsx +4 -4
  64. package/src/features/SyncStatusInspector/index.tsx +2 -2
  65. package/src/hooks/_header.ts +4 -4
  66. package/src/hooks/useSyncData.ts +3 -3
  67. package/src/hooks/useTTS.ts +4 -4
  68. package/src/layout/DefaultLayout/Desktop/SideBar/BottomActions.tsx +2 -2
  69. package/src/layout/DefaultLayout/Desktop/SideBar/TopActions.tsx +2 -2
  70. package/src/layout/DefaultLayout/Mobile/index.tsx +1 -1
  71. package/src/layout/GlobalProvider/AppTheme.tsx +4 -4
  72. package/src/layout/GlobalProvider/StoreInitialization.tsx +6 -1
  73. package/src/services/__tests__/chat.test.ts +17 -20
  74. package/src/services/__tests__/tool.test.ts +2 -2
  75. package/src/services/_auth.test.ts +2 -2
  76. package/src/services/_auth.ts +7 -7
  77. package/src/services/_header.ts +4 -4
  78. package/src/services/chat.ts +13 -13
  79. package/src/services/config.ts +4 -4
  80. package/src/services/models.ts +3 -3
  81. package/src/services/ollama.ts +3 -3
  82. package/src/services/session/client.ts +2 -2
  83. package/src/services/tool.ts +1 -1
  84. package/src/services/trace.ts +3 -3
  85. package/src/store/agent/slices/chat/selectors.test.ts +2 -2
  86. package/src/store/chat/slices/message/selectors.test.ts +1 -1
  87. package/src/store/chat/slices/message/selectors.ts +3 -3
  88. package/src/store/global/{slices/preference/action.test.ts → action.test.ts} +65 -13
  89. package/src/store/global/{slices/preference/action.ts → action.ts} +30 -16
  90. package/src/store/global/initialState.ts +58 -8
  91. package/src/store/global/selectors.ts +9 -8
  92. package/src/store/global/store.ts +3 -7
  93. package/src/store/market/action.ts +1 -1
  94. package/src/store/session/slices/session/action.ts +3 -3
  95. package/src/store/{global → user}/helpers.ts +2 -2
  96. package/src/store/user/index.ts +1 -0
  97. package/src/store/user/initialState.ts +11 -0
  98. package/src/store/user/selectors.ts +8 -0
  99. package/src/store/{global → user}/slices/common/action.test.ts +29 -81
  100. package/src/store/{global → user}/slices/common/action.ts +2 -20
  101. package/src/store/user/slices/common/initialState.ts +18 -0
  102. package/src/store/user/slices/common/selectors.ts +6 -0
  103. package/src/store/user/slices/preference/action.test.ts +41 -0
  104. package/src/store/user/slices/preference/action.ts +50 -0
  105. package/src/store/user/slices/preference/initialState.ts +33 -0
  106. package/src/store/user/slices/preference/selectors.ts +13 -0
  107. package/src/store/{global → user}/slices/settings/actions/general.test.ts +6 -6
  108. package/src/store/{global → user}/slices/settings/actions/general.ts +2 -2
  109. package/src/store/{global → user}/slices/settings/actions/index.ts +2 -2
  110. package/src/store/{global → user}/slices/settings/actions/llm.test.ts +11 -14
  111. package/src/store/{global → user}/slices/settings/actions/llm.ts +2 -2
  112. package/src/store/{global → user}/slices/settings/initialState.ts +2 -2
  113. package/src/store/{global → user}/slices/settings/selectors/modelConfig.test.ts +8 -8
  114. package/src/store/{global → user}/slices/settings/selectors/modelConfig.ts +12 -12
  115. package/src/store/{global → user}/slices/settings/selectors/modelProvider.test.ts +17 -17
  116. package/src/store/{global → user}/slices/settings/selectors/modelProvider.ts +19 -20
  117. package/src/store/{global → user}/slices/settings/selectors/selectors.test.ts +8 -8
  118. package/src/store/{global → user}/slices/settings/selectors/settings.ts +12 -12
  119. package/src/store/user/slices/settings/selectors/sync.ts +14 -0
  120. package/src/store/user/store.ts +33 -0
  121. package/src/tools/dalle/Render/ToolBar.tsx +3 -3
  122. package/src/utils/localStorage.ts +3 -1
  123. package/src/store/global/slices/common/initialState.ts +0 -42
  124. package/src/store/global/slices/common/selectors.ts +0 -6
  125. package/src/store/global/slices/preference/initialState.ts +0 -51
  126. package/src/store/global/slices/preference/selectors.ts +0 -18
  127. package/src/store/global/slices/settings/selectors/sync.ts +0 -14
  128. /package/src/store/{global → user}/slices/settings/reducers/customModelCard.test.ts +0 -0
  129. /package/src/store/{global → user}/slices/settings/reducers/customModelCard.ts +0 -0
  130. /package/src/store/{global → user}/slices/settings/selectors/__snapshots__/selectors.test.ts.snap +0 -0
  131. /package/src/store/{global → user}/slices/settings/selectors/index.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.150.10](https://github.com/lobehub/lobe-chat/compare/v0.150.9...v0.150.10)
6
+
7
+ <sup>Released on **2024-04-28**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Rename globalStore to userStore.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Rename globalStore to userStore, closes [#2264](https://github.com/lobehub/lobe-chat/issues/2264) ([a3cb538](https://github.com/lobehub/lobe-chat/commit/a3cb538))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.150.9](https://github.com/lobehub/lobe-chat/compare/v0.150.8...v0.150.9)
6
31
 
7
32
  <sup>Released on **2024-04-28**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.150.9",
3
+ "version": "0.150.10",
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",
@@ -5,8 +5,8 @@ import ModelTag from '@/components/ModelTag';
5
5
  import ModelSwitchPanel from '@/features/ModelSwitchPanel';
6
6
  import { useAgentStore } from '@/store/agent';
7
7
  import { agentSelectors } from '@/store/agent/selectors';
8
- import { useGlobalStore } from '@/store/global';
9
- import { modelProviderSelectors } from '@/store/global/selectors';
8
+ import { useUserStore } from '@/store/user';
9
+ import { modelProviderSelectors } from '@/store/user/selectors';
10
10
 
11
11
  import PluginTag from '../../../features/PluginTag';
12
12
 
@@ -16,7 +16,7 @@ const TitleTags = memo(() => {
16
16
  agentSelectors.currentAgentPlugins(s),
17
17
  ]);
18
18
 
19
- const showPlugin = useGlobalStore(modelProviderSelectors.isModelEnabledFunctionCall(model));
19
+ const showPlugin = useUserStore(modelProviderSelectors.isModelEnabledFunctionCall(model));
20
20
 
21
21
  return (
22
22
  <Flexbox gap={8} horizontal>
@@ -9,8 +9,8 @@ import { Center, Flexbox } from 'react-layout-kit';
9
9
  import { useAgentStore } from '@/store/agent';
10
10
  import { agentSelectors } from '@/store/agent/selectors';
11
11
  import { useFileStore } from '@/store/file';
12
- import { useGlobalStore } from '@/store/global';
13
- import { modelProviderSelectors } from '@/store/global/selectors';
12
+ import { useUserStore } from '@/store/user';
13
+ import { modelProviderSelectors } from '@/store/user/selectors';
14
14
 
15
15
  const useStyles = createStyles(({ css, token, stylish }) => {
16
16
  return {
@@ -77,7 +77,7 @@ const DragUpload = memo(() => {
77
77
 
78
78
  const model = useAgentStore(agentSelectors.currentAgentModel);
79
79
 
80
- const enabledFiles = useGlobalStore(modelProviderSelectors.isModelEnabledFiles(model));
80
+ const enabledFiles = useUserStore(modelProviderSelectors.isModelEnabledFiles(model));
81
81
 
82
82
  const uploadImages = async (fileList: FileList | undefined) => {
83
83
  if (!fileList || fileList.length === 0) return;
@@ -11,8 +11,8 @@ import HotKeys from '@/components/HotKeys';
11
11
  import { ALT_KEY } from '@/const/hotkeys';
12
12
  import { useSendMessage } from '@/features/ChatInput/useSend';
13
13
  import { useChatStore } from '@/store/chat';
14
- import { useGlobalStore } from '@/store/global';
15
- import { preferenceSelectors } from '@/store/global/selectors';
14
+ import { useUserStore } from '@/store/user';
15
+ import { preferenceSelectors } from '@/store/user/selectors';
16
16
  import { isMacOS } from '@/utils/platform';
17
17
 
18
18
  const useStyles = createStyles(({ css, prefixCls }) => {
@@ -32,7 +32,7 @@ const SendMore = memo(() => {
32
32
 
33
33
  const { styles } = useStyles();
34
34
 
35
- const [useCmdEnterToSend, updatePreference] = useGlobalStore((s) => [
35
+ const [useCmdEnterToSend, updatePreference] = useUserStore((s) => [
36
36
  preferenceSelectors.useCmdEnterToSend(s),
37
37
  s.updatePreference,
38
38
  ]);
@@ -13,8 +13,8 @@ import { useSendMessage } from '@/features/ChatInput/useSend';
13
13
  import { useAgentStore } from '@/store/agent';
14
14
  import { agentSelectors } from '@/store/agent/slices/chat';
15
15
  import { useChatStore } from '@/store/chat';
16
- import { useGlobalStore } from '@/store/global';
17
- import { modelProviderSelectors, preferenceSelectors } from '@/store/global/selectors';
16
+ import { useUserStore } from '@/store/user';
17
+ import { modelProviderSelectors, preferenceSelectors } from '@/store/user/selectors';
18
18
  import { isMacOS } from '@/utils/platform';
19
19
 
20
20
  import DragUpload from './DragUpload';
@@ -66,7 +66,7 @@ const Footer = memo<FooterProps>(({ setExpand }) => {
66
66
 
67
67
  const model = useAgentStore(agentSelectors.currentAgentModel);
68
68
 
69
- const [useCmdEnterToSend, canUpload] = useGlobalStore((s) => [
69
+ const [useCmdEnterToSend, canUpload] = useUserStore((s) => [
70
70
  preferenceSelectors.useCmdEnterToSend(s),
71
71
  modelProviderSelectors.isModelEnabledUpload(model)(s),
72
72
  ]);
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { useChatStore } from '@/store/chat';
6
- import { useGlobalStore } from '@/store/global';
6
+ import { useUserStore } from '@/store/user';
7
7
 
8
8
  import InputArea from './TextArea';
9
9
 
@@ -232,7 +232,7 @@ describe('<InputArea />', () => {
232
232
  inputMessage: '123',
233
233
  sendMessage: sendMessageMock,
234
234
  });
235
- useGlobalStore.getState().updatePreference({ useCmdEnterToSend: true });
235
+ useUserStore.getState().updatePreference({ useCmdEnterToSend: true });
236
236
  });
237
237
 
238
238
  render(<InputArea setExpand={setExpandMock} />);
@@ -252,7 +252,7 @@ describe('<InputArea />', () => {
252
252
  sendMessage: sendMessageMock,
253
253
  updateInputMessage: updateInputMessageMock,
254
254
  });
255
- useGlobalStore.getState().updatePreference({ useCmdEnterToSend: false });
255
+ useUserStore.getState().updatePreference({ useCmdEnterToSend: false });
256
256
  });
257
257
 
258
258
  render(<InputArea setExpand={setExpandMock} />);
@@ -275,7 +275,7 @@ describe('<InputArea />', () => {
275
275
  inputMessage: '123',
276
276
  sendMessage: sendMessageMock,
277
277
  });
278
- useGlobalStore.getState().updatePreference({ useCmdEnterToSend: true });
278
+ useUserStore.getState().updatePreference({ useCmdEnterToSend: true });
279
279
  });
280
280
 
281
281
  render(<InputArea setExpand={setExpandMock} />);
@@ -300,7 +300,7 @@ describe('<InputArea />', () => {
300
300
  sendMessage: sendMessageMock,
301
301
  updateInputMessage: updateInputMessageMock,
302
302
  });
303
- useGlobalStore.getState().updatePreference({ useCmdEnterToSend: false });
303
+ useUserStore.getState().updatePreference({ useCmdEnterToSend: false });
304
304
  });
305
305
 
306
306
  render(<InputArea setExpand={setExpandMock} />);
@@ -6,8 +6,8 @@ import { useTranslation } from 'react-i18next';
6
6
 
7
7
  import { useSendMessage } from '@/features/ChatInput/useSend';
8
8
  import { useChatStore } from '@/store/chat';
9
- import { useGlobalStore } from '@/store/global';
10
- import { preferenceSelectors } from '@/store/global/selectors';
9
+ import { useUserStore } from '@/store/user';
10
+ import { preferenceSelectors } from '@/store/user/selectors';
11
11
  import { isCommandPressed } from '@/utils/keyboard';
12
12
 
13
13
  import { useAutoFocus } from './useAutoFocus';
@@ -47,7 +47,7 @@ const InputArea = memo<InputAreaProps>(({ setExpand }) => {
47
47
  s.updateInputMessage,
48
48
  ]);
49
49
 
50
- const useCmdEnterToSend = useGlobalStore(preferenceSelectors.useCmdEnterToSend);
50
+ const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
51
51
 
52
52
  const sendMessage = useSendMessage();
53
53
 
@@ -7,10 +7,10 @@ import { Flexbox } from 'react-layout-kit';
7
7
 
8
8
  import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
9
9
  import SyncStatusInspector from '@/features/SyncStatusInspector';
10
- import { useGlobalStore } from '@/store/global';
11
- import { commonSelectors } from '@/store/global/selectors';
12
10
  import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
13
11
  import { useSessionStore } from '@/store/session';
12
+ import { useUserStore } from '@/store/user';
13
+ import { commonSelectors } from '@/store/user/selectors';
14
14
  import { mobileHeaderSticky } from '@/styles/mobileHeader';
15
15
 
16
16
  export const useStyles = createStyles(({ css, token }) => ({
@@ -26,7 +26,7 @@ export const useStyles = createStyles(({ css, token }) => ({
26
26
  const Header = memo(() => {
27
27
  const [createSession] = useSessionStore((s) => [s.createSession]);
28
28
  const router = useRouter();
29
- const avatar = useGlobalStore(commonSelectors.userAvatar);
29
+ const avatar = useUserStore(commonSelectors.userAvatar);
30
30
  const { showCreateSession } = useServerConfigStore(featureFlagsSelectors);
31
31
 
32
32
  return (
@@ -6,8 +6,8 @@ import { Flexbox } from 'react-layout-kit';
6
6
 
7
7
  import { FORM_STYLE } from '@/const/layoutTokens';
8
8
  import { useChatStore } from '@/store/chat';
9
- import { useGlobalStore } from '@/store/global';
10
- import { commonSelectors } from '@/store/global/selectors';
9
+ import { useUserStore } from '@/store/user';
10
+ import { commonSelectors } from '@/store/user/selectors';
11
11
 
12
12
  import Preview from './Preview';
13
13
  import { FieldType, ImageType } from './type';
@@ -49,7 +49,7 @@ const ShareModal = memo<ModalProps>(({ onCancel, open }) => {
49
49
  const [fieldValue, setFieldValue] = useState<FieldType>(DEFAULT_FIELD_VALUE);
50
50
  const [tab, setTab] = useState<Tab>(Tab.Screenshot);
51
51
  const { t } = useTranslation('chat');
52
- const avatar = useGlobalStore(commonSelectors.userAvatar);
52
+ const avatar = useUserStore(commonSelectors.userAvatar);
53
53
  const [shareLoading, shareToShareGPT] = useChatStore((s) => [s.shareLoading, s.shareToShareGPT]);
54
54
  const { loading, onDownload, title } = useScreenshot(fieldValue.imageType);
55
55
 
@@ -9,9 +9,9 @@ import { useTranslation } from 'react-i18next';
9
9
  import { Flexbox } from 'react-layout-kit';
10
10
 
11
11
  import { PRIVACY_URL } from '@/const/url';
12
- import { useGlobalStore } from '@/store/global';
13
12
  import { useServerConfigStore } from '@/store/serverConfig';
14
13
  import { serverConfigSelectors } from '@/store/serverConfig/selectors';
14
+ import { useUserStore } from '@/store/user';
15
15
 
16
16
  const useStyles = createStyles(({ css, token, isDarkMode }) => ({
17
17
  container: css`
@@ -58,7 +58,7 @@ const TelemetryNotification = memo<{ mobile?: boolean }>(({ mobile }) => {
58
58
  const { t } = useTranslation('common');
59
59
  const shouldCheck = useServerConfigStore(serverConfigSelectors.enabledTelemetryChat);
60
60
 
61
- const [useCheckTrace, updatePreference] = useGlobalStore((s) => [
61
+ const [useCheckTrace, updatePreference] = useUserStore((s) => [
62
62
  s.useCheckTrace,
63
63
  s.updatePreference,
64
64
  ]);
@@ -9,7 +9,7 @@ import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
9
9
  import { imageUrl } from '@/const/url';
10
10
  import { useChatStore } from '@/store/chat';
11
11
  import { topicSelectors } from '@/store/chat/selectors';
12
- import { useGlobalStore } from '@/store/global';
12
+ import { useUserStore } from '@/store/user';
13
13
  import { ChatTopic } from '@/types/topic';
14
14
 
15
15
  import { Placeholder, SkeletonList } from './SkeletonList';
@@ -30,7 +30,7 @@ export const Topic = memo(() => {
30
30
  s.activeTopicId,
31
31
  topicSelectors.currentTopicLength(s),
32
32
  ]);
33
- const [visible, updateGuideState] = useGlobalStore((s) => [
33
+ const [visible, updateGuideState] = useUserStore((s) => [
34
34
  s.preference.guide?.topic,
35
35
  s.updateGuideState,
36
36
  ]);
@@ -12,10 +12,10 @@ import { AGENTS_INDEX_GITHUB_ISSUE } from '@/const/url';
12
12
  import AgentInfo from '@/features/AgentInfo';
13
13
  import { useAgentStore } from '@/store/agent';
14
14
  import { agentSelectors } from '@/store/agent/selectors';
15
- import { useGlobalStore } from '@/store/global';
16
- import { settingsSelectors } from '@/store/global/selectors';
17
15
  import { useSessionStore } from '@/store/session';
18
16
  import { sessionMetaSelectors } from '@/store/session/selectors';
17
+ import { useUserStore } from '@/store/user';
18
+ import { settingsSelectors } from '@/store/user/selectors';
19
19
 
20
20
  const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
21
21
  const { t } = useTranslation('setting');
@@ -23,7 +23,7 @@ const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
23
23
  const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
24
24
  const theme = useTheme();
25
25
  const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
26
- const language = useGlobalStore((s) => settingsSelectors.currentSettings(s).language);
26
+ const language = useUserStore((s) => settingsSelectors.currentSettings(s).language);
27
27
 
28
28
  const isMetaPass = Boolean(
29
29
  meta && meta.title && meta.description && (meta.tags as string[])?.length > 0 && meta.avatar,
@@ -7,8 +7,8 @@ import { Center, Flexbox } from 'react-layout-kit';
7
7
 
8
8
  import { CURRENT_VERSION } from '@/const/version';
9
9
  import AvatarWithUpload from '@/features/AvatarWithUpload';
10
- import { useGlobalStore } from '@/store/global';
11
- import { commonSelectors } from '@/store/global/selectors';
10
+ import { useUserStore } from '@/store/user';
11
+ import { commonSelectors } from '@/store/user/selectors';
12
12
 
13
13
  import SettingList from '../features/SettingList';
14
14
  import AvatarBanner from './features/AvatarBanner';
@@ -26,7 +26,7 @@ const useStyles = createStyles(({ css, token }) => ({
26
26
  }));
27
27
 
28
28
  const Setting = memo(() => {
29
- const avatar = useGlobalStore(commonSelectors.userAvatar);
29
+ const avatar = useUserStore(commonSelectors.userAvatar);
30
30
  const { styles } = useStyles();
31
31
 
32
32
  return (
@@ -4,14 +4,14 @@ import { useTranslation } from 'react-i18next';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import { useStyles } from '@/app/settings/about/style';
7
- import { useGlobalStore } from '@/store/global';
8
- import { preferenceSelectors } from '@/store/global/selectors';
7
+ import { useUserStore } from '@/store/user';
8
+ import { preferenceSelectors } from '@/store/user/selectors';
9
9
 
10
10
  const Analytics = memo(() => {
11
11
  const { t } = useTranslation('setting');
12
12
  const { styles } = useStyles();
13
- const checked = useGlobalStore(preferenceSelectors.userAllowTrace);
14
- const [updatePreference] = useGlobalStore((s) => [s.updatePreference]);
13
+ const checked = useUserStore(preferenceSelectors.userAllowTrace);
14
+ const [updatePreference] = useUserStore((s) => [s.updatePreference]);
15
15
 
16
16
  return (
17
17
  <div className={styles.wrapper}>
@@ -5,13 +5,13 @@ import { INBOX_SESSION_ID } from '@/const/session';
5
5
  import AgentSetting from '@/features/AgentSetting';
6
6
  import { useAgentStore } from '@/store/agent';
7
7
  import { agentSelectors } from '@/store/agent/selectors';
8
- import { useGlobalStore } from '@/store/global';
9
- import { settingsSelectors } from '@/store/global/selectors';
8
+ import { useUserStore } from '@/store/user';
9
+ import { settingsSelectors } from '@/store/user/selectors';
10
10
 
11
11
  const Agent = memo(() => {
12
12
  const config = useAgentStore(agentSelectors.defaultAgentConfig, isEqual);
13
- const meta = useGlobalStore(settingsSelectors.defaultAgentMeta, isEqual);
14
- const [updateAgent] = useGlobalStore((s) => [s.updateDefaultAgent]);
13
+ const meta = useUserStore(settingsSelectors.defaultAgentMeta, isEqual);
14
+ const [updateAgent] = useUserStore((s) => [s.updateDefaultAgent]);
15
15
 
16
16
  return (
17
17
  <AgentSetting
@@ -12,10 +12,10 @@ import { DEFAULT_SETTINGS } from '@/const/settings';
12
12
  import { useOAuthSession } from '@/hooks/useOAuthSession';
13
13
  import { useChatStore } from '@/store/chat';
14
14
  import { useFileStore } from '@/store/file';
15
- import { useGlobalStore } from '@/store/global';
16
- import { settingsSelectors } from '@/store/global/selectors';
17
15
  import { useSessionStore } from '@/store/session';
18
16
  import { useToolStore } from '@/store/tool';
17
+ import { useUserStore } from '@/store/user';
18
+ import { settingsSelectors } from '@/store/user/selectors';
19
19
 
20
20
  type SettingItemGroup = ItemGroup;
21
21
 
@@ -40,8 +40,8 @@ const Common = memo<SettingsCommonProps>(({ showAccessCodeConfig, showOAuthLogin
40
40
  ]);
41
41
  const [removeAllFiles] = useFileStore((s) => [s.removeAllFiles]);
42
42
  const removeAllPlugins = useToolStore((s) => s.removeAllPlugins);
43
- const settings = useGlobalStore(settingsSelectors.currentSettings, isEqual);
44
- const [setSettings, resetSettings] = useGlobalStore((s) => [s.setSettings, s.resetSettings]);
43
+ const settings = useUserStore(settingsSelectors.currentSettings, isEqual);
44
+ const [setSettings, resetSettings] = useUserStore((s) => [s.setSettings, s.resetSettings]);
45
45
 
46
46
  const { message, modal } = App.useApp();
47
47
 
@@ -10,8 +10,8 @@ import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import { imageUrl } from '@/const/url';
11
11
  import AvatarWithUpload from '@/features/AvatarWithUpload';
12
12
  import { localeOptions } from '@/locales/resources';
13
- import { useGlobalStore } from '@/store/global';
14
- import { settingsSelectors } from '@/store/global/selectors';
13
+ import { useUserStore } from '@/store/user';
14
+ import { settingsSelectors } from '@/store/user/selectors';
15
15
  import { switchLang } from '@/utils/client/switchLang';
16
16
 
17
17
  import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from '../features/ThemeSwatches';
@@ -22,8 +22,8 @@ const Theme = memo(() => {
22
22
  const { t } = useTranslation('setting');
23
23
  const [form] = AntForm.useForm();
24
24
 
25
- const settings = useGlobalStore(settingsSelectors.currentSettings, isEqual);
26
- const [setThemeMode, setSettings] = useGlobalStore((s) => [s.switchThemeMode, s.setSettings]);
25
+ const settings = useUserStore(settingsSelectors.currentSettings, isEqual);
26
+ const [setThemeMode, setSettings] = useUserStore((s) => [s.switchThemeMode, s.setSettings]);
27
27
 
28
28
  useSyncSettings(form);
29
29
 
@@ -7,11 +7,11 @@ import {
7
7
  } from '@lobehub/ui';
8
8
  import { memo } from 'react';
9
9
 
10
- import { useGlobalStore } from '@/store/global';
11
- import { settingsSelectors } from '@/store/global/selectors';
10
+ import { useUserStore } from '@/store/user';
11
+ import { settingsSelectors } from '@/store/user/selectors';
12
12
 
13
13
  const ThemeSwatchesNeutral = memo(() => {
14
- const [neutralColor, setSettings] = useGlobalStore((s) => [
14
+ const [neutralColor, setSettings] = useUserStore((s) => [
15
15
  settingsSelectors.currentSettings(s).neutralColor,
16
16
  s.setSettings,
17
17
  ]);
@@ -7,11 +7,11 @@ import {
7
7
  } from '@lobehub/ui';
8
8
  import { memo } from 'react';
9
9
 
10
- import { useGlobalStore } from '@/store/global';
11
- import { settingsSelectors } from '@/store/global/selectors';
10
+ import { useUserStore } from '@/store/user';
11
+ import { settingsSelectors } from '@/store/user/selectors';
12
12
 
13
13
  const ThemeSwatchesPrimary = memo(() => {
14
- const [primaryColor, setSettings] = useGlobalStore((s) => [
14
+ const [primaryColor, setSettings] = useUserStore((s) => [
15
15
  settingsSelectors.currentSettings(s).primaryColor,
16
16
  s.setSettings,
17
17
  ]);
@@ -1,15 +1,15 @@
1
1
  import { FormInstance } from 'antd/es/form/hooks/useForm';
2
2
  import { useEffect } from 'react';
3
3
 
4
- import { useGlobalStore } from '@/store/global';
4
+ import { useUserStore } from '@/store/user';
5
5
 
6
6
  export const useSyncSettings = (form: FormInstance) => {
7
7
  useEffect(() => {
8
8
  // set the first time
9
- form.setFieldsValue(useGlobalStore.getState().settings);
9
+ form.setFieldsValue(useUserStore.getState().settings);
10
10
 
11
11
  // sync with later updated settings
12
- const unsubscribe = useGlobalStore.subscribe(
12
+ const unsubscribe = useUserStore.subscribe(
13
13
  (s) => s.settings,
14
14
  (settings) => {
15
15
  form.setFieldsValue(settings);
@@ -7,8 +7,8 @@ import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
9
  import { ModelProvider } from '@/libs/agent-runtime';
10
- import { useGlobalStore } from '@/store/global';
11
- import { modelProviderSelectors } from '@/store/global/selectors';
10
+ import { useUserStore } from '@/store/user';
11
+ import { modelProviderSelectors } from '@/store/user/selectors';
12
12
 
13
13
  import ProviderConfig from '../components/ProviderConfig';
14
14
  import { LLMProviderApiTokenKey, LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
@@ -33,7 +33,7 @@ const AzureOpenAIProvider = memo(() => {
33
33
  const { styles } = useStyles();
34
34
 
35
35
  // Get the first model card's deployment name as the check model
36
- const checkModel = useGlobalStore((s) => {
36
+ const checkModel = useUserStore((s) => {
37
37
  const chatModelCards = modelProviderSelectors.getModelCardsById(providerKey)(s);
38
38
 
39
39
  if (chatModelCards.length > 0) {
@@ -12,8 +12,8 @@ import {
12
12
  LLMProviderModelListKey,
13
13
  } from '@/app/settings/llm/const';
14
14
  import { FORM_STYLE } from '@/const/layoutTokens';
15
- import { useGlobalStore } from '@/store/global';
16
- import { modelConfigSelectors } from '@/store/global/selectors';
15
+ import { useUserStore } from '@/store/user';
16
+ import { modelConfigSelectors } from '@/store/user/selectors';
17
17
  import { GlobalLLMProviderKey } from '@/types/settings';
18
18
 
19
19
  import Checker from '../Checker';
@@ -59,7 +59,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
59
59
  enabled,
60
60
  isFetchOnClient,
61
61
  isProviderEndpointNotEmpty,
62
- ] = useGlobalStore((s) => [
62
+ ] = useUserStore((s) => [
63
63
  s.toggleProviderEnabled,
64
64
  s.setSettings,
65
65
  modelConfigSelectors.isProviderEnabled(provider)(s),
@@ -8,8 +8,8 @@ import { Flexbox } from 'react-layout-kit';
8
8
 
9
9
  import ModelIcon from '@/components/ModelIcon';
10
10
  import { ModelInfoTags } from '@/components/ModelSelect';
11
- import { useGlobalStore } from '@/store/global';
12
- import { modelConfigSelectors } from '@/store/global/selectors';
11
+ import { useUserStore } from '@/store/user';
12
+ import { modelConfigSelectors } from '@/store/user/selectors';
13
13
  import { GlobalLLMProviderKey } from '@/types/settings';
14
14
 
15
15
  interface CustomModelOptionProps {
@@ -23,12 +23,12 @@ const CustomModelOption = memo<CustomModelOptionProps>(({ id, provider }) => {
23
23
  const { modal } = App.useApp();
24
24
 
25
25
  const [dispatchCustomModelCards, toggleEditingCustomModelCard, removeEnabledModels] =
26
- useGlobalStore((s) => [
26
+ useUserStore((s) => [
27
27
  s.dispatchCustomModelCards,
28
28
  s.toggleEditingCustomModelCard,
29
29
  s.removeEnabledModels,
30
30
  ]);
31
- const modelCard = useGlobalStore(
31
+ const modelCard = useUserStore(
32
32
  modelConfigSelectors.getCustomModelCard({ id, provider }),
33
33
  isEqual,
34
34
  );
@@ -4,8 +4,8 @@ import isEqual from 'fast-deep-equal';
4
4
  import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
- import { useGlobalStore } from '@/store/global';
8
- import { modelConfigSelectors } from '@/store/global/slices/settings/selectors';
7
+ import { useUserStore } from '@/store/user';
8
+ import { modelConfigSelectors } from '@/store/user/selectors';
9
9
 
10
10
  import MaxTokenSlider from './MaxTokenSlider';
11
11
 
@@ -18,7 +18,7 @@ const ModelConfigModal = memo<ModelConfigModalProps>(({ showAzureDeployName, pro
18
18
  const { t } = useTranslation('setting');
19
19
 
20
20
  const [open, id, editingProvider, dispatchCustomModelCards, toggleEditingCustomModelCard] =
21
- useGlobalStore((s) => [
21
+ useUserStore((s) => [
22
22
  !!s.editingCustomCardModel && provider === s.editingCustomCardModel?.provider,
23
23
  s.editingCustomCardModel?.id,
24
24
  s.editingCustomCardModel?.provider,
@@ -26,7 +26,7 @@ const ModelConfigModal = memo<ModelConfigModalProps>(({ showAzureDeployName, pro
26
26
  s.toggleEditingCustomModelCard,
27
27
  ]);
28
28
 
29
- const modelCard = useGlobalStore(
29
+ const modelCard = useUserStore(
30
30
  modelConfigSelectors.getCustomModelCard({ id, provider: editingProvider }),
31
31
  isEqual,
32
32
  );
@@ -7,12 +7,12 @@ import { memo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { Flexbox } from 'react-layout-kit';
9
9
 
10
- import { useGlobalStore } from '@/store/global';
10
+ import { useUserStore } from '@/store/user';
11
11
  import {
12
12
  modelConfigSelectors,
13
13
  modelProviderSelectors,
14
14
  settingsSelectors,
15
- } from '@/store/global/selectors';
15
+ } from '@/store/user/selectors';
16
16
  import { GlobalLLMProviderKey } from '@/types/settings';
17
17
 
18
18
  const useStyles = createStyles(({ css, token }) => ({
@@ -36,15 +36,15 @@ interface ModelFetcherProps {
36
36
  const ModelFetcher = memo<ModelFetcherProps>(({ provider }) => {
37
37
  const { styles } = useStyles();
38
38
  const { t } = useTranslation('setting');
39
- const [useFetchProviderModelList] = useGlobalStore((s) => [
39
+ const [useFetchProviderModelList] = useUserStore((s) => [
40
40
  s.useFetchProviderModelList,
41
41
  s.setModelProviderConfig,
42
42
  ]);
43
- const enabledAutoFetch = useGlobalStore(modelConfigSelectors.isAutoFetchModelsEnabled(provider));
44
- const latestFetchTime = useGlobalStore(
43
+ const enabledAutoFetch = useUserStore(modelConfigSelectors.isAutoFetchModelsEnabled(provider));
44
+ const latestFetchTime = useUserStore(
45
45
  (s) => settingsSelectors.providerConfig(provider)(s)?.latestFetchTime,
46
46
  );
47
- const totalModels = useGlobalStore(
47
+ const totalModels = useUserStore(
48
48
  (s) => modelProviderSelectors.getModelCardsById(provider)(s).length,
49
49
  );
50
50
 
@@ -5,8 +5,8 @@ import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import ModelIcon from '@/components/ModelIcon';
7
7
  import { ModelInfoTags } from '@/components/ModelSelect';
8
- import { useGlobalStore } from '@/store/global';
9
- import { modelProviderSelectors } from '@/store/global/selectors';
8
+ import { useUserStore } from '@/store/user';
9
+ import { modelProviderSelectors } from '@/store/user/selectors';
10
10
  import { GlobalLLMProviderKey } from '@/types/settings';
11
11
 
12
12
  import CustomModelOption from './CustomModelOption';
@@ -18,7 +18,7 @@ interface OptionRenderProps {
18
18
  provider: GlobalLLMProviderKey;
19
19
  }
20
20
  const OptionRender = memo<OptionRenderProps>(({ displayName, id, provider, isAzure }) => {
21
- const model = useGlobalStore((s) => modelProviderSelectors.getModelCardById(id)(s), isEqual);
21
+ const model = useUserStore((s) => modelProviderSelectors.getModelCardById(id)(s), isEqual);
22
22
 
23
23
  // if there is isCustom, it means it is a user defined custom model
24
24
  if (model?.isCustom || isAzure) return <CustomModelOption id={id} provider={provider} />;