mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat(core): remove ai from experimental features (#6529)
This commit is contained in:
@@ -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