From 4a67c84c73a29bf607f2a9d14683bd4bc526582e Mon Sep 17 00:00:00 2001 From: pengx17 Date: Fri, 12 Apr 2024 03:58:43 +0000 Subject: [PATCH] fix(core): chat panel display on cont in chat (#6527) --- .../pages/workspace/detail-page/detail-page.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx index 89d79a6907..d4fbd18d5b 100644 --- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx +++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx @@ -11,7 +11,7 @@ import { ImageService, } from '@blocksuite/blocks'; import { DisposableGroup } from '@blocksuite/global/utils'; -import type { AffineEditorContainer } from '@blocksuite/presets'; +import { type AffineEditorContainer, AIProvider } from '@blocksuite/presets'; import type { Doc as BlockSuiteDoc } from '@blocksuite/store'; import { Doc, @@ -56,7 +56,10 @@ import { MultiTabSidebarHeaderSwitcher, sidebarTabs, } from '../../../modules/multi-tab-sidebar'; -import { RightSidebarViewIsland } from '../../../modules/right-sidebar'; +import { + RightSidebar, + RightSidebarViewIsland, +} from '../../../modules/right-sidebar'; import { useIsActiveView, ViewBodyIsland, @@ -71,6 +74,7 @@ const RIGHT_SIDEBAR_TABS_ACTIVE_KEY = 'app:settings:rightsidebar:tabs:active'; const DetailPageImpl = memo(function DetailPageImpl() { const globalState = useService(GlobalState); + const rightSidebar = useService(RightSidebar); const activeTabName = useLiveData( LiveData.from( globalState.watch(RIGHT_SIDEBAR_TABS_ACTIVE_KEY), @@ -102,6 +106,15 @@ const DetailPageImpl = memo(function DetailPageImpl() { } }, [editor, isActiveView, setActiveBlockSuiteEditor]); + useEffect(() => { + AIProvider.slots.requestContinueInChat.on(() => { + rightSidebar.open(); + if (activeTabName !== 'chat') { + setActiveTabName('chat'); + } + }); + }, [activeTabName, rightSidebar, setActiveTabName]); + const pageMeta = useBlockSuiteDocMeta(docCollection).find( meta => meta.id === page.id );