From e82c9d2ddc2290d625b0ad5cb7b5cd34ae7cda2e Mon Sep 17 00:00:00 2001 From: L-Sun Date: Tue, 10 Jun 2025 02:14:01 +0000 Subject: [PATCH] fix(editor): add title to edgeless page block ai context (#12763) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close [BS-3590](https://linear.app/affine-design/issue/BS-3590/page-block-的标题没有被作为上下文输入) --- .../core/src/blocksuite/ai/actions/edgeless-handler.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts b/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts index 8c60bdc7d2..a4e3c22f6e 100644 --- a/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts +++ b/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts @@ -130,6 +130,12 @@ export async function getContentFromSelected( } ); + const hasPageBlock = notes.find(note => note.isPageBlock()); + const title = + hasPageBlock && host.std.store.meta?.title + ? `# ${host.std.store.meta?.title}\n` + : ''; + const noteContent = await getContentFromHubBlockModel(host, notes); const edgelessTextContent = await getContentFromHubBlockModel( host, @@ -140,7 +146,7 @@ export async function getContentFromSelected( embedSyncedDocs ); - return `${noteContent.join('\n')} + return `${title}${noteContent.join('\n')} ${edgelessTextContent.join('\n')} ${syncedDocsContent} ${texts.map(text => text.text.toString()).join('\n')}