fix(core): in edgeless mode, an error occurs when asking AI questions without selecting any content (#12437)

### TL;DR

fix: in edgeless mode, an error occurs when asking AI questions without selecting any content

> CLOSE AI-133

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

- **New Features**
  - Added support for asking AI input in edgeless mode when no content is selected.
  - Enhanced AI panel behavior with improved input handling and chat message sending in edgeless mode.
- **Bug Fixes**
  - Improved handling of AI chat input visibility and context extraction in edgeless mode.
- **Tests**
  - Introduced new end-to-end tests to verify chat interactions with AI in edgeless mode.
  - Centralized editor content removal logic in test utilities for better maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
yoyoyohamapi
2025-05-23 06:18:28 +00:00
parent e2e00688a9
commit fd3a2756f8
7 changed files with 83 additions and 22 deletions

View File

@@ -484,4 +484,31 @@ test.describe('AIBasic/Chat', () => {
},
]);
});
test('should support chat with ask ai input in edgeless mode when nothing selected', async ({
loggedInPage: page,
utils,
}) => {
await utils.chatPanel.closeChatPanel(page);
await utils.editor.switchToEdgelessMode(page);
await utils.editor.removeAll(page);
await page.mouse.move(300, 300);
await page.mouse.down({ button: 'right' });
await page.mouse.move(350, 350);
await page.mouse.up({ button: 'right' });
await page.keyboard.type('Who are you?');
await page.keyboard.press('Enter');
await utils.chatPanel.waitForHistory(page, [
{
role: 'user',
content: 'Who are you?',
},
{
role: 'assistant',
status: 'success',
},
]);
});
});

View File

@@ -386,14 +386,18 @@ export class EditorUtils {
);
}
public static async removeAll(page: Page) {
await selectAllByKeyboard(page);
await page.keyboard.press('Delete');
}
public static async askAIWithEdgeless(
page: Page,
createBlock: () => Promise<void>,
afterSelected?: () => Promise<void>
) {
await this.switchToEdgelessMode(page);
await selectAllByKeyboard(page);
await page.keyboard.press('Delete');
await this.removeAll(page);
await createBlock();
await pressEscape(page, 5);
await selectAllByKeyboard(page);