From 01e84580757e39f7eeb0feeb4b5b26e4af726cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=B7=E5=B8=83=E5=8A=B3=E5=A4=96=20=C2=B7=20=E8=B4=BE?= =?UTF-8?q?=E8=B4=B5?= <472285740@qq.com> Date: Mon, 11 Aug 2025 17:42:18 +0800 Subject: [PATCH] refactor(core): add selected chip synchronously (#13469) > CLOSE PD-2698 ## Summary by CodeRabbit - **Refactor** - Optimized context chip handling in the AI chat composer to process additions concurrently. - Improves responsiveness when adding multiple documents or attachments as context, reducing wait times and making the composing experience smoother. - No changes to visible functionality; users should notice faster updates when selecting several items at once. --- .../ai-chat-composer/ai-chat-composer.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts index da6d56dd7..4fa2b156e 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts @@ -427,9 +427,9 @@ export class AIChatComposer extends SignalWatcher( html, state: 'finished', }; - await this.addChip(chip, true); - await Promise.all( - docs.map(docId => + await Promise.all([ + this.addChip(chip, true), + ...docs.map(docId => this.addChip( { docId, @@ -437,10 +437,8 @@ export class AIChatComposer extends SignalWatcher( }, true ) - ) - ); - await Promise.all( - attachments.map(attachment => + ), + ...attachments.map(attachment => this.addChip( { sourceId: attachment.sourceId, @@ -449,8 +447,8 @@ export class AIChatComposer extends SignalWatcher( }, true ) - ) - ); + ), + ]); }; private readonly removeSelectedContextChip = async () => {