Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor: use server config for business features (#16015)

YuTengjing6cbfe4389de9
diff --git a/src/features/Auth/SignIn/useSignIn.test.ts b/src/features/Auth/SignIn/useSignIn.test.ts
index 1d6e7148673..3e6c4584ab6 100644
--- a/src/features/Auth/SignIn/useSignIn.test.ts
+++ b/src/features/Auth/SignIn/useSignIn.test.ts
@@ -12,6 +12,11 @@ const mockSignInOauth2 = vi.hoisted(() => vi.fn());
const mockSignInEmail = vi.hoisted(() => vi.fn());
const mockSignInMagicLink = vi.hoisted(() => vi.fn());
const mockRequestPasswordReset = vi.hoisted(() => vi.fn());
+const mockBusinessSignin = vi.hoisted(() => ({
+ getAdditionalData: vi.fn(async () => ({})),
+ preSocialSigninCheck: vi.fn(async () => true),
+ ssoProviders: [] as string[],
+}));
const mockLocalStorage = vi.hoisted(() => {
const store = new Map<string, string>();
@@ -49,22 +54,23 @@ vi.mock('@/libs/better-auth/utils/client', () => ({
vi.mock('@lobechat/business-const', () => ({
BRANDING_NAME: 'LobeHub',
- ENABLE_BUSINESS_FEATURES: false,
}));
vi.mock('@/business/client/hooks/useBusinessSignin', () => ({
useBusinessSignin: () => ({
- getAdditionalData: async () => ({}),
- preSocialSigninCheck: async () => true,
- ssoProviders: [],
+ getAdditionalData: mockBusinessSignin.getAdditionalData,
+ preSocialSigninCheck: mockBusinessSignin.preSocialSigninCheck,
+ ssoProviders: mockBusinessSignin.ssoProviders,
}),
}));
+let mockEnableBusinessFeatures = false;
vi.mock('@/features/AuthShell', () => ({
useAuthServerConfigStore: (selector: (s: any) => any) =>
selector({
serverConfig: {
disableEmailPassword: false,
+ enableBusinessFeatures: mockEnableBusinessFeatures,
enableMagicLink: false,
oAuthSSOProviders: ['google', 'github'],
},
@@ -105,6 +111,10 @@ describe('useSignIn', () => {
vi.clearAllMocks();
mockLocalStorage.clear();
mockSearchParamsGet.mockReturnValue(null);
+ mockEnableBusinessFeatures = false;
+ mockBusinessSignin.ssoProviders = [];
+ mockBusinessSignin.getAdditionalData.mockResolvedValue({});
+ mockBusinessSignin.preSocialSigninCheck.mockResolvedValue(true);
Object.defineProperty(window, 'location', {
configurable: true,
value: { ...originalLocation, href: '' },
@@ -419,6 +429,20 @@ describe('useSignIn', () => {
expect(localStorage.getItem('lobehub:auth:last-provider:v1')).toBe('google');
});
+
+ it('should stop social sign in when business pre-check rejects', async () => {
+ mockEnableBusinessFeatures = true;
+ mockBusinessSignin.preSocialSigninCheck.mockResolvedValue(false);
+
+ const { result } = renderHook(() => useSignIn());
+
+ await act(async () => {
+ await result.current.handleSocialSignIn('google');
+ });
+
+ expect(mockBusinessSignin.preSocialSigninCheck).toHaveBeenCalled();
+ expect(mockSignInSocial).not.toHaveBeenCalled();
+ });
});
describe('handleBackToEmail', () => {
@@ -495,5 +519,14 @@ describe('useSignIn', () => {
localStorage.removeItem('lobehub:auth:last-provider:v1');
});
+
+ it('should use business SSO providers when business features are enabled by server config', () => {
+ mockEnableBusinessFeatures = true;
+ mockBusinessSignin.ssoProviders = ['saml'];
+
+ const { result } = renderHook(() => useSignIn());
+
+ expect(result.current.oAuthSSOProviders).toEqual(['saml']);
+ });
});
});
diff --git a/src/features/Auth/SignIn/useSignIn.ts b/src/features/Auth/SignIn/useSignIn.ts
index 97f788436e8..9da7324ffe0 100644
--- a/src/features/Auth/SignIn/useSignIn.ts
+++ b/src/features/Auth/SignIn/useSignIn.ts
@@ -1,4 +1,3 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { Form } from 'antd';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -38,6 +37,9 @@ export const useSignIn = () => {
const disableEmailPassword = useAuthServerConfigStore(
(s) => s.serverConfig.disableEmailPassword || false,
);
+ const enableBusinessFeatures = useAuthServerConfigStore(
+ (s) => s.serverConfig.enableBusinessFeatures || false,
+ );
const [form] = Form.useForm<SignInFormValues>();
const [loading, setLoading] = useState(false);
const [socialLoading, setSocialLoading] = useState<string | null>(null);
@@ -222,7 +224,7 @@ export const useSignIn = () => {
});
try {
- if (ENABLE_BUSINESS_FEATURES && !(await preSocialSigninCheck())) {
+ if (enableBusinessFeatures && !(await preSocialSigninCheck())) {
setSocialLoading(null);
return;
}
@@ -296,7 +298,7 @@ export const useSignIn = () => {
}
};
- const resolvedProviders = ENABLE_BUSINESS_FEATURES ? ssoProviders : oAuthSSOProviders;
+ const resolvedProviders = enableBusinessFeatures ? ssoProviders : oAuthSSOProviders;
const sortedProviders = lastAuthProvider
? [...resolvedProviders].sort((a, b) => {
if (a === lastAuthProvider) return -1;
@@ -319,7 +321,7 @@ export const useSignIn = () => {
lastAuthProvider,
loading,
oAuthSSOProviders: sortedProviders,
- serverConfigInit: ENABLE_BUSINESS_FEATURES ? true : serverConfigInit,
+ serverConfigInit: enableBusinessFeatures ? true : serverConfigInit,
socialLoading,
step,
};
diff --git a/src/features/Auth/SignUp/useSignUp.test.ts b/src/features/Auth/SignUp/useSignUp.test.ts
index 6d52a3c1d7f..82d5adaac6a 100644
--- a/src/features/Auth/SignUp/useSignUp.test.ts
+++ b/src/features/Auth/SignUp/useSignUp.test.ts
@@ -8,6 +8,7 @@ const mockSearchParamsGet = vi.hoisted(() => vi.fn().mockReturnValue(null));
const mockMessageError = vi.hoisted(() => vi.fn());
const mockSignUpEmail = vi.hoisted(() => vi.fn());
const mockGetCaptchaTokenOnError = vi.hoisted(() => vi.fn());
+const mockPreSocialSignupCheck = vi.hoisted(() => vi.fn(async () => true));
vi.mock('react-router-dom', () => ({
useNavigate: () => mockNavigate,
@@ -24,7 +25,6 @@ vi.mock('@/libs/better-auth/auth-client', () => ({
vi.mock('@lobechat/business-const', () => ({
BRANDING_NAME: 'LobeHub',
- ENABLE_BUSINESS_FEATURES: false,
}));
vi.mock('@/business/client/hooks/useBusinessSignup', () => ({
@@ -32,15 +32,17 @@ vi.mock('@/business/client/hooks/useBusinessSignup', () => ({
businessElement: null,
getCaptchaTokenOnError: mockGetCaptchaTokenOnError,
getFetchOptions: async () => undefined,
- preSocialSignupCheck: async () => true,
+ preSocialSignupCheck: mockPreSocialSignupCheck,
}),
}));
let mockEnableEmailVerification = false;
+let mockEnableBusinessFeatures = false;
vi.mock('@/features/AuthShell', () => ({
useAuthServerConfigStore: (selector: (s: any) => any) =>
selector({
serverConfig: {
+ enableBusinessFeatures: mockEnableBusinessFeatures,
enableEmailVerification: mockEnableEmailVerification,
},
}),
@@ -53,6 +55,8 @@ describe('useSignUp', () => {
vi.clearAllMocks();
mockSearchParamsGet.mockReturnValue(null);
mockGetCaptchaTokenOnError.mockResolvedValue(undefined);
+ mockPreSocialSignupCheck.mockResolvedValue(true);
+ mockEnableBusinessFeatures = false;
mockEnableEmailVerification = false;
Object.defineProperty(window, 'location', {
configurable: true,
@@ -104,6 +108,20 @@ describe('useSignUp', () => {
);
});
+ it('should stop sign up when business pre-check rejects', async () => {
+ mockEnableBusinessFeatures = true;
+ mockPreSocialSignupCheck.mockResolvedValue(false);
+
+ const { result } = renderHook(() => useSignUp());
+
+ await act(async () => {
+ await result.current.onSubmit(validValues);
+ });
+
+ expect(mockPreSocialSignupCheck).toHaveBeenCalledWith(validValues);
+ expect(mockSignUpEmail).not.toHaveBeenCalled();
+ });
+
it('should redirect to onboarding on success', async () => {
mockSignUpEmail.mockResolvedValue({ error: null });
diff --git a/src/features/Auth/SignUp/useSignUp.ts b/src/features/Auth/SignUp/useSignUp.ts
index b76f7976e4f..567de754ce8 100644
--- a/src/features/Auth/SignUp/useSignUp.ts
+++ b/src/features/Auth/SignUp/useSignUp.ts
@@ -1,4 +1,3 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { Form } from 'antd';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -39,13 +38,16 @@ export const useSignUp = () => {
const enableEmailVerification = useAuthServerConfigStore(
(s) => s.serverConfig.enableEmailVerification || false,
);
+ const enableBusinessFeatures = useAuthServerConfigStore(
+ (s) => s.serverConfig.enableBusinessFeatures || false,
+ );
const handleSignUp = async (values: SignUpFormValues) => {
setLoading(true);
await trackLoginOrSignupClicked({ spm: 'signup.submit.click' });
try {
- if (ENABLE_BUSINESS_FEATURES && !(await preSocialSignupCheck(values))) {
+ if (enableBusinessFeatures && !(await preSocialSignupCheck(values))) {
setLoading(false);
return;
}
diff --git a/src/features/Conversation/Error/index.test.tsx b/src/features/Conversation/Error/index.test.tsx
index 495c4305df4..8ff1c126979 100644
--- a/src/features/Conversation/Error/index.test.tsx
+++ b/src/features/Conversation/Error/index.test.tsx
@@ -19,7 +19,6 @@ vi.mock('@lobechat/business-const', async (importOriginal) => {
return {
...actual,
- ENABLE_BUSINESS_FEATURES: false,
};
});
diff --git a/src/routes/(main)/home/features/InputArea/StarterList.tsx b/src/routes/(main)/home/features/InputArea/StarterList.tsx
index 3fe12b3c87c..ad2177a324b 100644
--- a/src/routes/(main)/home/features/InputArea/StarterList.tsx
+++ b/src/routes/(main)/home/features/InputArea/StarterList.tsx
@@ -18,7 +18,7 @@ import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
import { useResolvedHomeAgentId } from '../AgentSelect/useResolvedHomeAgentId';
-import { DEFAULT_HOME_NEW_MODELS, NEW_CHAT_PROVIDER } from './starterModels';
+import { useStarterModelDefaults } from './useStarterModelDefaults';
const styles = createStaticStyles(({ css, cssVar }) => ({
button: css`
@@ -42,7 +42,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
}));
const getStarterItemKey = (item: HomeNewModelItem) => `${item.type}:${item.model}`;
-const getStarterItemProvider = (item: HomeNewModelItem) => item.provider ?? NEW_CHAT_PROVIDER;
+const getStarterItemProvider = (item: HomeNewModelItem, fallbackProvider: string) =>
+ item.provider ?? fallbackProvider;
const skeletonWidths = [112, 150, 126, 138];
const StarterList = memo(() => {
@@ -53,7 +54,8 @@ const StarterList = memo(() => {
const { allowed: canCreateContent, reason } = usePermission('create_content');
const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);
const [switchingKey, setSwitchingKey] = useState<string | null>(null);
- const { isLoading, items } = useHomeNewModels(DEFAULT_HOME_NEW_MODELS);
+ const { defaultHomeNewModels, fallbackChatProvider } = useStarterModelDefaults();
+ const { isLoading, items } = useHomeNewModels(defaultHomeNewModels);
const applyBusinessModelModeConfig = useBusinessModelModeConfig();
const handleClick = useCallback(
@@ -75,7 +77,7 @@ const StarterList = memo(() => {
if (item.type === 'chat') {
if (!activeAgentId || switchingKey) return;
setSwitchingKey(key);
- const provider = getStarterItemProvider(item);
+ const provider = getStarterItemProvider(item, fallbackChatProvider);
try {
// Hydrate the agent's config before mutating so the optimistic update
// doesn't drop pre-existing fields the home input never loaded.
@@ -121,6 +123,7 @@ const StarterList = memo(() => {
applyBusinessModelModeConfig,
updateAgentConfigById,
switchingKey,
+ fallbackChatProvider,
message,
t,
],
@@ -132,7 +135,7 @@ const StarterList = memo(() => {
{t('starter.newLabel')}
</Tag>
{isLoading
- ? DEFAULT_HOME_NEW_MODELS.map((item, index) => (
+ ? defaultHomeNewModels.map((item, index) => (
<Skeleton.Button
active
key={getStarterItemKey(item)}
diff --git a/src/routes/(main)/home/features/InputArea/starterModels.test.ts b/src/routes/(main)/home/features/InputArea/starterModels.test.ts
deleted file mode 100644
index 721c0f02b1b..00000000000
--- a/src/routes/(main)/home/features/InputArea/starterModels.test.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
-import { describe, expect, it } from 'vitest';
-
-import {
- DEFAULT_HOME_NEW_MODELS,
- NEW_CHAT_MODEL,
- NEW_CHAT_PROVIDER,
- NEW_MINIMAX_PROVIDER,
-} from './starterModels';
-
-describe('starter models', () => {
- it('uses the Anthropic provider in OSS and the LobeHub provider in business builds', () => {
- expect(NEW_CHAT_MODEL).toBe('claude-opus-4-8');
- expect(NEW_CHAT_PROVIDER).toBe(ENABLE_BUSINESS_FEATURES ? 'lobehub' : 'anthropic');
- expect(NEW_MINIMAX_PROVIDER).toBe(ENABLE_BUSINESS_FEATURES ? 'lobehub' : 'minimax');
- });
-
- it('keeps the fallback home new model entries in the current product order', () => {
- const sharedItems = [
- {
- model: 'claude-opus-4-8',
- provider: NEW_CHAT_PROVIDER,
- title: 'Claude Opus 4.8',
- type: 'chat',
- },
- {
- model: 'gpt-image-2',
- title: 'GPT Image 2',
- type: 'image',
- },
- {
- model: 'dreamina-seedance-2-0-260128',
- title: 'Seedance 2.0',
- type: 'video',
- },
- ];
-
- expect(DEFAULT_HOME_NEW_MODELS).toEqual(
- ENABLE_BUSINESS_FEATURES
- ? [
- {
- model: 'MiniMax-M3',
- provider: NEW_MINIMAX_PROVIDER,
- title: 'MiniMax M3',
- type: 'chat',
- },
- ...sharedItems,
- ]
- : sharedItems,
- );
- });
-});
diff --git a/src/routes/(main)/home/features/InputArea/starterModels.ts b/src/routes/(main)/home/features/InputArea/starterModels.ts
index 507c5915594..c959f38b69c 100644
--- a/src/routes/(main)/home/features/InputArea/starterModels.ts
+++ b/src/routes/(main)/home/features/InputArea/starterModels.ts
@@ -1,14 +1,14 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
-
import type { HomeNewModelItem } from '@/business/client/hooks/useHomeNewModels';
// Chat
-export const NEW_MINIMAX_MODEL = 'MiniMax-M3';
-export const NEW_MINIMAX_PROVIDER = ENABLE_BUSINESS_FEATURES ? 'lobehub' : 'minimax';
-export const NEW_MINIMAX_MODEL_NAME = 'MiniMax M3';
-export const NEW_CHAT_MODEL = 'claude-opus-4-8';
-export const NEW_CHAT_PROVIDER = ENABLE_BUSINESS_FEATURES ? 'lobehub' : 'anthropic';
-export const NEW_CHAT_MODEL_NAME = 'Claude Opus 4.8';
+export const NEW_GLM_MODEL = 'glm-5.2';
+export const NEW_GLM_MODEL_NAME = 'GLM-5.2';
+export const NEW_KIMI_MODEL = 'kimi-k2.7-code';
+export const NEW_KIMI_MODEL_NAME = 'Kimi K2.7 Code';
+
+export const BUSINESS_CHAT_PROVIDER = 'lobehub';
+export const OSS_GLM_PROVIDER = 'zhipu';
+export const OSS_KIMI_PROVIDER = 'moonshot';
// Image
export const NEW_IMAGE_MODEL = 'gpt-image-2';
@@ -18,17 +18,17 @@ export const NEW_IMAGE_MODEL_NAME = 'GPT Image 2';
export const NEW_VIDEO_MODEL = 'dreamina-seedance-2-0-260128';
export const NEW_VIDEO_MODEL_NAME = 'Seedance 2.0';
-const BUSINESS_HOME_NEW_MODELS = [
+export const BUSINESS_HOME_NEW_MODELS = [
{
- model: NEW_MINIMAX_MODEL,
- provider: NEW_MINIMAX_PROVIDER,
- title: NEW_MINIMAX_MODEL_NAME,
+ model: NEW_GLM_MODEL,
+ provider: BUSINESS_CHAT_PROVIDER,
+ title: NEW_GLM_MODEL_NAME,
type: 'chat',
},
{
- model: NEW_CHAT_MODEL,
- provider: NEW_CHAT_PROVIDER,
- title: NEW_CHAT_MODEL_NAME,
+ model: NEW_KIMI_MODEL,
+ provider: BUSINESS_CHAT_PROVIDER,
+ title: NEW_KIMI_MODEL_NAME,
type: 'chat',
},
{
@@ -43,11 +43,17 @@ const BUSINESS_HOME_NEW_MODELS = [
},
] satisfies HomeNewModelItem[];
-const OSS_HOME_NEW_MODELS = [
+export const OSS_HOME_NEW_MODELS = [
+ {
+ model: NEW_GLM_MODEL,
+ provider: OSS_GLM_PROVIDER,
+ title: NEW_GLM_MODEL_NAME,
+ type: 'chat',
+ },
{
- model: NEW_CHAT_MODEL,
- provider: NEW_CHAT_PROVIDER,
- title: NEW_CHAT_MODEL_NAME,
+ model: NEW_KIMI_MODEL,
+ provider: OSS_KIMI_PROVIDER,
+ title: NEW_KIMI_MODEL_NAME,
type: 'chat',
},
{
@@ -61,7 +67,3 @@ const OSS_HOME_NEW_MODELS = [
type: 'video',
},
] satisfies HomeNewModelItem[];
-
-export const DEFAULT_HOME_NEW_MODELS = ENABLE_BUSINESS_FEATURES
- ? BUSINESS_HOME_NEW_MODELS
- : OSS_HOME_NEW_MODELS;
diff --git a/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.test.ts b/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.test.ts
new file mode 100644
index 00000000000..1ac7eb65065
--- /dev/null
+++ b/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.test.ts
@@ -0,0 +1,87 @@
+import { renderHook } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { NEW_GLM_MODEL } from './starterModels';
+import { useStarterModelDefaults } from './useStarterModelDefaults';
+
+const mocks = vi.hoisted(() => ({
+ enableBusinessFeatures: false,
+}));
+
+vi.mock('@/store/serverConfig', () => ({
+ serverConfigSelectors: {
+ enableBusinessFeatures: (state: { enableBusinessFeatures: boolean }) =>
+ state.enableBusinessFeatures,
+ },
+ useServerConfigStore: <T>(selector: (state: { enableBusinessFeatures: boolean }) => T) =>
+ selector({ enableBusinessFeatures: mocks.enableBusinessFeatures }),
+}));
+
+beforeEach(() => {
+ mocks.enableBusinessFeatures = false;
+});
+
+describe('useStarterModelDefaults', () => {
+ it('uses the OSS fallback home new model entries in the current product order', () => {
+ const { result } = renderHook(() => useStarterModelDefaults());
+
+ expect(NEW_GLM_MODEL).toBe('glm-5.2');
+ expect(result.current.fallbackChatProvider).toBe('zhipu');
+ expect(result.current.defaultHomeNewModels).toEqual([
+ {
+ model: 'glm-5.2',
+ provider: 'zhipu',
+ title: 'GLM-5.2',
+ type: 'chat',
+ },
+ {
+ model: 'kimi-k2.7-code',
+ provider: 'moonshot',
+ title: 'Kimi K2.7 Code',
+ type: 'chat',
+ },
+ {
+ model: 'gpt-image-2',
+ title: 'GPT Image 2',
+ type: 'image',
+ },
+ {
+ model: 'dreamina-seedance-2-0-260128',
+ title: 'Seedance 2.0',
+ type: 'video',
+ },
+ ]);
+ });
+
+ it('uses the business fallback home new model entries in the current product order', () => {
+ mocks.enableBusinessFeatures = true;
+
+ const { result } = renderHook(() => useStarterModelDefaults());
+
+ expect(result.current.fallbackChatProvider).toBe('lobehub');
+ expect(result.current.defaultHomeNewModels).toEqual([
+ {
+ model: 'glm-5.2',
+ provider: 'lobehub',
+ title: 'GLM-5.2',
+ type: 'chat',
+ },
+ {
+ model: 'kimi-k2.7-code',
+ provider: 'lobehub',
+ title: 'Kimi K2.7 Code',
+ type: 'chat',
+ },
+ {
+ model: 'gpt-image-2',
+ title: 'GPT Image 2',
+ type: 'image',
+ },
+ {
+ model: 'dreamina-seedance-2-0-260128',
+ title: 'Seedance 2.0',
+ type: 'video',
+ },
+ ]);
+ });
+});
diff --git a/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.ts b/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.ts
new file mode 100644
index 00000000000..0c29ee0d8e1
--- /dev/null
+++ b/src/routes/(main)/home/features/InputArea/useStarterModelDefaults.ts
@@ -0,0 +1,22 @@
+import { useMemo } from 'react';
+
+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
+
+import {
+ BUSINESS_CHAT_PROVIDER,
+ BUSINESS_HOME_NEW_MODELS,
+ OSS_GLM_PROVIDER,
+ OSS_HOME_NEW_MODELS,
+} from './starterModels';
+
+export const useStarterModelDefaults = () => {
+ const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
+
+ return useMemo(
+ () => ({
+ defaultHomeNewModels: enableBusinessFeatures ? BUSINESS_HOME_NEW_MODELS : OSS_HOME_NEW_MODELS,
+ fallbackChatProvider: enableBusinessFeatures ? BUSINESS_CHAT_PROVIDER : OSS_GLM_PROVIDER,
+ }),
+ [enableBusinessFeatures],
+ );
+};
diff --git a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
index 9e520969f5f..139b687ed9e 100644
--- a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
+++ b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts
@@ -5,7 +5,6 @@ import {
AgentManagementIdentifier,
createCallAgentManifest,
} from '@lobechat/builtin-tool-agent-management';
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { isDesktop, LOADING_FLAT } from '@lobechat/const';
import { formatSelectedSkillsContext, formatSelectedToolsContext } from '@lobechat/context-engine';
import { chainCompressContext } from '@lobechat/prompts';
@@ -57,6 +56,7 @@ import {
import { getElectronStoreState } from '@/store/electron';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { getServerConfigStoreState, serverConfigSelectors } from '@/store/serverConfig';
import { pageAgentRuntime } from '@/store/tool/slices/builtin/executors/lobe-page-agent';
import { type StoreSetter } from '@/store/types';
import { useUserMemoryStore } from '@/store/userMemory';
@@ -974,7 +974,11 @@ export class ConversationLifecycleActionImpl {
this.#get().updateOperationMetadata(operationId, { inputEditorTempState: null });
}
- if (ENABLE_BUSINESS_FEATURES) {
+ const serverConfigState = getServerConfigStoreState();
+ const enableBusinessFeatures =
+ !!serverConfigState && serverConfigSelectors.enableBusinessFeatures(serverConfigState);
+
+ if (enableBusinessFeatures) {
markUserValidAction();
}
diff --git a/src/store/image/slices/createImage/action.ts b/src/store/image/slices/createImage/action.ts
index ef521f44d69..220f7ddf748 100644
--- a/src/store/image/slices/createImage/action.ts
+++ b/src/store/image/slices/createImage/action.ts
@@ -1,9 +1,8 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
-
import { handleGenerationPromptModerationError } from '@/business/client/handleGenerationPromptModerationError';
import { handleLobeHubModelDeprecatedError } from '@/business/client/handleLobeHubModelDeprecatedError';
import { markUserValidAction } from '@/business/client/markUserValidAction';
import { imageService } from '@/services/image';
+import { getServerConfigStoreState, serverConfigSelectors } from '@/store/serverConfig';
import { type StoreSetter } from '@/store/types';
import { type ImageStore } from '../../store';
@@ -11,12 +10,6 @@ import { generationBatchSelectors } from '../generationBatch/selectors';
import { imageGenerationConfigSelectors } from '../generationConfig/selectors';
import { generationTopicSelectors } from '../generationTopic';
-// ====== action interface ====== //
-
-// ====== helper functions ====== //
-
-// ====== action implementation ====== //
-
type Setter = StoreSetter<ImageStore>;
export const createCreateImageSlice = (set: Setter, get: () => ImageStore, _api?: unknown) =>
new CreateImageActionImpl(set, get, _api);
@@ -81,7 +74,11 @@ export class CreateImageActionImpl {
);
}
- if (ENABLE_BUSINESS_FEATURES) {
+ const serverConfigState = getServerConfigStoreState();
+ const enableBusinessFeatures =
+ !!serverConfigState && serverConfigSelectors.enableBusinessFeatures(serverConfigState);
+
+ if (enableBusinessFeatures) {
markUserValidAction();
}
diff --git a/src/store/video/slices/createVideo/action.ts b/src/store/video/slices/createVideo/action.ts
index ba52218d565..7f8838d78e7 100644
--- a/src/store/video/slices/createVideo/action.ts
+++ b/src/store/video/slices/createVideo/action.ts
@@ -1,4 +1,3 @@
-import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { t } from 'i18next';
import { handleGenerationPromptModerationError } from '@/business/client/handleGenerationPromptModerationError';
@@ -6,6 +5,7 @@ import { handleLobeHubModelDeprecatedError } from '@/business/client/handleLobeH
import { markUserValidAction } from '@/business/client/markUserValidAction';
import { message } from '@/components/AntdStaticMethods';
import { videoService } from '@/services/video';
+import { getServerConfigStoreState, serverConfigSelectors } from '@/store/serverConfig';
import { type StoreSetter } from '@/store/types';
import { type VideoStore } from '../../store';
@@ -94,7 +94,11 @@ export class CreateVideoActionImpl {
);
}
- if (ENABLE_BUSINESS_FEATURES) {
+ const serverConfigState = getServerConfigStoreState();
+ const enableBusinessFeatures =
+ !!serverConfigState && serverConfigSelectors.enableBusinessFeatures(serverConfigState);
+
+ if (enableBusinessFeatures) {
markUserValidAction();
}