@lobehub/chat 1.94.9 → 1.94.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.94.10](https://github.com/lobehub/lobe-chat/compare/v1.94.9...v1.94.10)
6
+
7
+ <sup>Released on **2025-06-15**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Improve chat selectors and enhance topic handling logic.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Improve chat selectors and enhance topic handling logic, closes [#8133](https://github.com/lobehub/lobe-chat/issues/8133) [#8117](https://github.com/lobehub/lobe-chat/issues/8117) ([15b24f1](https://github.com/lobehub/lobe-chat/commit/15b24f1))
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 1.94.9](https://github.com/lobehub/lobe-chat/compare/v1.94.8...v1.94.9)
6
31
 
7
32
  <sup>Released on **2025-06-15**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Improve chat selectors and enhance topic handling logic."
6
+ ]
7
+ },
8
+ "date": "2025-06-15",
9
+ "version": "1.94.10"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.94.9",
3
+ "version": "1.94.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",
@@ -183,7 +183,7 @@ export const generateAIChat: StateCreator<
183
183
 
184
184
  // if there is no activeTopicId and the feature length is greater than the threshold
185
185
  // then create a new topic and active it
186
- if (!get().activeTopicId && featureLength >= agentConfig.autoCreateTopicThreshold) {
186
+ if (!activeTopicId && featureLength >= agentConfig.autoCreateTopicThreshold) {
187
187
  // we need to create a temp message for optimistic update
188
188
  tempMessageId = get().internal_createTmpMessage(newMessage);
189
189
  get().internal_toggleMessageLoading(true, tempMessageId);
@@ -258,15 +258,16 @@ export const generateAIChat: StateCreator<
258
258
 
259
259
  // check activeTopic and then auto update topic title
260
260
  if (newTopicId) {
261
- const chats = chatSelectors.activeBaseChats(get());
261
+ const chats = chatSelectors.getBaseChatsByKey(messageMapKey(activeId, newTopicId))(get());
262
262
  await get().summaryTopicTitle(newTopicId, chats);
263
263
  return;
264
264
  }
265
265
 
266
- const topic = topicSelectors.currentActiveTopic(get());
266
+ if (!activeTopicId) return;
267
+ const topic = topicSelectors.getTopicById(activeTopicId)(get());
267
268
 
268
269
  if (topic && !topic.title) {
269
- const chats = chatSelectors.activeBaseChats(get());
270
+ const chats = chatSelectors.getBaseChatsByKey(messageMapKey(activeId, topic.id))(get());
270
271
  await get().summaryTopicTitle(topic.id, chats);
271
272
  }
272
273
  };
@@ -30,6 +30,14 @@ const getMeta = (message: ChatMessage) => {
30
30
  }
31
31
  };
32
32
 
33
+ const getBaseChatsByKey =
34
+ (key: string) =>
35
+ (s: ChatStoreState): ChatMessage[] => {
36
+ const messages = s.messagesMap[key] || [];
37
+
38
+ return messages.map((i) => ({ ...i, meta: getMeta(i) }));
39
+ };
40
+
33
41
  const currentChatKey = (s: ChatStoreState) => messageMapKey(s.activeId, s.activeTopicId);
34
42
 
35
43
  /**
@@ -38,9 +46,7 @@ const currentChatKey = (s: ChatStoreState) => messageMapKey(s.activeId, s.active
38
46
  const activeBaseChats = (s: ChatStoreState): ChatMessage[] => {
39
47
  if (!s.activeId) return [];
40
48
 
41
- const messages = s.messagesMap[currentChatKey(s)] || [];
42
-
43
- return messages.map((i) => ({ ...i, meta: getMeta(i) }));
49
+ return getBaseChatsByKey(currentChatKey(s))(s);
44
50
  };
45
51
 
46
52
  /**
@@ -203,6 +209,7 @@ export const chatSelectors = {
203
209
  currentChatLoadingState,
204
210
  currentToolMessages,
205
211
  currentUserFiles,
212
+ getBaseChatsByKey,
206
213
  getMessageById,
207
214
  getMessageByToolCallId,
208
215
  getTraceIdByMessageId,