diff --git a/js/global_scope_js.js b/js/global_scope_js.js index e808c473..29d2d8bd 100644 --- a/js/global_scope_js.js +++ b/js/global_scope_js.js @@ -31,13 +31,13 @@ function removeLastClick() { } function handleMorphdomUpdate(text) { - // Track closed blocks - const closedBlocks = new Set(); + // Track open blocks + const openBlocks = new Set(); document.querySelectorAll(".thinking-block").forEach(block => { const blockId = block.getAttribute("data-block-id"); - // If block exists and is not open, add to closed set - if (blockId && !block.hasAttribute("open")) { - closedBlocks.add(blockId); + // If block exists and is open, add to open set + if (blockId && block.hasAttribute("open")) { + openBlocks.add(blockId); } }); @@ -72,13 +72,15 @@ function handleMorphdomUpdate(text) { } } - // For thinking blocks, respect closed state + // For thinking blocks, assume closed by default if (fromEl.classList && fromEl.classList.contains("thinking-block") && - toEl.classList && toEl.classList.contains("thinking-block")) { + toEl.classList && toEl.classList.contains("thinking-block")) { const blockId = toEl.getAttribute("data-block-id"); - // If this block was closed by user, keep it closed - if (blockId && closedBlocks.has(blockId)) { - toEl.removeAttribute("open"); + // Remove open attribute by default + toEl.removeAttribute("open"); + // If this block was explicitly opened by user, keep it open + if (blockId && openBlocks.has(blockId)) { + toEl.setAttribute("open", ""); } } diff --git a/modules/html_generator.py b/modules/html_generator.py index c5252c26..67d15b6e 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -167,7 +167,7 @@ def convert_to_markdown(string, message_id=None): title_text = "Thinking..." if is_streaming else "Thought" thinking_block = f''' -
+