fix: pass user message as RAG query text, fix Sidebar rename input controlled warning

This commit is contained in:
YuanShiJiLoong committed 2026-02-22 20:40:39 +09:00
1 parent 6617672e4a
commit 3a524b06dc
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -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')
+1 -1
View File
@@ -129,7 +129,7 @@ export default function Sidebar() {
<input
className="modal-input"
style={{ margin: 0, padding: '4px 8px', fontSize: '13px' }}
value={renameTitle}
value={renameTitle || ''}
onChange={e => setRenameTitle(e.target.value)}
onBlur={() => handleRename(ch.id)}
onKeyDown={e => e.key === 'Enter' && handleRename(ch.id)}