mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(core): hide intelligence entrance when ai is disabled (#13251)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * The AI Chat button is now only visible when AI features are enabled and supported by the server, ensuring users see it only when available. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -10,8 +10,9 @@ import {
|
||||
SidebarScrollableContainer,
|
||||
} from '@affine/core/modules/app-sidebar/views';
|
||||
import { ExternalMenuLinkItem } from '@affine/core/modules/app-sidebar/views/menu-item/external-menu-link-item';
|
||||
import { AuthService } from '@affine/core/modules/cloud';
|
||||
import { AuthService, ServerService } from '@affine/core/modules/cloud';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
||||
import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/services/cmdk';
|
||||
import type { Workspace } from '@affine/core/modules/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
@@ -88,6 +89,11 @@ const AllDocsButton = () => {
|
||||
};
|
||||
|
||||
const AIChatButton = () => {
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const serverService = useService(ServerService);
|
||||
const serverFeatures = useLiveData(serverService.server.features$);
|
||||
const enableAI = useLiveData(featureFlagService.flags.enable_ai.$);
|
||||
|
||||
const { workbenchService } = useServices({
|
||||
WorkbenchService,
|
||||
});
|
||||
@@ -96,6 +102,10 @@ const AIChatButton = () => {
|
||||
workbench.location$.selector(location => location.pathname === '/chat')
|
||||
);
|
||||
|
||||
if (!enableAI || !serverFeatures?.copilot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuLinkItem icon={<AiOutlineIcon />} active={aiChatActive} to={'/chat'}>
|
||||
<span data-testid="ai-chat">Intelligence</span>
|
||||
|
||||
Reference in New Issue
Block a user