Add toggle for reasoning auto-expand

ff83ae975d1cf6e79209b32779c28d2e707a7fee

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +27 -1Ignore whitespace
public/index.html+7 -1
@@ -3789,6 +3789,12 @@
37893789 Auto-Parse Reasoning
37903790 </small>
37913791 </label>
3792+ <label class="checkbox_label" for="reasoning_auto_expand" title="Automatically expand reasoning blocks." data-i18n="[title]reasoning_auto_expand">
3793+ <input id="reasoning_auto_expand" type="checkbox" />
3794+ <small data-i18n="Auto-Expand Reasoning">
3795+ Auto-Expand Reasoning
3796+ </small>
3797+ </label>
37923798 <label class="checkbox_label" for="reasoning_add_to_prompts" title="Add existing reasoning blocks to prompts. To add a new reasoning block, use the message edit menu." data-i18n="[title]reasoning_add_to_prompts">
37933799 <input id="reasoning_add_to_prompts" type="checkbox" />
37943800 <small data-i18n="Add Reasoning to Prompts">
@@ -6247,7 +6253,7 @@
62476253 <div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div>
62486254 </div>
62496255 </div>
62506256 <details class="mes_reasoning_details" open>
62516257 <summary class="mes_reasoning_summary flex-container">
62526258 <div class="mes_reasoning_header_block flex-container">
62536259 <div class="mes_reasoning_header flex-container">
public/scripts/reasoning.js+20 -0
@@ -23,6 +23,18 @@ function getMessageFromJquery(element) {
2323}
2424
2525/**
26+ * Toggles the auto-expand state of reasoning blocks.
27+ */
28+function toggleReasoningAutoExpand() {
29+ const reasoningBlocks = document.querySelectorAll('details.mes_reasoning_details');
30+ reasoningBlocks.forEach((block) => {
31+ if (block instanceof HTMLDetailsElement) {
32+ block.open = power_user.reasoning.auto_expand;
33+ }
34+ });
35+}
36+
37+/**
2638 * Helper class for adding reasoning to messages.
2739 * Keeps track of the number of reasoning additions.
2840 */
@@ -118,6 +130,13 @@ function loadReasoningSettings() {
118130 power_user.reasoning.auto_parse = !!$(this).prop('checked');
119131 saveSettingsDebounced();
120132 });
133+
134+ $('#reasoning_auto_expand').prop('checked', power_user.reasoning.auto_expand);
135+ $('#reasoning_auto_expand').on('change', function () {
136+ power_user.reasoning.auto_expand = !!$(this).prop('checked');
137+ toggleReasoningAutoExpand();
138+ saveSettingsDebounced();
139+ });
121140}
122141
123142function registerReasoningSlashCommands() {
@@ -444,6 +463,7 @@ function registerReasoningAppEvents() {
444463
445464export function initReasoning() {
446465 loadReasoningSettings();
466+ toggleReasoningAutoExpand();
447467 setReasoningEventHandlers();
448468 registerReasoningSlashCommands();
449469 registerReasoningMacros();