@lobehub/lobehub 2.0.0-next.86 → 2.0.0-next.87

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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.87](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.86...v2.0.0-next.87)
6
+
7
+ <sup>Released on **2025-11-19**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor chat selectors.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor chat selectors, closes [#10274](https://github.com/lobehub/lobe-chat/issues/10274) ([0a056f3](https://github.com/lobehub/lobe-chat/commit/0a056f3))
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 2.0.0-next.86](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.85...v2.0.0-next.86)
6
31
 
7
32
  <sup>Released on **2025-11-19**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Refactor chat selectors."
6
+ ]
7
+ },
8
+ "date": "2025-11-19",
9
+ "version": "2.0.0-next.87"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "features": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.86",
3
+ "version": "2.0.0-next.87",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent 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",
@@ -4,7 +4,7 @@ import { useAnalytics } from '@lobehub/analytics/react';
4
4
  import { memo, useCallback, useEffect } from 'react';
5
5
 
6
6
  import { getChatStoreState } from '@/store/chat';
7
- import { chatSelectors } from '@/store/chat/slices/message/selectors';
7
+ import { displayMessageSelectors } from '@/store/chat/selectors';
8
8
  import { useGlobalStore } from '@/store/global';
9
9
  import { systemStatusSelectors } from '@/store/global/selectors';
10
10
  import { getSessionStoreState } from '@/store/session';
@@ -18,7 +18,7 @@ const MainInterfaceTracker = memo(() => {
18
18
  const activeSessionId = currentSession?.id;
19
19
  const defaultSessions = sessionSelectors.defaultSessions(getSessionStoreState());
20
20
  const showChatSideBar = systemStatusSelectors.showChatSideBar(useGlobalStore.getState());
21
- const messages = chatSelectors.activeBaseChats(getChatStoreState());
21
+ const messages = displayMessageSelectors.activeDisplayMessages(getChatStoreState());
22
22
  return {
23
23
  active_assistant: activeSessionId === 'inbox' ? null : currentSession?.meta?.title || null,
24
24
  has_chat_history: messages.length > 0,
@@ -1,9 +1,9 @@
1
+ import { ARTIFACT_THINKING_TAG } from '@lobechat/const';
1
2
  import { memo } from 'react';
2
3
 
3
4
  import Thinking from '@/components/Thinking';
4
- import { ARTIFACT_THINKING_TAG } from '@/const/plugin';
5
5
  import { useChatStore } from '@/store/chat';
6
- import { chatSelectors } from '@/store/chat/selectors';
6
+ import { dbMessageSelectors } from '@/store/chat/selectors';
7
7
  import { useUserStore } from '@/store/user';
8
8
  import { userGeneralSettingsSelectors } from '@/store/user/selectors';
9
9
 
@@ -12,7 +12,7 @@ import { isTagClosed } from '../utils';
12
12
 
13
13
  const Render = memo<MarkdownElementProps>(({ children, id }) => {
14
14
  const [isGenerating] = useChatStore((s) => {
15
- const message = chatSelectors.getMessageById(id)(s);
15
+ const message = dbMessageSelectors.getDbMessageById(id)(s);
16
16
  return [!isTagClosed(ARTIFACT_THINKING_TAG, message?.content)];
17
17
  });
18
18
  const transitionMode = useUserStore(userGeneralSettingsSelectors.transitionMode);
@@ -2,7 +2,7 @@ import { memo } from 'react';
2
2
 
3
3
  import Thinking from '@/components/Thinking';
4
4
  import { useChatStore } from '@/store/chat';
5
- import { chatSelectors } from '@/store/chat/selectors';
5
+ import { dbMessageSelectors } from '@/store/chat/selectors';
6
6
  import { useUserStore } from '@/store/user';
7
7
  import { userGeneralSettingsSelectors } from '@/store/user/selectors';
8
8
 
@@ -17,11 +17,11 @@ const isThinkingClosed = (input: string = '') => {
17
17
 
18
18
  const Render = memo<MarkdownElementProps>(({ children, id }) => {
19
19
  const [isGenerating] = useChatStore((s) => {
20
- const message = chatSelectors.getMessageById(id)(s);
20
+ const message = dbMessageSelectors.getDbMessageById(id)(s);
21
21
  return [!isThinkingClosed(message?.content)];
22
22
  });
23
23
  const citations = useChatStore((s) => {
24
- const message = chatSelectors.getMessageById(id)(s);
24
+ const message = dbMessageSelectors.getDbMessageById(id)(s);
25
25
  return message?.search?.citations;
26
26
  });
27
27
 
@@ -3,7 +3,7 @@ import { Skeleton } from 'antd';
3
3
  import { memo, useRef, useState } from 'react';
4
4
 
5
5
  import { useChatStore } from '@/store/chat';
6
- import { chatSelectors } from '@/store/chat/selectors';
6
+ import { dbMessageSelectors } from '@/store/chat/selectors';
7
7
  import { useToolStore } from '@/store/tool';
8
8
  import { pluginSelectors } from '@/store/tool/selectors';
9
9
 
@@ -28,7 +28,7 @@ import {
28
28
  // just to simplify code a little, don't use this pattern everywhere
29
29
  const getSettings = (identifier: string) =>
30
30
  pluginSelectors.getPluginSettingsById(identifier)(useToolStore.getState());
31
- const getMessage = (id: string) => chatSelectors.getMessageById(id)(useChatStore.getState());
31
+ const getMessage = (id: string) => dbMessageSelectors.getDbMessageById(id)(useChatStore.getState());
32
32
 
33
33
  interface IFrameRenderProps {
34
34
  height?: number;
@@ -61,7 +61,7 @@ const IFrameRender = memo<IFrameRenderProps>(({ url, id, payload, width = 600, h
61
61
  const iframeWin = iframeRef.current?.contentWindow;
62
62
 
63
63
  if (iframeWin) {
64
- const message = chatSelectors.getMessageById(id)(useChatStore.getState());
64
+ const message = dbMessageSelectors.getDbMessageById(id)(useChatStore.getState());
65
65
  if (!message) return;
66
66
  const props = { content: '' };
67
67
 
@@ -8,14 +8,14 @@ import { Center, Flexbox } from 'react-layout-kit';
8
8
  import Balancer from 'react-wrap-balancer';
9
9
 
10
10
  import { useChatStore } from '@/store/chat';
11
- import { chatSelectors } from '@/store/chat/selectors';
11
+ import { dbMessageSelectors, displayMessageSelectors } from '@/store/chat/selectors';
12
12
 
13
13
  import ArtifactItem from './Item';
14
14
 
15
15
  const ArtifactList = () => {
16
16
  const { t } = useTranslation('portal');
17
- const messages = useChatStore(chatSelectors.currentToolMessages, isEqual);
18
- const isCurrentChatLoaded = useChatStore(chatSelectors.isCurrentChatLoaded);
17
+ const messages = useChatStore(dbMessageSelectors.dbToolMessages, isEqual);
18
+ const isCurrentChatLoaded = useChatStore(displayMessageSelectors.isCurrentDisplayChatLoaded);
19
19
 
20
20
  const theme = useTheme();
21
21
  return !isCurrentChatLoaded ? (
@@ -1,3 +1,4 @@
1
+ import { FORM_STYLE } from '@lobechat/const';
1
2
  import { exportFile } from '@lobechat/utils/client';
2
3
  import { Button, Form, type FormItemProps, copyToClipboard } from '@lobehub/ui';
3
4
  import { App, Switch } from 'antd';
@@ -7,12 +8,11 @@ import { memo, useState } from 'react';
7
8
  import { useTranslation } from 'react-i18next';
8
9
  import { Flexbox } from 'react-layout-kit';
9
10
 
10
- import { FORM_STYLE } from '@/const/layoutTokens';
11
11
  import { useIsMobile } from '@/hooks/useIsMobile';
12
12
  import { useAgentStore } from '@/store/agent';
13
13
  import { agentSelectors } from '@/store/agent/selectors';
14
14
  import { useChatStore } from '@/store/chat';
15
- import { chatSelectors, topicSelectors } from '@/store/chat/selectors';
15
+ import { displayMessageSelectors, topicSelectors } from '@/store/chat/selectors';
16
16
 
17
17
  import { useStyles } from '../style';
18
18
  import Preview from './Preview';
@@ -67,7 +67,7 @@ const ShareText = memo(() => {
67
67
  ];
68
68
 
69
69
  const [systemRole] = useAgentStore((s) => [agentSelectors.currentAgentSystemRole(s)]);
70
- const messages = useChatStore(chatSelectors.activeBaseChats, isEqual);
70
+ const messages = useChatStore(displayMessageSelectors.activeDisplayMessages, isEqual);
71
71
  const topic = useChatStore(topicSelectors.currentActiveTopic, isEqual);
72
72
 
73
73
  const title = topic?.title || t('shareModal.exportTitle');
@@ -27,7 +27,7 @@ import { ChatTopic, CreateTopicParams } from '@/types/topic';
27
27
  import { merge } from '@/utils/merge';
28
28
  import { setNamespace } from '@/utils/storeDebug';
29
29
 
30
- import { chatSelectors } from '../message/selectors';
30
+ import { displayMessageSelectors } from '../message/selectors';
31
31
  import { ChatTopicDispatch, topicReducer } from './reducer';
32
32
  import { topicSelectors } from './selectors';
33
33
 
@@ -92,7 +92,7 @@ export const chatTopic: StateCreator<
92
92
  createTopic: async (sessionId, groupId) => {
93
93
  const { activeId, activeSessionType, internal_createTopic } = get();
94
94
 
95
- const messages = chatSelectors.activeBaseChats(get());
95
+ const messages = displayMessageSelectors.activeDisplayMessages(get());
96
96
 
97
97
  set({ creatingTopic: true }, false, n('creatingTopic/start'));
98
98
  const topicId = await internal_createTopic({
@@ -109,7 +109,7 @@ export const chatTopic: StateCreator<
109
109
 
110
110
  saveToTopic: async (sessionId, groupId) => {
111
111
  // if there is no message, stop
112
- const messages = chatSelectors.activeBaseChats(get());
112
+ const messages = displayMessageSelectors.activeDisplayMessages(get());
113
113
  if (messages.length === 0) return;
114
114
 
115
115
  const { activeId, activeSessionType, summaryTopicTitle, internal_createTopic } = get();