From afb3907efa0d19f5ab095df8e01afbd58476c82f Mon Sep 17 00:00:00 2001 From: Wu Yue Date: Tue, 8 Jul 2025 15:48:38 +0800 Subject: [PATCH] fix(core): show actions only if docId equals session.docId (#13080) Close [AI-240](https://linear.app/affine-design/issue/AI-240) ## Summary by CodeRabbit * **New Features** * Improved logic for displaying actions in AI chat content, ensuring actions are shown only when appropriate based on session and document context. --- .../components/ai-chat-content/ai-chat-content.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts index d9a2a21da..67832613b 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts @@ -197,6 +197,17 @@ export class AIChatContent extends SignalWatcher( }); } + get showActions() { + if (this.docId) { + if (!this.session) { + return true; + } + return this.session.docId === this.docId; + } else { + return false; + } + } + private readonly updateHistory = async () => { const currentRequest = ++this.updateHistoryCounter; if (!AIProvider.histories) { @@ -208,7 +219,7 @@ export class AIChatContent extends SignalWatcher( sessionId ? AIProvider.histories.chats(this.workspaceId, sessionId) : Promise.resolve([]), - this.docId + this.docId && this.showActions ? AIProvider.histories.actions(this.workspaceId, this.docId) : Promise.resolve([]), ]);