refactor(core): add selected chip synchronously (#13469)

> CLOSE PD-2698

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

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
德布劳外 · 贾贵
2025-08-11 17:42:18 +08:00
committed by GitHub
parent 0d9f6770bf
commit 01e8458075
@@ -427,9 +427,9 @@ export class AIChatComposer extends SignalWatcher(
html, html,
state: 'finished', state: 'finished',
}; };
await this.addChip(chip, true); await Promise.all([
await Promise.all( this.addChip(chip, true),
docs.map(docId => ...docs.map(docId =>
this.addChip( this.addChip(
{ {
docId, docId,
@@ -437,10 +437,8 @@ export class AIChatComposer extends SignalWatcher(
}, },
true true
) )
) ),
); ...attachments.map(attachment =>
await Promise.all(
attachments.map(attachment =>
this.addChip( this.addChip(
{ {
sourceId: attachment.sourceId, sourceId: attachment.sourceId,
@@ -449,8 +447,8 @@ export class AIChatComposer extends SignalWatcher(
}, },
true true
) )
) ),
); ]);
}; };
private readonly removeSelectedContextChip = async () => { private readonly removeSelectedContextChip = async () => {