From 4f4f35007e415162807be3f5ecf753a33cd2e392 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 18 May 2026 17:44:01 -0400 Subject: [PATCH] Fixing conversation history and SearXNG info block --- ollama_answers.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ollama_answers.py b/ollama_answers.py index 806eb42..ae0c4f2 100644 --- a/ollama_answers.py +++ b/ollama_answers.py @@ -843,6 +843,20 @@ INTERACTIVE_JS = r''' ''' FRONTEND_JS_TEMPLATE = r""" +// Hide SearXNG's native answers div to prevent duplicate answer display +(function() { + const hideNative = () => { + const answersDiv = document.getElementById('answers'); + if (answersDiv) { + answersDiv.style.display = 'none'; + } + }; + hideNative(); + // Also run after DOM settles in case it renders after our script + setTimeout(hideNative, 100); + setTimeout(hideNative, 500); +})(); + (async () => { const is_interactive = __IS_INTERACTIVE__; const q_init = __JS_Q__; @@ -1102,12 +1116,8 @@ FRONTEND_JS_TEMPLATE = r""" if (cursor) cursor.remove(); - // Replace streamed text nodes with markdown-rendered content - Array.from(data.childNodes).forEach(node => { - if (node.nodeType !== 1 || !node.classList.contains('sxng-prior-history')) { - node.remove(); - } - }); + // Only remove streaming chunk spans and cursor, preserve everything else + Array.from(data.querySelectorAll('.sxng-chunk, .sxng-cursor')).forEach(n => n.remove()); const rendered = parseMarkdown(fullText.trim()); const mdDiv = document.createElement('div'); @@ -2069,14 +2079,6 @@ class SXNGPlugin(Plugin): ''' - try: - search.result_container.answers.clear() - except Exception: - pass - try: - search.result_container.infoboxes.clear() - except Exception: - pass search.result_container.answers.add(results.types.Answer(answer=Markup(html_payload))) except Exception as e: logger.error(f"{PLUGIN_NAME}: {e}")