mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat(core): remove ai from experimental features (#6529)
This commit is contained in:
@@ -2,14 +2,7 @@ import { Button, Checkbox, Loading, Switch } from '@affine/component';
|
||||
import { SettingHeader } from '@affine/component/setting-components';
|
||||
import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import {
|
||||
useSetWorkspaceFeature,
|
||||
useWorkspaceAvailableFeatures,
|
||||
useWorkspaceEnabledFeatures,
|
||||
} from '@affine/core/hooks/use-workspace-features';
|
||||
import { FeatureType } from '@affine/graphql';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import type { WorkspaceMetadata } from '@toeverything/infra';
|
||||
import { useAtom } from 'jotai';
|
||||
import { atomWithStorage } from 'jotai/utils';
|
||||
import { Suspense, useCallback, useState } from 'react';
|
||||
@@ -73,12 +66,6 @@ const ExperimentalFeaturesPrompt = ({
|
||||
);
|
||||
};
|
||||
|
||||
interface ExperimentalFeaturesItemProps {
|
||||
feature: FeatureType;
|
||||
title: React.ReactNode;
|
||||
workspaceMetadata: WorkspaceMetadata;
|
||||
}
|
||||
|
||||
const ExperimentalFeaturesItem = ({
|
||||
title,
|
||||
isMutating,
|
||||
@@ -102,49 +89,6 @@ const ExperimentalFeaturesItem = ({
|
||||
);
|
||||
};
|
||||
|
||||
const WorkspaceFeaturesSettingItem = ({
|
||||
feature,
|
||||
title,
|
||||
workspaceMetadata,
|
||||
}: ExperimentalFeaturesItemProps) => {
|
||||
const enabledFeatures = useWorkspaceEnabledFeatures(workspaceMetadata);
|
||||
const enabled = enabledFeatures.includes(feature);
|
||||
const [localEnabled, setLocalEnabled] = useState(enabled);
|
||||
const { trigger, isMutating } = useSetWorkspaceFeature(workspaceMetadata);
|
||||
const onChange = useCallback(
|
||||
(checked: boolean) => {
|
||||
setLocalEnabled(checked);
|
||||
trigger(feature, checked);
|
||||
},
|
||||
[trigger, feature]
|
||||
);
|
||||
|
||||
return (
|
||||
<ExperimentalFeaturesItem
|
||||
title={title}
|
||||
isMutating={isMutating}
|
||||
checked={localEnabled}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const CopilotSettingRow = ({
|
||||
workspaceMetadata,
|
||||
}: {
|
||||
workspaceMetadata: WorkspaceMetadata;
|
||||
}) => {
|
||||
const features = useWorkspaceAvailableFeatures(workspaceMetadata);
|
||||
|
||||
return features.includes(FeatureType.Copilot) ? (
|
||||
<WorkspaceFeaturesSettingItem
|
||||
title="AI POC"
|
||||
workspaceMetadata={workspaceMetadata}
|
||||
feature={FeatureType.Copilot}
|
||||
/>
|
||||
) : null;
|
||||
};
|
||||
|
||||
const SplitViewSettingRow = () => {
|
||||
const { appSettings, updateSettings } = useAppSettingHelper();
|
||||
|
||||
@@ -204,11 +148,7 @@ const BlocksuiteFeatureFlagSettings = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const ExperimentalFeaturesMain = ({
|
||||
workspaceMetadata,
|
||||
}: {
|
||||
workspaceMetadata: WorkspaceMetadata;
|
||||
}) => {
|
||||
const ExperimentalFeaturesMain = () => {
|
||||
const t = useAFFiNEI18N();
|
||||
|
||||
return (
|
||||
@@ -219,7 +159,6 @@ const ExperimentalFeaturesMain = ({
|
||||
]()}
|
||||
/>
|
||||
<div className={styles.settingsContainer}>
|
||||
<CopilotSettingRow workspaceMetadata={workspaceMetadata} />
|
||||
<SplitViewSettingRow />
|
||||
<BlocksuiteFeatureFlagSettings />
|
||||
</div>
|
||||
@@ -233,11 +172,7 @@ const experimentalFeaturesDisclaimerAtom = atomWithStorage(
|
||||
false
|
||||
);
|
||||
|
||||
export const ExperimentalFeatures = ({
|
||||
workspaceMetadata,
|
||||
}: {
|
||||
workspaceMetadata: WorkspaceMetadata;
|
||||
}) => {
|
||||
export const ExperimentalFeatures = () => {
|
||||
const [enabled, setEnabled] = useAtom(experimentalFeaturesDisclaimerAtom);
|
||||
const handleConfirm = useAsyncCallback(async () => {
|
||||
setEnabled(true);
|
||||
@@ -247,7 +182,7 @@ export const ExperimentalFeatures = ({
|
||||
} else {
|
||||
return (
|
||||
<Suspense fallback={<Loading />}>
|
||||
<ExperimentalFeaturesMain workspaceMetadata={workspaceMetadata} />
|
||||
<ExperimentalFeaturesMain />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export const WorkspaceSetting = ({
|
||||
/>
|
||||
);
|
||||
case 'experimental-features':
|
||||
return <ExperimentalFeatures workspaceMetadata={workspaceMetadata} />;
|
||||
return <ExperimentalFeatures />;
|
||||
case 'properties':
|
||||
return (
|
||||
<WorkspaceSettingProperties workspaceMetadata={workspaceMetadata} />
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { useWorkspaceEnabledFeatures } from '@affine/core/hooks/use-workspace-features';
|
||||
import { FeatureType } from '@affine/graphql';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { AiIcon } from '@blocksuite/icons';
|
||||
import { ChatPanel } from '@blocksuite/presets';
|
||||
import { useService, Workspace } from '@toeverything/infra';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import type { SidebarTab, SidebarTabProps } from '../sidebar-tab';
|
||||
@@ -11,21 +8,14 @@ import * as styles from './chat.css';
|
||||
|
||||
// A wrapper for CopilotPanel
|
||||
const EditorChatPanel = ({ editor }: SidebarTabProps) => {
|
||||
const workspace = useService(Workspace);
|
||||
const copilotEnabled = useWorkspaceEnabledFeatures(workspace.meta).includes(
|
||||
FeatureType.Copilot
|
||||
);
|
||||
const chatPanelRef = useRef<ChatPanel | null>(null);
|
||||
|
||||
const onRefChange = useCallback(
|
||||
(container: HTMLDivElement | null) => {
|
||||
if (container && copilotEnabled) {
|
||||
assertExists(chatPanelRef.current, 'chat panel should be initialized');
|
||||
container.append(chatPanelRef.current);
|
||||
}
|
||||
},
|
||||
[copilotEnabled]
|
||||
);
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
if (container) {
|
||||
assertExists(chatPanelRef.current, 'chat panel should be initialized');
|
||||
container.append(chatPanelRef.current);
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!editor) {
|
||||
return;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { IconButton } from '@affine/component';
|
||||
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
|
||||
import { useWorkspaceEnabledFeatures } from '@affine/core/hooks/use-workspace-features';
|
||||
import { FeatureType } from '@affine/graphql';
|
||||
import { Doc, useService, Workspace } from '@toeverything/infra';
|
||||
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import type { SidebarTab, SidebarTabName } from '../entities/sidebar-tab';
|
||||
import * as styles from './header-switcher.css';
|
||||
@@ -24,22 +22,10 @@ export const MultiTabSidebarHeaderSwitcher = ({
|
||||
}: MultiTabSidebarHeaderSwitcherProps) => {
|
||||
const workspace = useService(Workspace);
|
||||
const doc = useService(Doc);
|
||||
const copilotEnabled = useWorkspaceEnabledFeatures(workspace.meta).includes(
|
||||
FeatureType.Copilot
|
||||
);
|
||||
|
||||
const { isJournal } = useJournalInfoHelper(workspace.docCollection, doc.id);
|
||||
|
||||
const exts = useMemo(
|
||||
() =>
|
||||
tabs.filter(ext => {
|
||||
if (ext.name === 'chat' && !copilotEnabled) return false;
|
||||
return true;
|
||||
}),
|
||||
[copilotEnabled, tabs]
|
||||
);
|
||||
|
||||
const activeExtension = exts.find(ext => ext.name === activeTabName);
|
||||
const activeExtension = tabs.find(ext => ext.name === activeTabName);
|
||||
|
||||
// if journal is active, set selected to journal
|
||||
useEffect(() => {
|
||||
@@ -50,14 +36,14 @@ export const MultiTabSidebarHeaderSwitcher = ({
|
||||
|
||||
const vars = assignInlineVars({
|
||||
[styles.activeIdx]: String(
|
||||
exts.findIndex(ext => ext.name === activeExtension?.name) ?? 0
|
||||
tabs.findIndex(ext => ext.name === activeExtension?.name) ?? 0
|
||||
),
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={styles.switchRootWrapper}>
|
||||
<div className={styles.switchRoot} style={vars}>
|
||||
{exts.map(extension => {
|
||||
{tabs.map(extension => {
|
||||
return (
|
||||
<IconButton
|
||||
onClick={() => setActiveTabName(extension.name)}
|
||||
|
||||
Reference in New Issue
Block a user