@lobehub/chat 0.160.1 → 0.160.3
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 +50 -0
- package/package.json +2 -2
- package/src/config/featureFlags/index.test.ts +4 -0
- package/src/config/featureFlags/index.ts +9 -0
- package/src/features/ChatInput/ActionBar/Tools/Dropdown.tsx +1 -1
- package/src/features/Conversation/components/InboxWelcome/index.tsx +8 -3
- package/src/features/ModelSwitchPanel/index.tsx +2 -1
- package/src/features/User/UserPanel/useNewVersion.tsx +3 -1
- package/src/features/User/__tests__/useMenu.test.tsx +8 -4
- package/src/store/global/action.ts +3 -3
- package/src/store/serverConfig/selectors.test.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.160.3](https://github.com/lobehub/lobe-chat/compare/v0.160.2...v0.160.3)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-05-19**</sup>
|
|
8
|
+
|
|
9
|
+
#### 💄 Styles
|
|
10
|
+
|
|
11
|
+
- **misc**: Add two feature flags: check_updates 、welcome_suggest.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Styles
|
|
19
|
+
|
|
20
|
+
- **misc**: Add two feature flags: check_updates 、welcome_suggest, closes [#2555](https://github.com/lobehub/lobe-chat/issues/2555) ([84c69c9](https://github.com/lobehub/lobe-chat/commit/84c69c9))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.160.2](https://github.com/lobehub/lobe-chat/compare/v0.160.1...v0.160.2)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-05-19**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Upgrade antd and fix lint type.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Upgrade antd and fix lint type, closes [#2567](https://github.com/lobehub/lobe-chat/issues/2567) ([efe28da](https://github.com/lobehub/lobe-chat/commit/efe28da))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.160.1](https://github.com/lobehub/lobe-chat/compare/v0.160.0...v0.160.1)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2024-05-18**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.160.
|
|
3
|
+
"version": "0.160.3",
|
|
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",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@vercel/speed-insights": "^1.0.10",
|
|
111
111
|
"ahooks": "^3.7.11",
|
|
112
112
|
"ai": "3.0.19",
|
|
113
|
-
"antd": "^5.17.
|
|
113
|
+
"antd": "^5.17.3",
|
|
114
114
|
"antd-style": "^3.6.2",
|
|
115
115
|
"brotli-wasm": "^3.0.0",
|
|
116
116
|
"chroma-js": "^2.4.2",
|
|
@@ -36,6 +36,8 @@ describe('mapFeatureFlagsEnvToState', () => {
|
|
|
36
36
|
create_session: true,
|
|
37
37
|
edit_agent: false,
|
|
38
38
|
dalle: true,
|
|
39
|
+
check_updates: true,
|
|
40
|
+
welcome_suggest: true,
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
const expectedState = {
|
|
@@ -46,6 +48,8 @@ describe('mapFeatureFlagsEnvToState', () => {
|
|
|
46
48
|
showOpenAIApiKey: true,
|
|
47
49
|
showOpenAIProxyUrl: false,
|
|
48
50
|
showDalle: true,
|
|
51
|
+
enableCheckUpdates: true,
|
|
52
|
+
showWelcomeSuggest: true,
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
const mappedState = mapFeatureFlagsEnvToState(config);
|
|
@@ -13,6 +13,9 @@ export const FeatureFlagsSchema = z.object({
|
|
|
13
13
|
edit_agent: z.boolean().optional(),
|
|
14
14
|
|
|
15
15
|
dalle: z.boolean().optional(),
|
|
16
|
+
|
|
17
|
+
check_updates: z.boolean().optional(),
|
|
18
|
+
welcome_suggest: z.boolean().optional(),
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
// TypeScript 类型,从 Zod schema 生成
|
|
@@ -30,6 +33,9 @@ export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = {
|
|
|
30
33
|
edit_agent: true,
|
|
31
34
|
|
|
32
35
|
dalle: true,
|
|
36
|
+
|
|
37
|
+
check_updates: true,
|
|
38
|
+
welcome_suggest: true,
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
export const mapFeatureFlagsEnvToState = (config: IFeatureFlags) => {
|
|
@@ -44,5 +50,8 @@ export const mapFeatureFlagsEnvToState = (config: IFeatureFlags) => {
|
|
|
44
50
|
showOpenAIProxyUrl: config.openai_proxy_url,
|
|
45
51
|
|
|
46
52
|
showDalle: config.dalle,
|
|
53
|
+
|
|
54
|
+
enableCheckUpdates: config.check_updates,
|
|
55
|
+
showWelcomeSuggest: config.welcome_suggest,
|
|
47
56
|
};
|
|
48
57
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Avatar, Icon } from '@lobehub/ui';
|
|
2
2
|
import { Dropdown } from 'antd';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
|
-
import type { ItemType } from 'antd/es/menu/
|
|
4
|
+
import type { ItemType } from 'antd/es/menu/interface';
|
|
5
5
|
import isEqual from 'fast-deep-equal';
|
|
6
6
|
import { ArrowRight, Store, ToyBrick } from 'lucide-react';
|
|
7
7
|
import { PropsWithChildren, memo } from 'react';
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import { useGreeting } from '@/hooks/useGreeting';
|
|
10
|
-
import { useServerConfigStore } from '@/store/serverConfig';
|
|
10
|
+
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
11
11
|
|
|
12
12
|
import AgentsSuggest from './AgentsSuggest';
|
|
13
13
|
import QuestionSuggest from './QuestionSuggest';
|
|
@@ -44,6 +44,7 @@ const InboxWelcome = memo(() => {
|
|
|
44
44
|
const { styles } = useStyles();
|
|
45
45
|
const mobile = useServerConfigStore((s) => s.isMobile);
|
|
46
46
|
const greeting = useGreeting();
|
|
47
|
+
const { showWelcomeSuggest } = useServerConfigStore(featureFlagsSelectors);
|
|
47
48
|
|
|
48
49
|
return (
|
|
49
50
|
<Center padding={16} width={'100%'}>
|
|
@@ -55,8 +56,12 @@ const InboxWelcome = memo(() => {
|
|
|
55
56
|
<Markdown className={styles.desc} variant={'chat'}>
|
|
56
57
|
{t('guide.defaultMessage')}
|
|
57
58
|
</Markdown>
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
{
|
|
60
|
+
showWelcomeSuggest && <>
|
|
61
|
+
<AgentsSuggest mobile={mobile} />
|
|
62
|
+
<QuestionSuggest mobile={mobile} />
|
|
63
|
+
</>
|
|
64
|
+
}
|
|
60
65
|
</Flexbox>
|
|
61
66
|
</Center>
|
|
62
67
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Icon } from '@lobehub/ui';
|
|
2
2
|
import { Dropdown } from 'antd';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
|
+
import type { ItemType } from 'antd/es/menu/interface';
|
|
4
5
|
import isEqual from 'fast-deep-equal';
|
|
5
6
|
import { LucideArrowRight } from 'lucide-react';
|
|
6
7
|
import { useRouter } from 'next/navigation';
|
|
@@ -48,7 +49,7 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
|
|
|
48
49
|
const router = useRouter();
|
|
49
50
|
const enabledList = useUserStore(modelProviderSelectors.modelProviderListForModelSelect, isEqual);
|
|
50
51
|
|
|
51
|
-
const items = useMemo(() => {
|
|
52
|
+
const items = useMemo<ItemType[]>(() => {
|
|
52
53
|
const getModelItems = (provider: ModelProviderCard) => {
|
|
53
54
|
const items = provider.chatModels.map((model) => ({
|
|
54
55
|
key: model.id,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useGlobalStore } from '@/store/global';
|
|
2
|
+
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
2
3
|
|
|
3
4
|
export const useNewVersion = () => {
|
|
4
5
|
const [hasNewVersion, useCheckLatestVersion] = useGlobalStore((s) => [
|
|
@@ -6,7 +7,8 @@ export const useNewVersion = () => {
|
|
|
6
7
|
s.useCheckLatestVersion,
|
|
7
8
|
]);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const { enableCheckUpdates } = useServerConfigStore(featureFlagsSelectors);
|
|
11
|
+
useCheckLatestVersion(enableCheckUpdates);
|
|
10
12
|
|
|
11
13
|
return hasNewVersion;
|
|
12
14
|
};
|
|
@@ -2,9 +2,13 @@ import { act, renderHook } from '@testing-library/react';
|
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { useUserStore } from '@/store/user';
|
|
5
|
+
import { ServerConfigStoreProvider } from '@/store/serverConfig';
|
|
5
6
|
|
|
6
7
|
import { useMenu } from '../UserPanel/useMenu';
|
|
7
8
|
|
|
9
|
+
const wrapper: React.JSXElementConstructor<{ children: React.ReactNode }> = ({ children }) =>
|
|
10
|
+
<ServerConfigStoreProvider>{children}</ServerConfigStoreProvider>
|
|
11
|
+
|
|
8
12
|
// Mock dependencies
|
|
9
13
|
vi.mock('next/link', () => ({
|
|
10
14
|
default: vi.fn(({ children }) => <div>{children}</div>),
|
|
@@ -69,7 +73,7 @@ describe('useMenu', () => {
|
|
|
69
73
|
enableAuth = true;
|
|
70
74
|
enableClerk = false;
|
|
71
75
|
|
|
72
|
-
const { result } = renderHook(() => useMenu());
|
|
76
|
+
const { result } = renderHook(() => useMenu(), { wrapper });
|
|
73
77
|
|
|
74
78
|
act(() => {
|
|
75
79
|
const { mainItems, logoutItems } = result.current;
|
|
@@ -89,7 +93,7 @@ describe('useMenu', () => {
|
|
|
89
93
|
enableAuth = true;
|
|
90
94
|
enableClerk = true;
|
|
91
95
|
|
|
92
|
-
const { result } = renderHook(() => useMenu());
|
|
96
|
+
const { result } = renderHook(() => useMenu(), { wrapper });
|
|
93
97
|
|
|
94
98
|
act(() => {
|
|
95
99
|
const { mainItems, logoutItems } = result.current;
|
|
@@ -108,7 +112,7 @@ describe('useMenu', () => {
|
|
|
108
112
|
});
|
|
109
113
|
enableAuth = false;
|
|
110
114
|
|
|
111
|
-
const { result } = renderHook(() => useMenu());
|
|
115
|
+
const { result } = renderHook(() => useMenu(), { wrapper });
|
|
112
116
|
|
|
113
117
|
act(() => {
|
|
114
118
|
const { mainItems, logoutItems } = result.current;
|
|
@@ -127,7 +131,7 @@ describe('useMenu', () => {
|
|
|
127
131
|
});
|
|
128
132
|
enableAuth = true;
|
|
129
133
|
|
|
130
|
-
const { result } = renderHook(() => useMenu());
|
|
134
|
+
const { result } = renderHook(() => useMenu(), { wrapper });
|
|
131
135
|
|
|
132
136
|
act(() => {
|
|
133
137
|
const { mainItems, logoutItems } = result.current;
|
|
@@ -27,7 +27,7 @@ export interface GlobalStoreAction {
|
|
|
27
27
|
toggleMobileTopic: (visible?: boolean) => void;
|
|
28
28
|
toggleSystemRole: (visible?: boolean) => void;
|
|
29
29
|
updatePreference: (preference: Partial<GlobalPreference>, action?: any) => void;
|
|
30
|
-
useCheckLatestVersion: () => SWRResponse<string>;
|
|
30
|
+
useCheckLatestVersion: (enabledCheck?: boolean) => SWRResponse<string>;
|
|
31
31
|
useInitGlobalPreference: () => SWRResponse;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -79,8 +79,8 @@ export const globalActionSlice: StateCreator<
|
|
|
79
79
|
get().preferenceStorage.saveToLocalStorage(nextPreference);
|
|
80
80
|
},
|
|
81
81
|
|
|
82
|
-
useCheckLatestVersion: () =>
|
|
83
|
-
useSWR('checkLatestVersion', globalService.getLatestVersion, {
|
|
82
|
+
useCheckLatestVersion: (enabledCheck = true) =>
|
|
83
|
+
useSWR(enabledCheck ? 'checkLatestVersion' : null, globalService.getLatestVersion, {
|
|
84
84
|
// check latest version every 30 minutes
|
|
85
85
|
focusThrottleInterval: 1000 * 60 * 30,
|
|
86
86
|
onSuccess: (data: string) => {
|