fix(core): missing hide edgeless copilot panel logic (#13445)

Close [AI-409](https://linear.app/affine-design/issue/AI-409)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Wu Yue
2025-08-08 16:37:49 +08:00
committed by GitHub
parent 5fd7dfc8aa
commit 4005f40b16
2 changed files with 9 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ import type {
} from '../components/ai-item/types'; } from '../components/ai-item/types';
import { AIProvider } from '../provider'; import { AIProvider } from '../provider';
import { getAIPanelWidget } from '../utils/ai-widgets'; import { getAIPanelWidget } from '../utils/ai-widgets';
import { getEdgelessCopilotWidget } from '../utils/get-edgeless-copilot-widget';
import { import {
AIImageIconWithAnimation, AIImageIconWithAnimation,
AIPenIconWithAnimation, AIPenIconWithAnimation,
@@ -384,10 +385,12 @@ const OthersAIGroup: AIItemGroupConfig = {
icon: CommentIcon(), icon: CommentIcon(),
handler: host => { handler: host => {
const panel = getAIPanelWidget(host); const panel = getAIPanelWidget(host);
const edgelessCopilot = getEdgelessCopilotWidget(host);
AIProvider.slots.requestOpenWithChat.next({ AIProvider.slots.requestOpenWithChat.next({
host, host,
autoSelect: true, autoSelect: true,
}); });
edgelessCopilot.hideCopilotPanel();
panel.hide(); panel.hide();
}, },
}, },

View File

@@ -51,7 +51,10 @@ import {
import type { AIItemGroupConfig } from '../../components/ai-item/types'; import type { AIItemGroupConfig } from '../../components/ai-item/types';
import { AIProvider } from '../../provider'; import { AIProvider } from '../../provider';
import { getAIPanelWidget } from '../../utils/ai-widgets'; import { getAIPanelWidget } from '../../utils/ai-widgets';
import { mindMapToMarkdown } from '../../utils/edgeless'; import {
getEdgelessCopilotWidget,
mindMapToMarkdown,
} from '../../utils/edgeless';
import { extractSelectedContent } from '../../utils/extract'; import { extractSelectedContent } from '../../utils/extract';
import { canvasToBlob, randomSeed } from '../../utils/image'; import { canvasToBlob, randomSeed } from '../../utils/image';
import { import {
@@ -115,6 +118,7 @@ const othersGroup: AIItemGroupConfig = {
showWhen: () => true, showWhen: () => true,
handler: host => { handler: host => {
const panel = getAIPanelWidget(host); const panel = getAIPanelWidget(host);
const edgelessCopilot = getEdgelessCopilotWidget(host);
extractSelectedContent(host) extractSelectedContent(host)
.then(context => { .then(context => {
AIProvider.slots.requestOpenWithChat.next({ AIProvider.slots.requestOpenWithChat.next({
@@ -125,6 +129,7 @@ const othersGroup: AIItemGroupConfig = {
}); });
}) })
.catch(console.error); .catch(console.error);
edgelessCopilot.hideCopilotPanel();
panel.hide(); panel.hide();
}, },
}, },