From 3a524b06dc3b2abc877e4be808607c89fe2ec4e7 Mon Sep 17 00:00:00 2001 From: YuanShiJiLoong <2450829984@qq.com> Date: Sun, 22 Feb 2026 20:40:39 +0900 Subject: [PATCH] fix: pass user message as RAG query text, fix Sidebar rename input controlled warning --- app/components/AiSidebar.js | 4 ++-- app/components/Sidebar.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/AiSidebar.js b/app/components/AiSidebar.js index 509ca16..3f6567d 100644 --- a/app/components/AiSidebar.js +++ b/app/components/AiSidebar.js @@ -197,7 +197,7 @@ export default function AiSidebar({ onInsertText }) { const { apiConfig } = getProjectSettings(); const apiEndpoint = apiConfig?.provider === 'gemini-native' ? '/api/ai/gemini' : '/api/ai'; - const context = await buildContext(activeChapterId, '', contextSelection.size > 0 ? contextSelection : null); + const context = await buildContext(activeChapterId, text, contextSelection.size > 0 ? contextSelection : null); const systemPrompt = compileSystemPrompt(context, 'chat'); const historyForApi = selectedHistory.map(m => `${m.role === 'user' ? t('aiSidebar.roleYou') : t('aiSidebar.roleAi')}: ${m.content}`).join('\n'); const userPrompt = historyForApi ? `${historyForApi}\n${t('aiSidebar.roleYou')}: ${text}` : text; @@ -261,7 +261,7 @@ export default function AiSidebar({ onInsertText }) { const { apiConfig } = getProjectSettings(); const apiEndpoint = apiConfig?.provider === 'gemini-native' ? '/api/ai/gemini' : '/api/ai'; - const context = await buildContext(activeChapterId, '', contextSelection.size > 0 ? contextSelection : null); + const context = await buildContext(activeChapterId, userMsg.content, contextSelection.size > 0 ? contextSelection : null); const systemPrompt = compileSystemPrompt(context, 'chat'); const historyForApi = priorHistory .filter(m => m.role === 'user' || m.role === 'assistant') diff --git a/app/components/Sidebar.js b/app/components/Sidebar.js index 55cd9ae..1069d5f 100644 --- a/app/components/Sidebar.js +++ b/app/components/Sidebar.js @@ -129,7 +129,7 @@ export default function Sidebar() { setRenameTitle(e.target.value)} onBlur={() => handleRename(ch.id)} onKeyDown={e => e.key === 'Enter' && handleRename(ch.id)}