Add toggle for reasoning auto-expand

This commit is contained in:
Cohee
2025-02-02 18:42:12 +02:00
parent 02130b848c
commit ff83ae975d
2 changed files with 27 additions and 1 deletions

View File

@ -3789,6 +3789,12 @@
Auto-Parse Reasoning Auto-Parse Reasoning
</small> </small>
</label> </label>
<label class="checkbox_label" for="reasoning_auto_expand" title="Automatically expand reasoning blocks." data-i18n="[title]reasoning_auto_expand">
<input id="reasoning_auto_expand" type="checkbox" />
<small data-i18n="Auto-Expand Reasoning">
Auto-Expand Reasoning
</small>
</label>
<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"> <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">
<input id="reasoning_add_to_prompts" type="checkbox" /> <input id="reasoning_add_to_prompts" type="checkbox" />
<small data-i18n="Add Reasoning to Prompts"> <small data-i18n="Add Reasoning to Prompts">
@ -6247,7 +6253,7 @@
<div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div> <div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div>
</div> </div>
</div> </div>
<details class="mes_reasoning_details" open> <details class="mes_reasoning_details">
<summary class="mes_reasoning_summary flex-container"> <summary class="mes_reasoning_summary flex-container">
<div class="mes_reasoning_header_block flex-container"> <div class="mes_reasoning_header_block flex-container">
<div class="mes_reasoning_header flex-container"> <div class="mes_reasoning_header flex-container">

View File

@ -22,6 +22,18 @@ function getMessageFromJquery(element) {
return { messageId: messageId, message, messageBlock }; 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. * Helper class for adding reasoning to messages.
* Keeps track of the number of reasoning additions. * Keeps track of the number of reasoning additions.
@ -118,6 +130,13 @@ function loadReasoningSettings() {
power_user.reasoning.auto_parse = !!$(this).prop('checked'); power_user.reasoning.auto_parse = !!$(this).prop('checked');
saveSettingsDebounced(); 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() { function registerReasoningSlashCommands() {
@ -444,6 +463,7 @@ function registerReasoningAppEvents() {
export function initReasoning() { export function initReasoning() {
loadReasoningSettings(); loadReasoningSettings();
toggleReasoningAutoExpand();
setReasoningEventHandlers(); setReasoningEventHandlers();
registerReasoningSlashCommands(); registerReasoningSlashCommands();
registerReasoningMacros(); registerReasoningMacros();