diff --git a/templates/chat.html b/templates/chat.html
index 4ffd2f7..d999843 100644
--- a/templates/chat.html
+++ b/templates/chat.html
@@ -421,10 +421,24 @@ function truncateCodeBlock(block, maxLines = 100) {
// Reapply syntax highlighting
hljs.highlightElement(block);
addLineNumbers(block);
- // Remove the expand button
- expandButton.remove();
+ // Change the button text to "Show Less"
+ expandButton.textContent = 'Show Less';
+ // Change the onclick function to truncate the block again
+ expandButton.onclick = function() {
+ block.textContent = truncatedText;
+ // Reapply syntax highlighting
+ hljs.highlightElement(block);
+ addLineNumbers(block);
+ // Change the button text back to "Show More"
+ expandButton.textContent = 'Show More';
+ // Set the onclick function back to the original expand function
+ expandButton.onclick = originalExpandFunction;
+ };
};
+ // Keep a reference to the original expand function
+ const originalExpandFunction = expandButton.onclick;
+
// Insert the expand button after the code block
block.parentNode.insertBefore(expandButton, block.nextSibling);
}