From 4005f40b16f43a59090252484e19b6814d9fe3af Mon Sep 17 00:00:00 2001 From: Wu Yue Date: Fri, 8 Aug 2025 16:37:49 +0800 Subject: [PATCH] fix(core): missing hide edgeless copilot panel logic (#13445) Close [AI-409](https://linear.app/affine-design/issue/AI-409) ## Summary by CodeRabbit * **Bug Fixes** * Improved the behavior when continuing in AI Chat by ensuring the copilot panel is properly hidden before switching panels for a smoother user experience. --- packages/frontend/core/src/blocksuite/ai/_common/config.ts | 3 +++ .../src/blocksuite/ai/entries/edgeless/actions-config.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/blocksuite/ai/_common/config.ts b/packages/frontend/core/src/blocksuite/ai/_common/config.ts index b17593a2f..7de82072b 100644 --- a/packages/frontend/core/src/blocksuite/ai/_common/config.ts +++ b/packages/frontend/core/src/blocksuite/ai/_common/config.ts @@ -38,6 +38,7 @@ import type { } from '../components/ai-item/types'; import { AIProvider } from '../provider'; import { getAIPanelWidget } from '../utils/ai-widgets'; +import { getEdgelessCopilotWidget } from '../utils/get-edgeless-copilot-widget'; import { AIImageIconWithAnimation, AIPenIconWithAnimation, @@ -384,10 +385,12 @@ const OthersAIGroup: AIItemGroupConfig = { icon: CommentIcon(), handler: host => { const panel = getAIPanelWidget(host); + const edgelessCopilot = getEdgelessCopilotWidget(host); AIProvider.slots.requestOpenWithChat.next({ host, autoSelect: true, }); + edgelessCopilot.hideCopilotPanel(); panel.hide(); }, }, diff --git a/packages/frontend/core/src/blocksuite/ai/entries/edgeless/actions-config.ts b/packages/frontend/core/src/blocksuite/ai/entries/edgeless/actions-config.ts index ae68393e9..1962b6bf1 100644 --- a/packages/frontend/core/src/blocksuite/ai/entries/edgeless/actions-config.ts +++ b/packages/frontend/core/src/blocksuite/ai/entries/edgeless/actions-config.ts @@ -51,7 +51,10 @@ import { import type { AIItemGroupConfig } from '../../components/ai-item/types'; import { AIProvider } from '../../provider'; import { getAIPanelWidget } from '../../utils/ai-widgets'; -import { mindMapToMarkdown } from '../../utils/edgeless'; +import { + getEdgelessCopilotWidget, + mindMapToMarkdown, +} from '../../utils/edgeless'; import { extractSelectedContent } from '../../utils/extract'; import { canvasToBlob, randomSeed } from '../../utils/image'; import { @@ -115,6 +118,7 @@ const othersGroup: AIItemGroupConfig = { showWhen: () => true, handler: host => { const panel = getAIPanelWidget(host); + const edgelessCopilot = getEdgelessCopilotWidget(host); extractSelectedContent(host) .then(context => { AIProvider.slots.requestOpenWithChat.next({ @@ -125,6 +129,7 @@ const othersGroup: AIItemGroupConfig = { }); }) .catch(console.error); + edgelessCopilot.hideCopilotPanel(); panel.hide(); }, },