@lobehub/lobehub 2.0.0-next.68 → 2.0.0-next.69
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/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/packages/const/src/version.ts +0 -5
- package/packages/database/src/models/__tests__/chunk.test.ts +38 -0
- package/src/app/(backend)/api/webhooks/clerk/route.ts +1 -2
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +0 -20
- package/src/app/[variants]/(main)/(mobile)/me/(home)/features/useCategory.tsx +4 -33
- package/src/app/[variants]/(main)/(mobile)/me/profile/features/Category.tsx +18 -23
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +5 -15
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/ActionButton/ProviderConfig.tsx +4 -11
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect/index.tsx +12 -27
- package/src/app/[variants]/(main)/image/layout.tsx +0 -4
- package/src/app/[variants]/(main)/profile/hooks/useCategory.tsx +10 -13
- package/src/app/[variants]/(main)/profile/stats/features/ShareButton/Preview.tsx +2 -14
- package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +2 -3
- package/src/app/[variants]/(main)/settings/_layout/SettingsContent.tsx +1 -12
- package/src/app/[variants]/(main)/settings/_layout/type.ts +0 -1
- package/src/app/[variants]/(main)/settings/hooks/useCategory.tsx +8 -16
- package/src/app/[variants]/(main)/settings/page.tsx +3 -7
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/index.tsx +2 -4
- package/src/app/[variants]/(main)/settings/storage/index.tsx +1 -9
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +1 -2
- package/src/components/InvalidAPIKey/APIKeyForm/useApiKey.ts +0 -12
- package/src/config/featureFlags/schema.test.ts +1 -3
- package/src/config/featureFlags/schema.ts +0 -3
- package/src/features/ChatInput/ActionBar/Knowledge/index.tsx +2 -3
- package/src/features/ChatInput/ActionBar/Search/index.tsx +5 -7
- package/src/features/ChatInput/ActionBar/Upload/index.tsx +1 -3
- package/src/features/Conversation/Messages/Assistant/index.tsx +1 -1
- package/src/features/Conversation/components/ShareMessageModal/index.tsx +3 -8
- package/src/features/DevPanel/PostgresViewer/usePgTable.ts +3 -11
- package/src/features/ModelSwitchPanel/index.tsx +9 -24
- package/src/features/ShareModal/index.tsx +7 -13
- package/src/features/User/UserPanel/PanelContent.tsx +6 -8
- package/src/hooks/useCheckPluginsIsInstalled.ts +1 -4
- package/src/hooks/useFetchGroups.ts +1 -4
- package/src/hooks/useFetchInstalledPlugins.ts +1 -4
- package/src/hooks/useFetchMessages.ts +1 -4
- package/src/hooks/useFetchSessions.ts +1 -4
- package/src/hooks/useFetchThreads.ts +1 -5
- package/src/hooks/useFetchTopics.ts +1 -4
- package/src/hooks/useInterceptingRoutes.test.ts +0 -19
- package/src/hooks/useInterceptingRoutes.ts +1 -7
- package/src/layout/GlobalProvider/StoreInitialization.tsx +2 -4
- package/src/services/_auth.ts +2 -11
- package/src/services/_header.ts +2 -10
- package/src/services/chat/chat.test.ts +53 -10
- package/src/services/chat/clientModelRuntime.test.ts +108 -172
- package/src/services/chat/contextEngineering.ts +2 -2
- package/src/services/config.ts +2 -2
- package/src/store/aiInfra/slices/aiProvider/action.ts +3 -4
- package/src/store/chat/slices/thread/action.ts +2 -2
- package/src/store/global/selectors/systemStatus.test.ts +0 -98
- package/src/store/global/selectors/systemStatus.ts +0 -30
- package/src/store/serverConfig/selectors.test.ts +2 -2
- package/src/store/serverConfig/store.test.ts +0 -1
- package/src/app/[variants]/(main)/settings/storage/IndexedDBStorage.tsx +0 -55
- package/src/features/ChatInput/ActionBar/Upload/ClientMode.tsx +0 -62
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDesktop } from '@lobechat/const';
|
|
1
2
|
import { Icon } from '@lobehub/ui';
|
|
2
3
|
import {
|
|
3
4
|
Bot,
|
|
@@ -15,14 +16,13 @@ import { useMemo } from 'react';
|
|
|
15
16
|
import { useTranslation } from 'react-i18next';
|
|
16
17
|
|
|
17
18
|
import type { MenuProps } from '@/components/Menu';
|
|
18
|
-
import { isDeprecatedEdition, isDesktop } from '@/const/version';
|
|
19
19
|
import { SettingsTabs } from '@/store/global/initialState';
|
|
20
20
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
21
21
|
|
|
22
22
|
export const useCategory = () => {
|
|
23
23
|
const { t } = useTranslation('setting');
|
|
24
24
|
const mobile = useServerConfigStore((s) => s.isMobile);
|
|
25
|
-
const {
|
|
25
|
+
const { enableSTT, hideDocs } = useServerConfigStore(featureFlagsSelectors);
|
|
26
26
|
|
|
27
27
|
const cateItems: MenuProps['items'] = useMemo(
|
|
28
28
|
() =>
|
|
@@ -45,19 +45,11 @@ export const useCategory = () => {
|
|
|
45
45
|
{
|
|
46
46
|
type: 'divider',
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
key: SettingsTabs.LLM,
|
|
54
|
-
label: t('tab.llm'),
|
|
55
|
-
}
|
|
56
|
-
: {
|
|
57
|
-
icon: <Icon icon={Brain} />,
|
|
58
|
-
key: SettingsTabs.Provider,
|
|
59
|
-
label: t('tab.provider'),
|
|
60
|
-
}),
|
|
48
|
+
{
|
|
49
|
+
icon: <Icon icon={Brain} />,
|
|
50
|
+
key: SettingsTabs.Provider,
|
|
51
|
+
label: t('tab.provider'),
|
|
52
|
+
},
|
|
61
53
|
{
|
|
62
54
|
icon: <Icon icon={ImageIcon} />,
|
|
63
55
|
key: SettingsTabs.Image,
|
|
@@ -92,7 +84,7 @@ export const useCategory = () => {
|
|
|
92
84
|
label: t('tab.about'),
|
|
93
85
|
},
|
|
94
86
|
].filter(Boolean) as MenuProps['items'],
|
|
95
|
-
[t,
|
|
87
|
+
[t, enableSTT, hideDocs, mobile],
|
|
96
88
|
);
|
|
97
89
|
|
|
98
90
|
return cateItems;
|
|
@@ -20,14 +20,9 @@ export const generateMetadata = async (props: DynamicLayoutProps) => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const SettingsLayout = ServerLayout<
|
|
24
|
-
LayoutProps & {
|
|
25
|
-
showLLM?: boolean;
|
|
26
|
-
}
|
|
27
|
-
>({ Desktop, Mobile });
|
|
23
|
+
const SettingsLayout = ServerLayout<LayoutProps>({ Desktop, Mobile });
|
|
28
24
|
|
|
29
25
|
const SettingsPage = async (props: DynamicLayoutProps) => {
|
|
30
|
-
const showLLM = serverFeatureFlags().showProvider;
|
|
31
26
|
const { showOpenAIProxyUrl, showOpenAIApiKey } = serverFeatureFlags();
|
|
32
27
|
|
|
33
28
|
return (
|
|
@@ -37,7 +32,8 @@ const SettingsPage = async (props: DynamicLayoutProps) => {
|
|
|
37
32
|
showOpenAIProxyUrl: showOpenAIProxyUrl,
|
|
38
33
|
}}
|
|
39
34
|
>
|
|
40
|
-
|
|
35
|
+
{/* @ts-ignore */}
|
|
36
|
+
<SettingsLayout {...props} />
|
|
41
37
|
</SettingsContextProvider>
|
|
42
38
|
);
|
|
43
39
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { AES_GCM_URL, BASE_PROVIDER_DOC_URL, FORM_STYLE, isDesktop } from '@lobechat/const';
|
|
3
4
|
import { ProviderCombine } from '@lobehub/icons';
|
|
4
5
|
import {
|
|
5
6
|
Avatar,
|
|
@@ -22,9 +23,6 @@ import { z } from 'zod';
|
|
|
22
23
|
|
|
23
24
|
import { FormInput, FormPassword } from '@/components/FormInput';
|
|
24
25
|
import { SkeletonInput, SkeletonSwitch } from '@/components/Skeleton';
|
|
25
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
26
|
-
import { AES_GCM_URL, BASE_PROVIDER_DOC_URL } from '@/const/url';
|
|
27
|
-
import { isDesktop, isServerMode } from '@/const/version';
|
|
28
26
|
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
|
29
27
|
import {
|
|
30
28
|
AiProviderDetailItem,
|
|
@@ -351,7 +349,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
|
|
|
351
349
|
minWidth: undefined,
|
|
352
350
|
}
|
|
353
351
|
: undefined,
|
|
354
|
-
showAceGcm &&
|
|
352
|
+
showAceGcm && aceGcmItem,
|
|
355
353
|
].filter(Boolean) as FormItemProps[];
|
|
356
354
|
|
|
357
355
|
const logoUrl = data?.logo ?? logo;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { isServerMode } from '@/const/version';
|
|
4
|
-
|
|
5
3
|
import Advanced from './Advanced';
|
|
6
|
-
import IndexedDBStorage from './IndexedDBStorage';
|
|
7
4
|
|
|
8
5
|
const StorageEstimate = () => {
|
|
9
|
-
return
|
|
10
|
-
<>
|
|
11
|
-
{!isServerMode && <IndexedDBStorage />}
|
|
12
|
-
<Advanced />
|
|
13
|
-
</>
|
|
14
|
-
);
|
|
6
|
+
return <Advanced />;
|
|
15
7
|
};
|
|
16
8
|
|
|
17
9
|
export default StorageEstimate;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_REWRITE_QUERY } from '@lobechat/prompts';
|
|
4
4
|
|
|
5
|
-
import { isServerMode } from '@/const/version';
|
|
6
5
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
7
6
|
|
|
8
7
|
import SystemAgentForm from './features/SystemAgentForm';
|
|
@@ -16,7 +15,7 @@ const Page = () => {
|
|
|
16
15
|
<SystemAgentForm systemAgentKey="translation" />
|
|
17
16
|
<SystemAgentForm systemAgentKey="historyCompress" />
|
|
18
17
|
<SystemAgentForm systemAgentKey="agentMeta" />
|
|
19
|
-
{
|
|
18
|
+
{enableKnowledgeBase && (
|
|
20
19
|
<SystemAgentForm
|
|
21
20
|
allowCustomPrompt
|
|
22
21
|
allowDisable
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
|
|
4
|
-
import { isDeprecatedEdition } from '@/const/version';
|
|
5
4
|
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
|
6
|
-
import { useUserStore } from '@/store/user';
|
|
7
|
-
import { keyVaultsConfigSelectors } from '@/store/user/selectors';
|
|
8
5
|
|
|
9
6
|
import { LoadingContext } from './LoadingContext';
|
|
10
7
|
|
|
11
8
|
export const useApiKey = (provider: string) => {
|
|
12
|
-
const [apiKey, baseURL, setConfig] = useUserStore((s) => [
|
|
13
|
-
keyVaultsConfigSelectors.getVaultByProvider(provider as any)(s)?.apiKey,
|
|
14
|
-
keyVaultsConfigSelectors.getVaultByProvider(provider as any)(s)?.baseURL,
|
|
15
|
-
s.updateKeyVaultConfig,
|
|
16
|
-
]);
|
|
17
9
|
const { setLoading } = useContext(LoadingContext);
|
|
18
10
|
const updateAiProviderConfig = useAiInfraStore((s) => s.updateAiProviderConfig);
|
|
19
11
|
const data = useAiInfraStore(aiProviderSelectors.providerConfigById(provider), isEqual);
|
|
20
12
|
|
|
21
|
-
// TODO: remove this in V2
|
|
22
|
-
if (isDeprecatedEdition) return { apiKey, baseURL, setConfig };
|
|
23
|
-
//
|
|
24
|
-
|
|
25
13
|
return {
|
|
26
14
|
apiKey: data?.keyVaults.apiKey,
|
|
27
15
|
baseURL: data?.keyVaults?.baseURL,
|
|
@@ -5,7 +5,7 @@ import { FeatureFlagsSchema, evaluateFeatureFlag, mapFeatureFlagsEnvToState } fr
|
|
|
5
5
|
describe('FeatureFlagsSchema', () => {
|
|
6
6
|
it('should validate correct feature flags with boolean values', () => {
|
|
7
7
|
const result = FeatureFlagsSchema.safeParse({
|
|
8
|
-
|
|
8
|
+
provider_settings: false,
|
|
9
9
|
openai_api_key: true,
|
|
10
10
|
openai_proxy_url: false,
|
|
11
11
|
create_session: true,
|
|
@@ -98,7 +98,6 @@ describe('evaluateFeatureFlag', () => {
|
|
|
98
98
|
describe('mapFeatureFlagsEnvToState', () => {
|
|
99
99
|
it('should correctly map boolean feature flags to state', () => {
|
|
100
100
|
const config = {
|
|
101
|
-
language_model_settings: false,
|
|
102
101
|
provider_settings: true,
|
|
103
102
|
openai_api_key: true,
|
|
104
103
|
openai_proxy_url: false,
|
|
@@ -126,7 +125,6 @@ describe('mapFeatureFlagsEnvToState', () => {
|
|
|
126
125
|
expect(mappedState).toMatchObject({
|
|
127
126
|
isAgentEditable: false,
|
|
128
127
|
showCreateSession: true,
|
|
129
|
-
showLLM: false,
|
|
130
128
|
showProvider: true,
|
|
131
129
|
showOpenAIApiKey: true,
|
|
132
130
|
showOpenAIProxyUrl: false,
|
|
@@ -9,7 +9,6 @@ export const FeatureFlagsSchema = z.object({
|
|
|
9
9
|
pin_list: FeatureFlagValue.optional(),
|
|
10
10
|
|
|
11
11
|
// settings
|
|
12
|
-
language_model_settings: FeatureFlagValue.optional(),
|
|
13
12
|
provider_settings: FeatureFlagValue.optional(),
|
|
14
13
|
|
|
15
14
|
openai_api_key: FeatureFlagValue.optional(),
|
|
@@ -69,7 +68,6 @@ export const evaluateFeatureFlag = (
|
|
|
69
68
|
export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = {
|
|
70
69
|
pin_list: false,
|
|
71
70
|
|
|
72
|
-
language_model_settings: true,
|
|
73
71
|
provider_settings: true,
|
|
74
72
|
|
|
75
73
|
openai_api_key: true,
|
|
@@ -112,7 +110,6 @@ export const mapFeatureFlagsEnvToState = (config: IFeatureFlags, userId?: string
|
|
|
112
110
|
|
|
113
111
|
showCreateSession: evaluateFeatureFlag(config.create_session, userId),
|
|
114
112
|
enableGroupChat: evaluateFeatureFlag(config.group_chat, userId),
|
|
115
|
-
showLLM: evaluateFeatureFlag(config.language_model_settings, userId),
|
|
116
113
|
showProvider: evaluateFeatureFlag(config.provider_settings, userId),
|
|
117
114
|
showPinList: evaluateFeatureFlag(config.pin_list, userId),
|
|
118
115
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { LOBE_CHAT_CLOUD } from '@lobechat/const';
|
|
1
2
|
import { LibraryBig } from 'lucide-react';
|
|
2
3
|
import { Suspense, memo, useState } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
|
|
5
6
|
import TipGuide from '@/components/TipGuide';
|
|
6
|
-
import { LOBE_CHAT_CLOUD } from '@/const/branding';
|
|
7
|
-
import { isServerMode } from '@/const/version';
|
|
8
7
|
import { AttachKnowledgeModal } from '@/features/KnowledgeBaseModal';
|
|
9
8
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
10
9
|
import { useUserStore } from '@/store/user';
|
|
@@ -13,7 +12,7 @@ import { preferenceSelectors } from '@/store/user/selectors';
|
|
|
13
12
|
import Action from '../components/Action';
|
|
14
13
|
import { useControls } from './useControls';
|
|
15
14
|
|
|
16
|
-
const enableKnowledge =
|
|
15
|
+
const enableKnowledge = true;
|
|
17
16
|
|
|
18
17
|
const Knowledge = memo(() => {
|
|
19
18
|
const { t } = useTranslation('chat');
|
|
@@ -4,7 +4,6 @@ import { Globe } from 'lucide-react';
|
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
|
-
import { isDeprecatedEdition } from '@/const/version';
|
|
8
7
|
import { useAgentEnableSearch } from '@/hooks/useAgentEnableSearch';
|
|
9
8
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
|
10
9
|
import { useAgentStore } from '@/store/agent';
|
|
@@ -25,7 +24,6 @@ const Search = memo(() => {
|
|
|
25
24
|
const theme = useTheme();
|
|
26
25
|
const isMobile = useIsMobile();
|
|
27
26
|
|
|
28
|
-
if (isDeprecatedEdition) return null;
|
|
29
27
|
if (isLoading) return <Action disabled icon={GlobeOffIcon} />;
|
|
30
28
|
|
|
31
29
|
return (
|
|
@@ -36,11 +34,11 @@ const Search = memo(() => {
|
|
|
36
34
|
isMobile
|
|
37
35
|
? undefined
|
|
38
36
|
: async (e) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
e?.preventDefault?.();
|
|
38
|
+
e?.stopPropagation?.();
|
|
39
|
+
const next = mode === 'off' ? 'auto' : 'off';
|
|
40
|
+
await updateAgentChatConfig({ searchMode: next });
|
|
41
|
+
}
|
|
44
42
|
}
|
|
45
43
|
popover={{
|
|
46
44
|
content: <Controls />,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { isServerMode } from '@/const/version';
|
|
2
1
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
3
2
|
|
|
4
|
-
import ClientMode from './ClientMode';
|
|
5
3
|
import ServerMode from './ServerMode';
|
|
6
4
|
|
|
7
5
|
const Upload = () => {
|
|
8
6
|
const { enableKnowledgeBase } = useServerConfigStore(featureFlagsSelectors);
|
|
9
|
-
return
|
|
7
|
+
return enableKnowledgeBase && <ServerMode />;
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
export default Upload;
|
|
@@ -315,7 +315,7 @@ const AssistantMessage = memo<AssistantMessageProps>(
|
|
|
315
315
|
<Flexbox
|
|
316
316
|
className={styles.container}
|
|
317
317
|
gap={mobile ? 6 : 12}
|
|
318
|
-
style={isLatestItem ? { minHeight: 'calc(-
|
|
318
|
+
style={isLatestItem ? { minHeight: 'calc(-300px + 100dvh)' } : undefined}
|
|
319
319
|
>
|
|
320
320
|
<Flexbox gap={4} horizontal>
|
|
321
321
|
<Avatar
|
|
@@ -4,7 +4,6 @@ import { memo, useId, useMemo, useState } from 'react';
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Flexbox } from 'react-layout-kit';
|
|
6
6
|
|
|
7
|
-
import { isServerMode } from '@/const/version';
|
|
8
7
|
import SharePdf from '@/features/ShareModal/SharePdf';
|
|
9
8
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
|
10
9
|
|
|
@@ -41,16 +40,12 @@ const ShareModal = memo<ShareModalProps>(({ onCancel, open, message }) => {
|
|
|
41
40
|
key: Tab.Text,
|
|
42
41
|
label: t('shareModal.text'),
|
|
43
42
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Only add PDF tab in server mode
|
|
47
|
-
if (isServerMode) {
|
|
48
|
-
items.push({
|
|
43
|
+
{
|
|
49
44
|
children: <SharePdf message={message} />,
|
|
50
45
|
key: Tab.PDF,
|
|
51
46
|
label: t('shareModal.pdf'),
|
|
52
|
-
}
|
|
53
|
-
|
|
47
|
+
},
|
|
48
|
+
];
|
|
54
49
|
|
|
55
50
|
return items;
|
|
56
51
|
}, [isMobile, message, uniqueId, t]);
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
import useSWR from 'swr';
|
|
2
2
|
|
|
3
3
|
import { tableViewerService } from '@/services/tableViewer';
|
|
4
|
-
import { useGlobalStore } from '@/store/global';
|
|
5
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
6
4
|
|
|
7
5
|
const FETCH_TABLES = 'fetch-tables';
|
|
8
6
|
const FETCH_TABLE_COLUMN_KEY = (tableName: string) => ['fetch-table-columns', tableName];
|
|
9
7
|
export const FETCH_TABLE_DATA_KEY = (tableName: string) => ['fetch-table-data', tableName];
|
|
10
8
|
|
|
11
9
|
export const useFetchTables = () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return useSWR(isDBInited ? FETCH_TABLES : null, () => tableViewerService.getAllTables());
|
|
10
|
+
return useSWR(FETCH_TABLES, () => tableViewerService.getAllTables());
|
|
15
11
|
};
|
|
16
12
|
|
|
17
13
|
export const useTableColumns = (tableName?: string) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return useSWR(isDBInited && tableName ? FETCH_TABLE_COLUMN_KEY(tableName) : null, ([, table]) =>
|
|
14
|
+
return useSWR(tableName ? FETCH_TABLE_COLUMN_KEY(tableName) : null, ([, table]) =>
|
|
21
15
|
tableViewerService.getTableDetails(table),
|
|
22
16
|
);
|
|
23
17
|
};
|
|
24
18
|
|
|
25
19
|
export const usePgTable = (tableName?: string) => {
|
|
26
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
27
|
-
|
|
28
20
|
return useSWR(
|
|
29
|
-
|
|
21
|
+
tableName ? FETCH_TABLE_DATA_KEY(tableName) : null,
|
|
30
22
|
([, table]) => tableViewerService.getTableData(table) as any,
|
|
31
23
|
);
|
|
32
24
|
};
|
|
@@ -9,12 +9,10 @@ import { useTranslation } from 'react-i18next';
|
|
|
9
9
|
import { Flexbox } from 'react-layout-kit';
|
|
10
10
|
|
|
11
11
|
import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
|
|
12
|
-
import { isDeprecatedEdition } from '@/const/version';
|
|
13
12
|
import ActionDropdown from '@/features/ChatInput/ActionBar/components/ActionDropdown';
|
|
14
13
|
import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
|
|
15
14
|
import { useAgentStore } from '@/store/agent';
|
|
16
15
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
17
|
-
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
18
16
|
import { EnabledProviderWithModels } from '@/types/aiProvider';
|
|
19
17
|
|
|
20
18
|
const useStyles = createStyles(({ css, prefixCls }) => ({
|
|
@@ -55,7 +53,6 @@ const ModelSwitchPanel = memo<IProps>(({ children, onOpenChange, open }) => {
|
|
|
55
53
|
agentSelectors.currentAgentModelProvider(s),
|
|
56
54
|
s.updateAgentConfig,
|
|
57
55
|
]);
|
|
58
|
-
const { showLLM } = useServerConfigStore(featureFlagsSelectors);
|
|
59
56
|
const router = useRouter();
|
|
60
57
|
const enabledList = useEnabledChatModels();
|
|
61
58
|
|
|
@@ -81,11 +78,7 @@ const ModelSwitchPanel = memo<IProps>(({ children, onOpenChange, open }) => {
|
|
|
81
78
|
</Flexbox>
|
|
82
79
|
),
|
|
83
80
|
onClick: () => {
|
|
84
|
-
router.push(
|
|
85
|
-
isDeprecatedEdition
|
|
86
|
-
? '/settings?active=llm'
|
|
87
|
-
: `/settings?active=provider&provider=${provider.id}`,
|
|
88
|
-
);
|
|
81
|
+
router.push(`/settings?active=provider&provider=${provider.id}`);
|
|
89
82
|
},
|
|
90
83
|
},
|
|
91
84
|
];
|
|
@@ -104,7 +97,7 @@ const ModelSwitchPanel = memo<IProps>(({ children, onOpenChange, open }) => {
|
|
|
104
97
|
</Flexbox>
|
|
105
98
|
),
|
|
106
99
|
onClick: () => {
|
|
107
|
-
router.push(
|
|
100
|
+
router.push('/settings?active=provider');
|
|
108
101
|
},
|
|
109
102
|
},
|
|
110
103
|
];
|
|
@@ -121,21 +114,13 @@ const ModelSwitchPanel = memo<IProps>(({ children, onOpenChange, open }) => {
|
|
|
121
114
|
provider={provider.id}
|
|
122
115
|
source={provider.source}
|
|
123
116
|
/>
|
|
124
|
-
{
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
>
|
|
132
|
-
<ActionIcon
|
|
133
|
-
icon={LucideBolt}
|
|
134
|
-
size={'small'}
|
|
135
|
-
title={t('ModelSwitchPanel.goToSettings')}
|
|
136
|
-
/>
|
|
137
|
-
</Link>
|
|
138
|
-
)}
|
|
117
|
+
<Link href={`/settings?active=provider&provider=${provider.id}`}>
|
|
118
|
+
<ActionIcon
|
|
119
|
+
icon={LucideBolt}
|
|
120
|
+
size={'small'}
|
|
121
|
+
title={t('ModelSwitchPanel.goToSettings')}
|
|
122
|
+
/>
|
|
123
|
+
</Link>
|
|
139
124
|
</Flexbox>
|
|
140
125
|
),
|
|
141
126
|
type: 'group',
|
|
@@ -3,7 +3,6 @@ import { memo, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
|
5
5
|
|
|
6
|
-
import { isServerMode } from '@/const/version';
|
|
7
6
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
|
8
7
|
|
|
9
8
|
import ShareImage from './ShareImage';
|
|
@@ -24,7 +23,7 @@ const ShareModal = memo<ModalProps>(({ onCancel, open }) => {
|
|
|
24
23
|
const isMobile = useIsMobile();
|
|
25
24
|
|
|
26
25
|
const tabItems = useMemo(() => {
|
|
27
|
-
|
|
26
|
+
return [
|
|
28
27
|
{
|
|
29
28
|
children: <ShareImage mobile={isMobile} />,
|
|
30
29
|
key: Tab.Screenshot,
|
|
@@ -35,24 +34,19 @@ const ShareModal = memo<ModalProps>(({ onCancel, open }) => {
|
|
|
35
34
|
key: Tab.Text,
|
|
36
35
|
label: t('shareModal.text'),
|
|
37
36
|
},
|
|
37
|
+
{
|
|
38
|
+
children: <SharePdf />,
|
|
39
|
+
key: Tab.PDF,
|
|
40
|
+
label: t('shareModal.pdf'),
|
|
41
|
+
},
|
|
38
42
|
{
|
|
39
43
|
children: <ShareJSON />,
|
|
40
44
|
key: Tab.JSON,
|
|
41
45
|
label: 'JSON',
|
|
42
46
|
},
|
|
43
47
|
];
|
|
44
|
-
|
|
45
|
-
// Only add PDF tab in server mode
|
|
46
|
-
if (isServerMode) {
|
|
47
|
-
items.splice(2, 0, {
|
|
48
|
-
children: <SharePdf />,
|
|
49
|
-
key: Tab.PDF,
|
|
50
|
-
label: t('shareModal.pdf'),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return items;
|
|
55
48
|
}, [isMobile, t]);
|
|
49
|
+
|
|
56
50
|
return (
|
|
57
51
|
<Modal
|
|
58
52
|
allowFullscreen
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { enableNextAuth } from '@lobechat/const';
|
|
1
2
|
import Link from 'next/link';
|
|
2
3
|
import { useRouter } from 'next/navigation';
|
|
3
4
|
import { memo } from 'react';
|
|
@@ -5,8 +6,6 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
5
6
|
|
|
6
7
|
import BrandWatermark from '@/components/BrandWatermark';
|
|
7
8
|
import Menu from '@/components/Menu';
|
|
8
|
-
import { enableAuth, enableNextAuth } from '@/const/auth';
|
|
9
|
-
import { isDeprecatedEdition } from '@/const/version';
|
|
10
9
|
import { useUserStore } from '@/store/user';
|
|
11
10
|
import { authSelectors } from '@/store/user/selectors';
|
|
12
11
|
|
|
@@ -38,14 +37,13 @@ const PanelContent = memo<{ closePopover: () => void }>(({ closePopover }) => {
|
|
|
38
37
|
|
|
39
38
|
return (
|
|
40
39
|
<Flexbox gap={2} style={{ minWidth: 300 }}>
|
|
41
|
-
{
|
|
40
|
+
{isLoginWithAuth ? (
|
|
42
41
|
<>
|
|
43
42
|
<UserInfo avatarProps={{ clickable: false }} />
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)}
|
|
43
|
+
|
|
44
|
+
<Link href={'/profile/stats'} style={{ color: 'inherit' }}>
|
|
45
|
+
<DataStatistics />
|
|
46
|
+
</Link>
|
|
49
47
|
</>
|
|
50
48
|
) : (
|
|
51
49
|
<UserLoginOrSignup onClick={handleSignIn} />
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { useGlobalStore } from '@/store/global';
|
|
2
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
3
1
|
import { useToolStore } from '@/store/tool';
|
|
4
2
|
|
|
5
3
|
export const useCheckPluginsIsInstalled = (plugins: string[]) => {
|
|
6
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
7
4
|
const checkPluginsIsInstalled = useToolStore((s) => s.useCheckPluginsIsInstalled);
|
|
8
5
|
|
|
9
|
-
checkPluginsIsInstalled(
|
|
6
|
+
checkPluginsIsInstalled(true, plugins);
|
|
10
7
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useChatGroupStore } from '@/store/chatGroup';
|
|
2
|
-
import { useGlobalStore } from '@/store/global';
|
|
3
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
4
2
|
import { useUserStore } from '@/store/user';
|
|
5
3
|
import { authSelectors } from '@/store/user/slices/auth/selectors';
|
|
6
4
|
|
|
7
5
|
export const useFetchGroups = () => {
|
|
8
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
9
6
|
const isLogin = useUserStore(authSelectors.isLogin);
|
|
10
7
|
const useFetchGroups = useChatGroupStore((s) => s.useFetchGroups);
|
|
11
8
|
|
|
12
|
-
useFetchGroups(
|
|
9
|
+
useFetchGroups(true, isLogin ?? false);
|
|
13
10
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { useGlobalStore } from '@/store/global';
|
|
2
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
3
1
|
import { useToolStore } from '@/store/tool';
|
|
4
2
|
|
|
5
3
|
export const useFetchInstalledPlugins = () => {
|
|
6
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
7
4
|
const [useFetchInstalledPlugins] = useToolStore((s) => [s.useFetchInstalledPlugins]);
|
|
8
5
|
|
|
9
|
-
return useFetchInstalledPlugins(
|
|
6
|
+
return useFetchInstalledPlugins(true);
|
|
10
7
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useChatStore } from '@/store/chat';
|
|
4
|
-
import { useGlobalStore } from '@/store/global';
|
|
5
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
6
4
|
import { useSessionStore } from '@/store/session';
|
|
7
5
|
import { sessionSelectors } from '@/store/session/selectors';
|
|
8
6
|
|
|
9
7
|
export const useFetchMessages = () => {
|
|
10
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
11
8
|
const sessionId = useSessionStore((s) => s.activeId);
|
|
12
9
|
const [activeTopicId, useFetchMessages, internal_updateActiveSessionType] = useChatStore((s) => [
|
|
13
10
|
s.activeTopicId,
|
|
@@ -29,5 +26,5 @@ export const useFetchMessages = () => {
|
|
|
29
26
|
}
|
|
30
27
|
}, [currentSession?.id, currentSession?.type, internal_updateActiveSessionType]);
|
|
31
28
|
|
|
32
|
-
useFetchMessages(
|
|
29
|
+
useFetchMessages(true, sessionId, activeTopicId, isGroupSession ? 'group' : 'session');
|
|
33
30
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { useGlobalStore } from '@/store/global';
|
|
2
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
3
1
|
import { useSessionStore } from '@/store/session';
|
|
4
2
|
import { useUserStore } from '@/store/user';
|
|
5
3
|
import { authSelectors } from '@/store/user/slices/auth/selectors';
|
|
6
4
|
|
|
7
5
|
export const useFetchSessions = () => {
|
|
8
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
9
6
|
const isLogin = useUserStore(authSelectors.isLogin);
|
|
10
7
|
const useFetchSessions = useSessionStore((s) => s.useFetchSessions);
|
|
11
8
|
|
|
12
|
-
useFetchSessions(
|
|
9
|
+
useFetchSessions(true, isLogin);
|
|
13
10
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { useChatStore } from '@/store/chat';
|
|
2
|
-
import { useGlobalStore } from '@/store/global';
|
|
3
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
4
2
|
|
|
5
3
|
export const useFetchThreads = (activeTopicId?: string) => {
|
|
6
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
7
|
-
|
|
8
4
|
const [useFetchThreads] = useChatStore((s) => [s.useFetchThreads]);
|
|
9
5
|
|
|
10
|
-
useFetchThreads(
|
|
6
|
+
useFetchThreads(true, activeTopicId);
|
|
11
7
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { useChatStore } from '@/store/chat';
|
|
2
|
-
import { useGlobalStore } from '@/store/global';
|
|
3
|
-
import { systemStatusSelectors } from '@/store/global/selectors';
|
|
4
2
|
import { useSessionStore } from '@/store/session';
|
|
5
3
|
|
|
6
4
|
/**
|
|
@@ -9,7 +7,6 @@ import { useSessionStore } from '@/store/session';
|
|
|
9
7
|
export const useFetchTopics = () => {
|
|
10
8
|
const [sessionId] = useSessionStore((s) => [s.activeId]);
|
|
11
9
|
const useFetchTopics = useChatStore((s) => s.useFetchTopics);
|
|
12
|
-
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
|
|
13
10
|
|
|
14
|
-
useFetchTopics(
|
|
11
|
+
useFetchTopics(true, sessionId);
|
|
15
12
|
};
|
|
@@ -42,26 +42,7 @@ vi.mock('@/store/global', () => ({
|
|
|
42
42
|
setState: vi.fn(),
|
|
43
43
|
},
|
|
44
44
|
}));
|
|
45
|
-
let isDeprecatedEdition = false;
|
|
46
|
-
vi.mock('@/const/version', async (importOriginal) => {
|
|
47
|
-
const actual = await importOriginal<typeof import('@/const/version')>();
|
|
48
|
-
return {
|
|
49
|
-
...actual,
|
|
50
|
-
get isDeprecatedEdition() {
|
|
51
|
-
return isDeprecatedEdition;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
45
|
describe('useOpenChatSettings', () => {
|
|
57
|
-
it('should handle inbox session id correctly', () => {
|
|
58
|
-
isDeprecatedEdition = true;
|
|
59
|
-
vi.mocked(useSessionStore).mockReturnValue(INBOX_SESSION_ID);
|
|
60
|
-
const { result } = renderHook(() => useOpenChatSettings());
|
|
61
|
-
|
|
62
|
-
expect(result.current()).toBe('/settings?active=agent'); // Assuming openSettings returns a function
|
|
63
|
-
isDeprecatedEdition = false;
|
|
64
|
-
});
|
|
65
46
|
|
|
66
47
|
it('should handle mobile route for chat settings', () => {
|
|
67
48
|
vi.mocked(useSessionStore).mockReturnValue('123');
|