@lobehub/chat 0.161.14 → 0.161.15
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/README.md +8 -8
- package/README.zh-CN.md +2 -2
- package/package.json +1 -1
- package/src/database/client/models/__tests__/sessionGroup.test.ts +7 -0
- package/src/hooks/useSyncData.ts +2 -2
- package/src/layout/AuthProvider/Clerk/UserUpdater.tsx +0 -1
- package/src/store/user/slices/auth/initialState.ts +0 -6
- package/src/store/user/slices/auth/selectors.ts +2 -2
- package/src/store/user/slices/common/action.test.ts +4 -3
- package/src/store/user/slices/common/action.ts +7 -2
- package/src/types/user/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.161.15](https://github.com/lobehub/lobe-chat/compare/v0.161.14...v0.161.15)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-05-24**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix avatar missing on client DB mode.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix avatar missing on client DB mode, closes [#2645](https://github.com/lobehub/lobe-chat/issues/2645) ([12726c2](https://github.com/lobehub/lobe-chat/commit/12726c2))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.161.14](https://github.com/lobehub/lobe-chat/compare/v0.161.13...v0.161.14)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-05-24**</sup>
|
package/README.md
CHANGED
|
@@ -262,14 +262,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
|
|
|
262
262
|
|
|
263
263
|
<!-- AGENT LIST -->
|
|
264
264
|
|
|
265
|
-
| Recent Submits | Description
|
|
266
|
-
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
267
|
-
| [
|
|
268
|
-
| [
|
|
269
|
-
| [
|
|
270
|
-
| [
|
|
271
|
-
|
|
272
|
-
> 📊 Total agents: [<kbd>**
|
|
265
|
+
| Recent Submits | Description |
|
|
266
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
267
|
+
| [Minecraft Command Instructor](https://chat-preview.lobehub.com/market?agent=mcse-helper)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-05-24**</sup> | Specializes in explaining and demonstrating Minecraft commands<br/>`minecraft` `commands` `explanation` `examples` |
|
|
268
|
+
| [Bahasa/English Translator](https://chat-preview.lobehub.com/market?agent=bahasa-translation)<br/><sup>By **[xenstar](https://github.com/xenstar)** on **2024-05-22**</sup> | Translates text into Bahasa or English, as needed<br/>`english` `translation` `writing` `bahasa` |
|
|
269
|
+
| [Zen Master](https://chat-preview.lobehub.com/market?agent=buddhism-master)<br/><sup>By **[epochaudio](https://github.com/epochaudio)** on **2024-05-22**</sup> | Well-versed in classics, adept at using Buddhism to guide life<br/>`buddhist-studies` `zen-buddhism` `buddhist-scripture-interpretation` `wisdom-q-a` |
|
|
270
|
+
| [Chinese Historian](https://chat-preview.lobehub.com/market?agent=chinese-historian)<br/><sup>By **[epochaudio](https://github.com/epochaudio)** on **2024-05-22**</sup> | Specialized in Chinese historical research, adept at applying ancient wisdom to analyze modern issues.<br/>`historical-research` `chinese-history` |
|
|
271
|
+
|
|
272
|
+
> 📊 Total agents: [<kbd>**270**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
273
273
|
|
|
274
274
|
<!-- AGENT LIST -->
|
|
275
275
|
|
package/README.zh-CN.md
CHANGED
|
@@ -252,12 +252,12 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
252
252
|
|
|
253
253
|
| 最近新增 | 助手说明 |
|
|
254
254
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
255
|
+
| [我的世界指令导师](https://chat-preview.lobehub.com/market?agent=mcse-helper)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-05-24**</sup> | 擅长解释和示范 “我的世界” 指令<br/>`我的世界` `指令` `解释` `示例` |
|
|
255
256
|
| [Bahasa/English Translator](https://chat-preview.lobehub.com/market?agent=bahasa-translation)<br/><sup>By **[xenstar](https://github.com/xenstar)** on **2024-05-22**</sup> | 根据需要将文本翻译成马来语或英语<br/>`英语` `翻译` `写作` `马来语` |
|
|
256
257
|
| [禅定法师](https://chat-preview.lobehub.com/market?agent=buddhism-master)<br/><sup>By **[epochaudio](https://github.com/epochaudio)** on **2024-05-22**</sup> | 熟读经典,善于运用佛法来指导人生<br/>`佛法佛法研究` `禅宗` `佛经解读` `智慧问答` |
|
|
257
258
|
| [中国历史学者](https://chat-preview.lobehub.com/market?agent=chinese-historian)<br/><sup>By **[epochaudio](https://github.com/epochaudio)** on **2024-05-22**</sup> | 专精于中国历史研究,擅长将古代智慧应用于现代问题分析<br/>`历史研究` `中国历史` |
|
|
258
|
-
| [儒家学者](https://chat-preview.lobehub.com/market?agent=confucian-sage)<br/><sup>By **[epochaudio](https://github.com/epochaudio)** on **2024-05-22**</sup> | 一名精通儒家经典且注重弘扬道义的学者<br/>`儒家学者` `道义弘扬者` |
|
|
259
259
|
|
|
260
|
-
> 📊 Total agents: [<kbd>**
|
|
260
|
+
> 📊 Total agents: [<kbd>**270**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
261
261
|
|
|
262
262
|
<!-- AGENT LIST -->
|
|
263
263
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.161.
|
|
3
|
+
"version": "0.161.15",
|
|
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",
|
|
@@ -6,6 +6,8 @@ import { SessionGroups } from '@/types/session';
|
|
|
6
6
|
import { DB_SessionGroup } from '../../schemas/sessionGroup';
|
|
7
7
|
import { SessionGroupModel } from '../sessionGroup';
|
|
8
8
|
|
|
9
|
+
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
+
|
|
9
11
|
describe('SessionGroupModel', () => {
|
|
10
12
|
let sessionGroupData: DB_SessionGroup;
|
|
11
13
|
|
|
@@ -135,9 +137,14 @@ describe('SessionGroupModel', () => {
|
|
|
135
137
|
|
|
136
138
|
it('should return session groups sorted by sort field first and then by createdAt', async () => {
|
|
137
139
|
const group0 = await SessionGroupModel.create('group0');
|
|
140
|
+
await sleep(10);
|
|
138
141
|
const group1 = await SessionGroupModel.create('group1', 1);
|
|
142
|
+
await sleep(10);
|
|
139
143
|
const group2 = await SessionGroupModel.create('group2');
|
|
144
|
+
await sleep(10);
|
|
140
145
|
const group3 = await SessionGroupModel.create('group3', 2);
|
|
146
|
+
await sleep(10);
|
|
147
|
+
|
|
141
148
|
const fetchedGroups = await SessionGroupModel.query();
|
|
142
149
|
expect(fetchedGroups[0].id).toEqual(group1.id);
|
|
143
150
|
expect(fetchedGroups[1].id).toEqual(group3.id);
|
package/src/hooks/useSyncData.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { useChatStore } from '@/store/chat';
|
|
|
4
4
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
5
5
|
import { useSessionStore } from '@/store/session';
|
|
6
6
|
import { useUserStore } from '@/store/user';
|
|
7
|
-
import { syncSettingsSelectors } from '@/store/user/selectors';
|
|
7
|
+
import { syncSettingsSelectors, userProfileSelectors } from '@/store/user/selectors';
|
|
8
8
|
|
|
9
9
|
export const useSyncEvent = () => {
|
|
10
10
|
const [refreshMessages, refreshTopic] = useChatStore((s) => [s.refreshMessages, s.refreshTopic]);
|
|
@@ -38,7 +38,7 @@ export const useSyncEvent = () => {
|
|
|
38
38
|
|
|
39
39
|
export const useEnabledDataSync = () => {
|
|
40
40
|
const [userId, userEnableSync, useEnabledSync] = useUserStore((s) => [
|
|
41
|
-
|
|
41
|
+
userProfileSelectors.userId(s),
|
|
42
42
|
syncSettingsSelectors.enableWebRTC(s),
|
|
43
43
|
s.useEnabledSync,
|
|
44
44
|
]);
|
|
@@ -27,7 +27,6 @@ const UserUpdater = memo(() => {
|
|
|
27
27
|
useStoreUpdater('isLoaded', isLoaded);
|
|
28
28
|
useStoreUpdater('user', lobeUser);
|
|
29
29
|
useStoreUpdater('isSignedIn', isSignedIn);
|
|
30
|
-
useStoreUpdater('userId', user?.id);
|
|
31
30
|
|
|
32
31
|
useStoreUpdater('clerkUser', user);
|
|
33
32
|
useStoreUpdater('clerkSession', session);
|
|
@@ -10,11 +10,6 @@ import {
|
|
|
10
10
|
import { LobeUser } from '@/types/user';
|
|
11
11
|
|
|
12
12
|
export interface UserAuthState {
|
|
13
|
-
/**
|
|
14
|
-
* 未来收到 user.avatar 中
|
|
15
|
-
* @deprecated
|
|
16
|
-
*/
|
|
17
|
-
avatar?: string;
|
|
18
13
|
clerkOpenUserProfile?: (props?: UserProfileProps) => void;
|
|
19
14
|
|
|
20
15
|
clerkSession?: ActiveSessionResource;
|
|
@@ -28,7 +23,6 @@ export interface UserAuthState {
|
|
|
28
23
|
nextSession?: Session;
|
|
29
24
|
nextUser?: User;
|
|
30
25
|
user?: LobeUser;
|
|
31
|
-
userId?: string;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
export const initialAuthState: UserAuthState = {};
|
|
@@ -24,8 +24,8 @@ const username = (s: UserStore) => {
|
|
|
24
24
|
|
|
25
25
|
export const userProfileSelectors = {
|
|
26
26
|
nickName,
|
|
27
|
-
userAvatar: (s: UserStore): string => s.user?.avatar ||
|
|
28
|
-
userId: (s: UserStore) => s.
|
|
27
|
+
userAvatar: (s: UserStore): string => s.user?.avatar || '',
|
|
28
|
+
userId: (s: UserStore) => s.user?.id,
|
|
29
29
|
userProfile: (s: UserStore): LobeUser | null | undefined => s.user,
|
|
30
30
|
username,
|
|
31
31
|
};
|
|
@@ -105,7 +105,7 @@ describe('createCommonSlice', () => {
|
|
|
105
105
|
await waitFor(() => expect(result.current.data).toEqual(mockUserState));
|
|
106
106
|
|
|
107
107
|
// 验证状态是否正确更新
|
|
108
|
-
expect(useUserStore.getState().avatar).toBe(mockUserState.avatar);
|
|
108
|
+
expect(useUserStore.getState().user?.avatar).toBe(mockUserState.avatar);
|
|
109
109
|
expect(useUserStore.getState().settings).toEqual(mockUserState.settings);
|
|
110
110
|
expect(successCallback).toHaveBeenCalledWith(mockUserState);
|
|
111
111
|
|
|
@@ -183,13 +183,14 @@ describe('createCommonSlice', () => {
|
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
it('should handle the case when user
|
|
186
|
+
it('should handle the case when user state have avatar', async () => {
|
|
187
187
|
const { result } = renderHook(() => useUserStore());
|
|
188
188
|
const mockUserState: UserInitializationState = {
|
|
189
189
|
userId: 'user-id',
|
|
190
190
|
isOnboard: true,
|
|
191
191
|
preference: undefined as any,
|
|
192
192
|
settings: null as any,
|
|
193
|
+
avatar: 'abc',
|
|
193
194
|
};
|
|
194
195
|
|
|
195
196
|
vi.spyOn(userService, 'getUserState').mockResolvedValueOnce(mockUserState);
|
|
@@ -202,7 +203,7 @@ describe('createCommonSlice', () => {
|
|
|
202
203
|
await waitFor(() => {
|
|
203
204
|
expect(result.current.isUserStateInit).toBeTruthy();
|
|
204
205
|
// 验证状态未被错误更新
|
|
205
|
-
expect(result.current.avatar).
|
|
206
|
+
expect(result.current.user?.avatar).toEqual('abc');
|
|
206
207
|
expect(result.current.settings).toEqual({});
|
|
207
208
|
});
|
|
208
209
|
});
|
|
@@ -88,6 +88,12 @@ export const createCommonSlice: StateCreator<
|
|
|
88
88
|
const isEmpty = Object.keys(data.preference || {}).length === 0;
|
|
89
89
|
const preference = isEmpty ? DEFAULT_PREFERENCE : data.preference;
|
|
90
90
|
|
|
91
|
+
// if there is avatar or userId (from client DB), update it into user
|
|
92
|
+
const user =
|
|
93
|
+
data.avatar || data.userId
|
|
94
|
+
? merge(get().user, { avatar: data.avatar, id: data.userId })
|
|
95
|
+
: get().user;
|
|
96
|
+
|
|
91
97
|
set(
|
|
92
98
|
{
|
|
93
99
|
defaultSettings,
|
|
@@ -97,11 +103,10 @@ export const createCommonSlice: StateCreator<
|
|
|
97
103
|
isUserCanEnableTrace: data.canEnableTrace,
|
|
98
104
|
isUserHasConversation: data.hasConversation,
|
|
99
105
|
isUserStateInit: true,
|
|
100
|
-
|
|
101
106
|
preference,
|
|
102
107
|
serverLanguageModel: serverConfig.languageModel,
|
|
103
108
|
settings: data.settings || {},
|
|
104
|
-
|
|
109
|
+
user,
|
|
105
110
|
},
|
|
106
111
|
false,
|
|
107
112
|
n('initUserState'),
|
package/src/types/user/index.ts
CHANGED