From 23ecac6afa60604763832f73fce860f079b2ad57 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 18 May 2026 23:14:22 -0400 Subject: [PATCH 01/26] Fixed mayber --- ollama_answers.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ollama_answers.py b/ollama_answers.py index 83ac20d..8547d29 100644 --- a/ollama_answers.py +++ b/ollama_answers.py @@ -876,8 +876,18 @@ FRONTEND_JS_TEMPLATE = r""" }; const box = document.getElementById('sxng-stream-box'); const data = document.getElementById('sxng-stream-data'); - const wrapper = box.closest('.answer'); - if (wrapper) wrapper.style.display = 'none'; + + // Hide native SearXNG answer entries that are siblings of our box + setTimeout(() => { + const parent = box ? box.parentElement : null; + if (parent) { + Array.from(parent.children).forEach(el => { + if (el !== box && el.classList.contains('answer')) { + el.style.display = 'none'; + } + }); + } + }, 0); let restored = false; let isStreaming = false; @@ -947,7 +957,6 @@ FRONTEND_JS_TEMPLATE = r""" isStreaming = true; try { const ctx = auxContext || conversation.originalContext; - if (wrapper) wrapper.style.display = ''; box.style.display = 'block'; const controller = new AbortController(); @@ -1002,6 +1011,11 @@ FRONTEND_JS_TEMPLATE = r""" data.appendChild(cursor); } + const streamContainer = document.createElement('div'); + streamContainer.className = 'sxng-stream-container'; + if (cursor) cursor.before(streamContainer); + else data.appendChild(streamContainer); + let buffer = ''; let fullText = ''; const flushBuffer = (force = false) => { @@ -1009,8 +1023,7 @@ FRONTEND_JS_TEMPLATE = r""" if (force) { const fragment = renderCitations(buffer, urls); - if (cursor) cursor.before(fragment); - else data.appendChild(fragment); + streamContainer.appendChild(fragment); buffer = ''; return; } @@ -1025,12 +1038,12 @@ FRONTEND_JS_TEMPLATE = r""" const s = document.createElement('span'); s.className = 'sxng-chunk'; s.textContent = preText; - cursor.before(s); + streamContainer.appendChild(s); } const citationText = match[0]; const fragment = renderCitations(citationText, urls); - cursor.before(fragment); + streamContainer.appendChild(fragment); buffer = buffer.substring(match.index + match[0].length); } @@ -1041,7 +1054,7 @@ FRONTEND_JS_TEMPLATE = r""" const s = document.createElement('span'); s.className = 'sxng-chunk'; s.textContent = buffer; - cursor.before(s); + streamContainer.appendChild(s); buffer = ''; } } else { @@ -1050,7 +1063,7 @@ FRONTEND_JS_TEMPLATE = r""" const s = document.createElement('span'); s.className = 'sxng-chunk'; s.textContent = safeChunk; - cursor.before(s); + streamContainer.appendChild(s); } buffer = buffer.substring(openIdx); @@ -1058,7 +1071,7 @@ FRONTEND_JS_TEMPLATE = r""" const s = document.createElement('span'); s.className = 'sxng-chunk'; s.textContent = buffer[0]; - cursor.before(s); + streamContainer.appendChild(s); buffer = buffer.substring(1); } } @@ -1120,11 +1133,9 @@ FRONTEND_JS_TEMPLATE = r""" } } + streamContainer.remove(); if (cursor) cursor.remove(); - // Remove only the streamed chunk spans added during this stream - Array.from(data.querySelectorAll('.sxng-chunk')).forEach(node => node.remove()); - const rendered = parseMarkdown(fullText.trim()); const mdDiv = document.createElement('div'); mdDiv.className = 'sxng-md-content'; -- 2.52.0 From 4c749b825c3007ee7e9e3d24d686659dcdd46b68 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 18 May 2026 23:53:04 -0400 Subject: [PATCH 02/26] Fixing conversation history and couldn't figure out how to remove SearXNG info box so just adding a smart divider --- ollama_answers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ollama_answers.py b/ollama_answers.py index 8547d29..a8b4da2 100644 --- a/ollama_answers.py +++ b/ollama_answers.py @@ -888,6 +888,24 @@ FRONTEND_JS_TEMPLATE = r""" }); } }, 0); + + setTimeout(() => { + const parent = box ? box.parentElement : null; + if (parent) { + // Check if any sibling answers are visible above us + const siblings = Array.from(parent.children); + const ourIndex = siblings.indexOf(box); + const hasVisibleSiblingAbove = siblings.slice(0, ourIndex).some( + el => el !== box && el.style.display !== 'none' + ); + if (hasVisibleSiblingAbove) { + box.style.borderTop = '1px solid var(--color-result-border, #444)'; + box.style.paddingTop = '1rem'; + box.style.marginTop = '0.75rem'; + } + } + }, 10); + let restored = false; let isStreaming = false; -- 2.52.0 From 541d98f7f1acde069cfde37ba1bb2a6637945229 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 18 May 2026 23:56:23 -0400 Subject: [PATCH 03/26] Maybe working divider --- ollama_answers.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ollama_answers.py b/ollama_answers.py index a8b4da2..3cba87b 100644 --- a/ollama_answers.py +++ b/ollama_answers.py @@ -889,23 +889,6 @@ FRONTEND_JS_TEMPLATE = r""" } }, 0); - setTimeout(() => { - const parent = box ? box.parentElement : null; - if (parent) { - // Check if any sibling answers are visible above us - const siblings = Array.from(parent.children); - const ourIndex = siblings.indexOf(box); - const hasVisibleSiblingAbove = siblings.slice(0, ourIndex).some( - el => el !== box && el.style.display !== 'none' - ); - if (hasVisibleSiblingAbove) { - box.style.borderTop = '1px solid var(--color-result-border, #444)'; - box.style.paddingTop = '1rem'; - box.style.marginTop = '0.75rem'; - } - } - }, 10); - let restored = false; let isStreaming = false; @@ -2057,7 +2040,7 @@ class SXNGPlugin(Plugin): .replace("__JS_Q__", js_q) html_payload = f''' -