diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/message/assistant.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/message/assistant.ts index 7d28d69db..4db241869 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/message/assistant.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/message/assistant.ts @@ -18,6 +18,7 @@ import { EdgelessEditorActions, PageEditorActions, } from '../../_common/chat-actions-handle'; +import type { DocDisplayConfig } from '../../components/ai-chat-chips'; import { type ChatMessage, type ChatStatus, @@ -82,6 +83,9 @@ export class ChatMessageAssistant extends WithDisposable(ShadowlessElement) { @property({ attribute: false }) accessor independentMode: boolean | undefined; + @property({ attribute: false }) + accessor docDisplayService!: DocDisplayConfig; + get state() { const { isLast, status } = this; return isLast @@ -141,6 +145,7 @@ export class ChatMessageAssistant extends WithDisposable(ShadowlessElement) { .affineFeatureFlagService=${this.affineFeatureFlagService} .notificationService=${this.notificationService} .theme=${this.affineThemeService.appTheme.themeSignal} + .docDisplayService=${this.docDisplayService} >`; } diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts index 4200912b0..012f4a9ea 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-content/ai-chat-content.ts @@ -417,6 +417,7 @@ export class AIChatContent extends SignalWatcher( .width=${this.width} .independentMode=${this.independentMode} .messages=${this.messages} + .docDisplayService=${this.docDisplayConfig} > | undefined; + @property({ attribute: false }) + accessor docDisplayService!: DocDisplayConfig; + @query('.chat-panel-messages-container') accessor messagesContainer: HTMLDivElement | null = null; @@ -328,6 +332,7 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) { .retry=${() => this.retry()} .width=${this.width} .independentMode=${this.independentMode} + .docDisplayService=${this.docDisplayService} >`; } else if (isChatAction(item) && this.host) { return html``; case 'doc_keyword_search': return html` | undefined; + @property({ attribute: false }) + accessor docDisplayService!: DocDisplayConfig; + renderToolCall() { return html` parseResultContent(result.content)) + .map(result => ({ + ...parseResultContent(result.content), + title: this.docDisplayService.getTitle(result.docId), + })) .filter(Boolean)} >`; }