fix(core): copy & paste ai message failed (#12655)

### TL;DR
* fix: ai message copy bug
  * Select a section of content in the Page
  * Choose the user's question from the AI chat conversation history and copy it
  * The copied (pasted) content will be the selected section from the Page

* fix: ai message paste bug
  * Select a section of content in the Page
  * Choose the user's question from the AI chat conversation history and copy it
  * Paste it into the AI Input, and the content will be pasted back into the original Page text

> CLOSE AF-2683

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

- **Bug Fixes**
  - Improved handling of copy and paste events in chat components to prevent unintended interactions with surrounding elements.
  - Enhanced test stability by adding error handling during embedding progress checks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
yoyoyohamapi
2025-06-03 06:09:44 +00:00
parent 57208a3de4
commit a88dcc0951
2 changed files with 7 additions and 1 deletions

View File

@@ -40,9 +40,14 @@ export class ChatContentPureText extends ShadowlessElement {
@property({ attribute: 'data-testid', reflect: true })
accessor testId = 'chat-content-pure-text';
stopPropagation(event: Event) {
event.stopPropagation();
}
protected override render() {
return this.text.length > 0
? html`<div class="chat-content-pure-text">${this.text}</div>`
? // prettier-ignore
html`<div class="chat-content-pure-text" @copy=${this.stopPropagation}>${this.text}</div>`
: nothing;
}
}

View File

@@ -492,6 +492,7 @@ export class AIChatInput extends SignalWatcher(
};
private readonly _handlePaste = (event: ClipboardEvent) => {
event.stopPropagation();
const items = event.clipboardData?.items;
if (!items) return;