mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
fix(core): temporarily make AI functions not follow server configuration (#8698)
Since the switch of the AI function in Blocksuite cannot be hot-updated, the editor will not be able to use the AI function when it is not connected to the server at the beginning, so this code is temporarily removed.
This commit is contained in:
@@ -1,9 +1,4 @@
|
|||||||
import { ServerConfigService } from '@affine/core/modules/cloud';
|
import { FeatureFlagService, useService } from '@toeverything/infra';
|
||||||
import {
|
|
||||||
FeatureFlagService,
|
|
||||||
useLiveData,
|
|
||||||
useService,
|
|
||||||
} from '@toeverything/infra';
|
|
||||||
import { Suspense, useCallback, useEffect, useState } from 'react';
|
import { Suspense, useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { AIOnboardingEdgeless } from './edgeless.dialog';
|
import { AIOnboardingEdgeless } from './edgeless.dialog';
|
||||||
@@ -35,12 +30,7 @@ export const WorkspaceAIOnboarding = () => {
|
|||||||
const [dismissGeneral] = useDismiss(AIOnboardingType.GENERAL);
|
const [dismissGeneral] = useDismiss(AIOnboardingType.GENERAL);
|
||||||
const [dismissLocal] = useDismiss(AIOnboardingType.LOCAL);
|
const [dismissLocal] = useDismiss(AIOnboardingType.LOCAL);
|
||||||
const featureFlagService = useService(FeatureFlagService);
|
const featureFlagService = useService(FeatureFlagService);
|
||||||
const serverConfigService = useService(ServerConfigService);
|
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||||
const serverFeatures = useLiveData(
|
|
||||||
serverConfigService.serverConfig.features$
|
|
||||||
);
|
|
||||||
const enableAI =
|
|
||||||
serverFeatures?.copilot && featureFlagService.flags.enable_ai.value;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
@@ -53,12 +43,7 @@ export const WorkspaceAIOnboarding = () => {
|
|||||||
export const PageAIOnboarding = () => {
|
export const PageAIOnboarding = () => {
|
||||||
const [dismissEdgeless] = useDismiss(AIOnboardingType.EDGELESS);
|
const [dismissEdgeless] = useDismiss(AIOnboardingType.EDGELESS);
|
||||||
const featureFlagService = useService(FeatureFlagService);
|
const featureFlagService = useService(FeatureFlagService);
|
||||||
const serverConfigService = useService(ServerConfigService);
|
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||||
const serverFeatures = useLiveData(
|
|
||||||
serverConfigService.serverConfig.features$
|
|
||||||
);
|
|
||||||
const enableAI =
|
|
||||||
serverFeatures?.copilot && featureFlagService.flags.enable_ai.value;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
useConfirmModal,
|
useConfirmModal,
|
||||||
useLitPortalFactory,
|
useLitPortalFactory,
|
||||||
} from '@affine/component';
|
} from '@affine/component';
|
||||||
import { ServerConfigService } from '@affine/core/modules/cloud';
|
|
||||||
import { EditorService } from '@affine/core/modules/editor';
|
import { EditorService } from '@affine/core/modules/editor';
|
||||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||||
import { JournalService } from '@affine/core/modules/journal';
|
import { JournalService } from '@affine/core/modules/journal';
|
||||||
@@ -91,7 +90,6 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
|||||||
editorService,
|
editorService,
|
||||||
workspaceService,
|
workspaceService,
|
||||||
featureFlagService,
|
featureFlagService,
|
||||||
serverConfigService,
|
|
||||||
} = useServices({
|
} = useServices({
|
||||||
PeekViewService,
|
PeekViewService,
|
||||||
DocService,
|
DocService,
|
||||||
@@ -99,12 +97,8 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
|||||||
WorkspaceService,
|
WorkspaceService,
|
||||||
EditorService,
|
EditorService,
|
||||||
FeatureFlagService,
|
FeatureFlagService,
|
||||||
ServerConfigService,
|
|
||||||
});
|
});
|
||||||
const framework = useFramework();
|
const framework = useFramework();
|
||||||
const serverFeatures = useLiveData(
|
|
||||||
serverConfigService.serverConfig.features$
|
|
||||||
);
|
|
||||||
const referenceRenderer: ReferenceReactRenderer = useMemo(() => {
|
const referenceRenderer: ReferenceReactRenderer = useMemo(() => {
|
||||||
return function customReference(reference) {
|
return function customReference(reference) {
|
||||||
const data = reference.delta.attributes?.reference;
|
const data = reference.delta.attributes?.reference;
|
||||||
@@ -130,17 +124,11 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
|||||||
}, [workspaceService]);
|
}, [workspaceService]);
|
||||||
|
|
||||||
const specs = useMemo(() => {
|
const specs = useMemo(() => {
|
||||||
const enableAI =
|
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||||
serverFeatures?.copilot && featureFlagService.flags.enable_ai.value;
|
|
||||||
return mode === 'edgeless'
|
return mode === 'edgeless'
|
||||||
? createEdgelessModeSpecs(framework, !!enableAI)
|
? createEdgelessModeSpecs(framework, !!enableAI)
|
||||||
: createPageModeSpecs(framework, !!enableAI);
|
: createPageModeSpecs(framework, !!enableAI);
|
||||||
}, [
|
}, [featureFlagService.flags.enable_ai.value, mode, framework]);
|
||||||
serverFeatures?.copilot,
|
|
||||||
featureFlagService.flags.enable_ai.value,
|
|
||||||
mode,
|
|
||||||
framework,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const confirmModal = useConfirmModal();
|
const confirmModal = useConfirmModal();
|
||||||
const patchedSpecs = useMemo(() => {
|
const patchedSpecs = useMemo(() => {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { EditorOutlineViewer } from '@affine/core/components/blocksuite/outline-
|
|||||||
import { DocPropertySidebar } from '@affine/core/components/doc-properties/sidebar';
|
import { DocPropertySidebar } from '@affine/core/components/doc-properties/sidebar';
|
||||||
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
|
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
|
||||||
import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta';
|
import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-page-meta';
|
||||||
import { ServerConfigService } from '@affine/core/modules/cloud';
|
|
||||||
import { EditorService } from '@affine/core/modules/editor';
|
import { EditorService } from '@affine/core/modules/editor';
|
||||||
import { RecentDocsService } from '@affine/core/modules/quicksearch';
|
import { RecentDocsService } from '@affine/core/modules/quicksearch';
|
||||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||||
@@ -70,7 +69,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
workspaceService,
|
workspaceService,
|
||||||
globalContextService,
|
globalContextService,
|
||||||
featureFlagService,
|
featureFlagService,
|
||||||
serverConfigService,
|
|
||||||
} = useServices({
|
} = useServices({
|
||||||
WorkbenchService,
|
WorkbenchService,
|
||||||
ViewService,
|
ViewService,
|
||||||
@@ -79,7 +77,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
WorkspaceService,
|
WorkspaceService,
|
||||||
GlobalContextService,
|
GlobalContextService,
|
||||||
FeatureFlagService,
|
FeatureFlagService,
|
||||||
ServerConfigService,
|
|
||||||
});
|
});
|
||||||
const workbench = workbenchService.workbench;
|
const workbench = workbenchService.workbench;
|
||||||
const editor = editorService.editor;
|
const editor = editorService.editor;
|
||||||
@@ -106,12 +103,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
const [_, setActiveBlockSuiteEditor] = useActiveBlocksuiteEditor();
|
const [_, setActiveBlockSuiteEditor] = useActiveBlocksuiteEditor();
|
||||||
|
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||||
const serverFeatures = useLiveData(
|
|
||||||
serverConfigService.serverConfig.features$
|
|
||||||
);
|
|
||||||
const enableAI =
|
|
||||||
serverFeatures?.copilot && featureFlagService.flags.enable_ai.value;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isActiveView) {
|
if (isActiveView) {
|
||||||
|
|||||||
Reference in New Issue
Block a user