Fixing conversation history and SearXNG info block
This commit is contained in:
+16
-14
@@ -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):
|
||||
</script>
|
||||
</article>
|
||||
'''
|
||||
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}")
|
||||
|
||||
Reference in New Issue
Block a user