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.

🐛 fix(messenger): hide the Messenger settings entry on non-business deployments (#20438)

Arvin Xua014886501ef
diff --git a/src/features/Messenger/PushResourceModal/useSendToMessengerMenuItem.tsx b/src/features/Messenger/PushResourceModal/useSendToMessengerMenuItem.tsx
index 830df8b36d2..bb3ed5b2591 100644
--- a/src/features/Messenger/PushResourceModal/useSendToMessengerMenuItem.tsx
+++ b/src/features/Messenger/PushResourceModal/useSendToMessengerMenuItem.tsx
@@ -10,6 +10,7 @@ import useSWR from 'swr';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { messengerKeys } from '@/libs/swr/keys';
import { messengerService } from '@/services/messenger';
+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
import {
type MessengerPlatform,
@@ -43,14 +44,18 @@ export const useSendToMessengerMenuItem = ({
}: UseSendToMessengerMenuItemParams): ItemType | null => {
const { t } = useTranslation(['components', 'common']);
const navigate = useWorkspaceAwareNavigate();
+ // Messenger bots only exist on business deployments; elsewhere the entry
+ // would lead to a settings page that is hidden.
+ const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
+ const active = enabled && enableBusinessFeatures;
const platformsSWR = useSWR(
- enabled ? messengerKeys.availablePlatforms() : null,
+ active ? messengerKeys.availablePlatforms() : null,
() => messengerService.availablePlatforms(),
{ revalidateOnFocus: false },
);
const linksSWR = useSWR(
- enabled ? messengerKeys.listMyLinks() : null,
+ active ? messengerKeys.listMyLinks() : null,
() => messengerService.listMyLinks(),
{ revalidateOnFocus: false },
);
@@ -69,7 +74,7 @@ export const useSendToMessengerMenuItem = ({
(installationsSWR.data ?? []).map((i) => [i.tenantId, i.tenantName]),
);
- if (!enabled) return null;
+ if (!active) return null;
let children: ItemType[];
diff --git a/src/features/Settings/hooks/useCategory.test.tsx b/src/features/Settings/hooks/useCategory.test.tsx
index c06ff62ca80..f37361fe3f5 100644
--- a/src/features/Settings/hooks/useCategory.test.tsx
+++ b/src/features/Settings/hooks/useCategory.test.tsx
@@ -20,11 +20,12 @@ vi.hoisted(() => {
});
});
-const createWrapper = (showProvider: boolean) => {
+const createWrapper = (showProvider: boolean, enableBusinessFeatures = false) => {
const Wrapper = ({ children }: { children: ReactNode }) => (
<Provider
createStore={() =>
initServerConfigStore({
+ serverConfig: { aiProvider: {}, enableBusinessFeatures, telemetry: {} },
featureFlags: {
...mapFeatureFlagsEnvToState({
provider_settings: true,
@@ -72,7 +73,6 @@ describe('settings useCategory', () => {
SettingsTabs.Profile,
SettingsTabs.Appearance,
SettingsTabs.Hotkey,
- SettingsTabs.Messenger,
]);
expect(generalGroup?.items.map((item) => item.key)).toEqual([
SettingsTabs.Stats,
@@ -83,6 +83,18 @@ describe('settings useCategory', () => {
).not.toContain(SettingsTabs.Messenger);
});
+ // Messenger bots are LobeHub-operated and only configurable from the cloud
+ // admin, so the tab is a dead end on self-hosted deployments.
+ it('shows Messenger in the Account group only with business features on', () => {
+ expect(getItemKeys()).not.toContain(SettingsTabs.Messenger);
+
+ const { result } = renderHook(() => useCategory(), {
+ wrapper: createWrapper(true, true),
+ });
+ const accountGroup = result.current.find((group) => group.key === SettingsGroupKey.Account);
+ expect(accountGroup?.items.map((item) => item.key)).toContain(SettingsTabs.Messenger);
+ });
+
it('keeps Provider visible when provider settings are enabled', () => {
expect(getItemKeys()).toContain(SettingsTabs.Provider);
});
diff --git a/src/features/Settings/hooks/useCategory.tsx b/src/features/Settings/hooks/useCategory.tsx
index f2e6a5eaa5b..f72875a46e1 100644
--- a/src/features/Settings/hooks/useCategory.tsx
+++ b/src/features/Settings/hooks/useCategory.tsx
@@ -121,8 +121,10 @@ export const useCategory = () => {
label: t('tab.hotkey'),
},
// Messenger bindings are a per-user identity (owned by userId), so they
- // live with the account rather than the agent configuration.
- {
+ // live with the account rather than the agent configuration. The bots
+ // are LobeHub-operated: their credentials are only ever written by the
+ // cloud admin, so a self-hosted deployment has nothing to bind to.
+ enableBusinessFeatures && {
icon: MessageCircleIcon,
key: SettingsTabs.Messenger,
label: t('tab.messenger'),
diff --git a/src/features/SettingsSearch/useSettingsSearch.ts b/src/features/SettingsSearch/useSettingsSearch.ts
index 8818ecd1494..16ea62bd8b2 100644
--- a/src/features/SettingsSearch/useSettingsSearch.ts
+++ b/src/features/SettingsSearch/useSettingsSearch.ts
@@ -179,8 +179,10 @@ export const useSettingsSearch = (
// IM notification channels (Telegram / Slack / …) live on the notification
// page with per-platform anchors. Index them from the same catalog the page
// renders so a search for the platform name deep-links to that row.
+ // Those rows come from the business notification section, so they only
+ // exist with business features on.
const notificationTab = visibleTabs.get(SettingsTabs.Notification);
- if (notificationTab)
+ if (notificationTab && enableBusinessFeatures)
for (const platform of SUPPORTED_MESSENGER_PLATFORMS) {
entries.push({
anchor: `notification-${platform.id}`,