Ensure prompt text presence before processing

This commit is contained in:
2026-04-16 21:31:14 +02:00
parent 2e116b8701
commit 603db28967

View File

@@ -573,8 +573,9 @@ async function regenerateFromIndex(index, overrideUserText = null) {
try { try {
const selectedLibrary = getChatLibraryForSession(sessionId) const selectedLibrary = getChatLibraryForSession(sessionId)
const promptText = overrideUserText != null ? overrideUserText : (msgs[lastUserIdx]?.content || '') const promptText = overrideUserText != null ? overrideUserText : (msgs[lastUserIdx]?.content || '')
const hasPromptText = Boolean((promptText || '').trim())
if (selectedLibrary?.states?.is_indexed) { if (hasPromptText && selectedLibrary?.states?.is_indexed) {
try { try {
const localContext = await fetchLocalLibraryContext(selectedLibrary.slug, promptText, requestController.signal) const localContext = await fetchLocalLibraryContext(selectedLibrary.slug, promptText, requestController.signal)
if (localContext.contextBlock) { if (localContext.contextBlock) {
@@ -589,7 +590,7 @@ async function regenerateFromIndex(index, overrideUserText = null) {
} }
} }
if (webSearchEnabled) { if (hasPromptText && webSearchEnabled) {
try { try {
const historyForSearch = msgs const historyForSearch = msgs
.slice(Math.max(0, lastUserIdx - 7), lastUserIdx + 1) .slice(Math.max(0, lastUserIdx - 7), lastUserIdx + 1)
@@ -625,7 +626,7 @@ async function regenerateFromIndex(index, overrideUserText = null) {
} }
citationSources = [...new Set(citationSources)] citationSources = [...new Set(citationSources)]
if (contextBlocks.length > 0) { if (hasPromptText && contextBlocks.length > 0) {
enrichedPrompt = `${promptText}\n\n${contextBlocks.join('\n\n')}` enrichedPrompt = `${promptText}\n\n${contextBlocks.join('\n\n')}`
} else { } else {
enrichedPrompt = null enrichedPrompt = null