fix(core): remove candidate doc chip suggestions (#10327)
Fix issue [AF-2247](https://linear.app/affine-design/issue/AF-2247).
This commit is contained in:
@@ -167,17 +167,8 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _updateChips = async () => {
|
private readonly _updateChips = async () => {
|
||||||
const candidateChip: DocChip = {
|
|
||||||
docId: this.doc.id,
|
|
||||||
state: 'candidate',
|
|
||||||
};
|
|
||||||
|
|
||||||
// context not initialized, show candidate chip
|
// context not initialized, show candidate chip
|
||||||
if (!this._chatSessionId || !this._chatContextId) {
|
if (!this._chatSessionId || !this._chatContextId) {
|
||||||
this.chatContextValue = {
|
|
||||||
...this.chatContextValue,
|
|
||||||
chips: [candidateChip],
|
|
||||||
};
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +203,7 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
|||||||
});
|
});
|
||||||
this.chatContextValue = {
|
this.chatContextValue = {
|
||||||
...this.chatContextValue,
|
...this.chatContextValue,
|
||||||
chips: chips.length === 0 ? [candidateChip] : chips,
|
chips,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -111,10 +111,10 @@ const collectChat = async (page: Page) => {
|
|||||||
}
|
}
|
||||||
// wait ai response
|
// wait ai response
|
||||||
await page.waitForSelector('.chat-panel-messages .message chat-copy-more');
|
await page.waitForSelector('.chat-panel-messages .message chat-copy-more');
|
||||||
await page.waitForTimeout(ONE_SECOND);
|
await page.waitForTimeout(200);
|
||||||
const lastMessage = await chatPanel.$$('.message').then(m => m[m.length - 1]);
|
const lastMessage = await chatPanel.$$('.message').then(m => m[m.length - 1]);
|
||||||
await lastMessage.waitForSelector('chat-copy-more');
|
await lastMessage.waitForSelector('chat-copy-more');
|
||||||
await page.waitForTimeout(ONE_SECOND);
|
await page.waitForTimeout(200);
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
Array.from(await chatPanel.$$('.message')).map(async m => ({
|
Array.from(await chatPanel.$$('.message')).map(async m => ({
|
||||||
name: await m.$('.user-info').then(i => i?.innerText()),
|
name: await m.$('.user-info').then(i => i?.innerText()),
|
||||||
@@ -906,8 +906,19 @@ test.describe('chat with doc', () => {
|
|||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
|
|
||||||
await openChat(page);
|
await openChat(page);
|
||||||
const chipTitle = await page.getByTestId('chat-panel-chip-title');
|
|
||||||
|
const addButton = await page.locator('chat-panel-chips .add-button');
|
||||||
|
await addButton.click();
|
||||||
|
const docItem = await page.locator('chat-panel-add-popover icon-button', {
|
||||||
|
hasText: 'Untitled',
|
||||||
|
});
|
||||||
|
await docItem.click();
|
||||||
|
await page.waitForTimeout(200);
|
||||||
|
let chipTitle = await page.getByTestId('chat-panel-chip-title');
|
||||||
expect(await chipTitle.textContent()).toBe('Untitled');
|
expect(await chipTitle.textContent()).toBe('Untitled');
|
||||||
|
let chip = await page.getByTestId('chat-panel-chip');
|
||||||
|
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
|
||||||
|
expect(await chip.getAttribute('data-state')).toBe('success');
|
||||||
|
|
||||||
const editorTitle = await page.locator('doc-title .inline-editor').nth(0);
|
const editorTitle = await page.locator('doc-title .inline-editor').nth(0);
|
||||||
await editorTitle.pressSequentially('AFFiNE AI', {
|
await editorTitle.pressSequentially('AFFiNE AI', {
|
||||||
@@ -928,11 +939,6 @@ test.describe('chat with doc', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(await chipTitle.textContent()).toBe('AFFiNE AI');
|
expect(await chipTitle.textContent()).toBe('AFFiNE AI');
|
||||||
const chip = await page.getByTestId('chat-panel-chip');
|
|
||||||
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
|
|
||||||
expect(await chip.getAttribute('data-state')).toBe('candidate');
|
|
||||||
await chip.click();
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
|
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
|
||||||
expect(await chip.getAttribute('data-state')).toBe('success');
|
expect(await chip.getAttribute('data-state')).toBe('success');
|
||||||
|
|
||||||
@@ -951,7 +957,7 @@ test.describe('chat with doc', () => {
|
|||||||
expect((await collectChat(page)).length).toBe(0);
|
expect((await collectChat(page)).length).toBe(0);
|
||||||
|
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(200);
|
||||||
await openChat(page);
|
await openChat(page);
|
||||||
expect(await chipTitle.textContent()).toBe('AFFiNE AI');
|
expect(await chipTitle.textContent()).toBe('AFFiNE AI');
|
||||||
const chip2 = await page.getByTestId('chat-panel-chip');
|
const chip2 = await page.getByTestId('chat-panel-chip');
|
||||||
|
|||||||
Reference in New Issue
Block a user