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 @@
3789 Auto-Parse Reasoning3789 Auto-Parse Reasoning
3790 </small>3790 </small>
3791 </label>3791 </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>
3792 <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">3798 <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">
3793 <input id="reasoning_add_to_prompts" type="checkbox" />3799 <input id="reasoning_add_to_prompts" type="checkbox" />
3794 <small data-i18n="Add Reasoning to Prompts">3800 <small data-i18n="Add Reasoning to Prompts">
@@ -6247,7 +6253,7 @@
6247 <div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div>6253 <div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div>
6248 </div>6254 </div>
6249 </div>6255 </div>
6250 <details class="mes_reasoning_details" open>6256 <details class="mes_reasoning_details">
6251 <summary class="mes_reasoning_summary flex-container">6257 <summary class="mes_reasoning_summary flex-container">
6252 <div class="mes_reasoning_header_block flex-container">6258 <div class="mes_reasoning_header_block flex-container">
6253 <div class="mes_reasoning_header flex-container">6259 <div class="mes_reasoning_header flex-container">
public/scripts/reasoning.js+20 -0
@@ -23,6 +23,18 @@ function getMessageFromJquery(element) {
23}23}
2424
25/**25/**
26 * Toggles the auto-expand state of reasoning blocks.
27 */
28function 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/**
26 * Helper class for adding reasoning to messages.38 * Helper class for adding reasoning to messages.
27 * Keeps track of the number of reasoning additions.39 * Keeps track of the number of reasoning additions.
28 */40 */
@@ -118,6 +130,13 @@ function loadReasoningSettings() {
118 power_user.reasoning.auto_parse = !!$(this).prop('checked');130 power_user.reasoning.auto_parse = !!$(this).prop('checked');
119 saveSettingsDebounced();131 saveSettingsDebounced();
120 });132 });
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 });
121}140}
122141
123function registerReasoningSlashCommands() {142function registerReasoningSlashCommands() {
@@ -444,6 +463,7 @@ function registerReasoningAppEvents() {
444463
445export function initReasoning() {464export function initReasoning() {
446 loadReasoningSettings();465 loadReasoningSettings();
466 toggleReasoningAutoExpand();
447 setReasoningEventHandlers();467 setReasoningEventHandlers();
448 registerReasoningSlashCommands();468 registerReasoningSlashCommands();
449 registerReasoningMacros();469 registerReasoningMacros();