mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 08:38:34 +00:00
refactor(core): ai input images display & max images count (#12395)
### TL;DR * refactor: use horizontal scrolling to display images * refactor: change max images to 9 * test: add test cases for validating the maximum number of uploadable images > CLOSE AI-6  <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a notification to inform users when attempting to upload more images than allowed in the AI chat input. - **Bug Fixes** - Prevented uploading more than 9 images at once in the AI chat input. - **Style** - Improved image preview grid layout to display images in a single horizontally scrollable row. - **Tests** - Added an end-to-end test to verify that an error message appears when too many images are uploaded. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -236,10 +236,9 @@ export class ChatPanelUtils {
|
||||
await this.makeChat(page, text);
|
||||
}
|
||||
|
||||
public static async chatWithImages(
|
||||
public static async uploadImages(
|
||||
page: Page,
|
||||
images: { name: string; mimeType: string; buffer: Buffer }[],
|
||||
text: string
|
||||
images: { name: string; mimeType: string; buffer: Buffer }[]
|
||||
) {
|
||||
await page.evaluate(() => {
|
||||
delete window.showOpenFilePicker;
|
||||
@@ -251,6 +250,14 @@ export class ChatPanelUtils {
|
||||
|
||||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(images);
|
||||
}
|
||||
|
||||
public static async chatWithImages(
|
||||
page: Page,
|
||||
images: { name: string; mimeType: string; buffer: Buffer }[],
|
||||
text: string
|
||||
) {
|
||||
await this.uploadImages(page, images);
|
||||
|
||||
await page.waitForSelector('ai-chat-input img');
|
||||
await this.makeChat(page, text);
|
||||
|
||||
Reference in New Issue
Block a user