feat(core): add with your docs label to ai answer (#10124)
Fix issue [BS-2425](https://linear.app/affine-design/issue/BS-2425). 
This commit is contained in:
@@ -71,6 +71,12 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-info {
|
||||||
|
color: var(--affine-placeholder-color);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-container {
|
.avatar-container {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
@@ -370,6 +376,12 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
|
|
||||||
renderAvatar(item: ChatItem) {
|
renderAvatar(item: ChatItem) {
|
||||||
const isUser = 'role' in item && item.role === 'user';
|
const isUser = 'role' in item && item.role === 'user';
|
||||||
|
const isAssistant = 'role' in item && item.role === 'assistant';
|
||||||
|
const isWithDocs =
|
||||||
|
isAssistant &&
|
||||||
|
item.content &&
|
||||||
|
item.content.includes('[^') &&
|
||||||
|
/\[\^\d+\]:{"type":"doc","docId":"[^"]+"}/.test(item.content);
|
||||||
|
|
||||||
return html`<div class="user-info">
|
return html`<div class="user-info">
|
||||||
${isUser
|
${isUser
|
||||||
@@ -380,6 +392,9 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
</div>`
|
</div>`
|
||||||
: AffineAvatarIcon}
|
: AffineAvatarIcon}
|
||||||
${isUser ? 'You' : 'AFFiNE AI'}
|
${isUser ? 'You' : 'AFFiNE AI'}
|
||||||
|
${isWithDocs
|
||||||
|
? html`<span class="message-info">with your docs</span>`
|
||||||
|
: nothing}
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -865,7 +865,7 @@ test.describe('chat with doc', () => {
|
|||||||
name: 'You',
|
name: 'You',
|
||||||
content: 'What is AFFiNE AI?',
|
content: 'What is AFFiNE AI?',
|
||||||
});
|
});
|
||||||
expect(history[1].name).toBe('AFFiNE AI');
|
expect(history[1].name).toBe(`AFFiNE AI\nwith your docs`);
|
||||||
expect(
|
expect(
|
||||||
await page.locator('chat-panel affine-footnote-node').count()
|
await page.locator('chat-panel affine-footnote-node').count()
|
||||||
).toBeGreaterThan(0);
|
).toBeGreaterThan(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user