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

@ -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();