diff --git a/public/index.html b/public/index.html index aba5c6c40..195af02ba 100644 --- a/public/index.html +++ b/public/index.html @@ -3789,6 +3789,12 @@ Auto-Parse Reasoning + + + + Auto-Expand Reasoning + + @@ -6247,7 +6253,7 @@ - + diff --git a/public/scripts/reasoning.js b/public/scripts/reasoning.js index 3eea8224d..4cd805fd0 100644 --- a/public/scripts/reasoning.js +++ b/public/scripts/reasoning.js @@ -22,6 +22,18 @@ function getMessageFromJquery(element) { return { messageId: messageId, message, messageBlock }; } +/** + * Toggles the auto-expand state of reasoning blocks. + */ +function toggleReasoningAutoExpand() { + const reasoningBlocks = document.querySelectorAll('details.mes_reasoning_details'); + reasoningBlocks.forEach((block) => { + if (block instanceof HTMLDetailsElement) { + block.open = power_user.reasoning.auto_expand; + } + }); +} + /** * Helper class for adding reasoning to messages. * Keeps track of the number of reasoning additions. @@ -118,6 +130,13 @@ function loadReasoningSettings() { power_user.reasoning.auto_parse = !!$(this).prop('checked'); saveSettingsDebounced(); }); + + $('#reasoning_auto_expand').prop('checked', power_user.reasoning.auto_expand); + $('#reasoning_auto_expand').on('change', function () { + power_user.reasoning.auto_expand = !!$(this).prop('checked'); + toggleReasoningAutoExpand(); + saveSettingsDebounced(); + }); } function registerReasoningSlashCommands() { @@ -444,6 +463,7 @@ function registerReasoningAppEvents() { export function initReasoning() { loadReasoningSettings(); + toggleReasoningAutoExpand(); setReasoningEventHandlers(); registerReasoningSlashCommands(); registerReasoningMacros();