Make hidden reasoning blocks not toggleable

93f3334ad0bb7b286ce9535d747d5034106bf018

Wolfsblvt <wolfsblvt@gmail.com>

2 files changed, +18 -2Ignore whitespace
public/scripts/reasoning.js+14 -2
@@ -153,7 +153,7 @@ export class ReasoningHandler {
153 // Cached DOM elements for reasoning153 // Cached DOM elements for reasoning
154 /** @type {HTMLElement} Main message DOM element `.mes` */154 /** @type {HTMLElement} Main message DOM element `.mes` */
155 this.messageDom = null;155 this.messageDom = null;
156 /** @type {HTMLElement} Reasoning details DOM element `.mes_reasoning_details` */156 /** @type {HTMLDetailsElement} Reasoning details DOM element `.mes_reasoning_details` */
157 this.messageReasoningDetailsDom = null;157 this.messageReasoningDetailsDom = null;
158 /** @type {HTMLElement} Reasoning content DOM element `.mes_reasoning` */158 /** @type {HTMLElement} Reasoning content DOM element `.mes_reasoning` */
159 this.messageReasoningContentDom = null;159 this.messageReasoningContentDom = null;
@@ -336,6 +336,11 @@ export class ReasoningHandler {
336 const button = this.messageDom.querySelector('.mes_edit_add_reasoning');336 const button = this.messageDom.querySelector('.mes_edit_add_reasoning');
337 button.title = this.state === ReasoningState.Hidden ? t`Hidden reasoning - Add reasoning block` : t`Add reasoning block`;337 button.title = this.state === ReasoningState.Hidden ? t`Hidden reasoning - Add reasoning block` : t`Add reasoning block`;
338338
339 // Make sure that hidden reasoning headers are collapsed by default, to not show a useless edit button
340 if (this.state === ReasoningState.Hidden) {
341 this.messageReasoningDetailsDom.open = false;
342 }
343
339 // Update the reasoning duration in the UI344 // Update the reasoning duration in the UI
340 this.#updateReasoningTimeUI();345 this.#updateReasoningTimeUI();
341 }346 }
@@ -628,7 +633,14 @@ function setReasoningEventHandlers() {
628 }633 }
629 });634 });
630635
631 $(document).on('click', '.mes_reasoning_header', function () {636 $(document).on('click', '.mes_reasoning_header', function (e) {
637 const details = $(this).closest('.mes_reasoning_details');
638 // Along with the CSS rules to mark blocks not toggle-able when they are empty, prevent them from actually being toggled, or being edited
639 if (details.find('.mes_reasoning').is(':empty')) {
640 e.preventDefault();
641 return;
642 }
643
632 // If we are in message edit mode and reasoning area is closed, a click opens and edits it644 // If we are in message edit mode and reasoning area is closed, a click opens and edits it
633 const mes = $(this).closest('.mes');645 const mes = $(this).closest('.mes');
634 const mesEditArea = mes.find('#curEditTextarea');646 const mesEditArea = mes.find('#curEditTextarea');
public/style.css+4 -0
@@ -398,6 +398,10 @@ input[type='checkbox']:focus-visible {
398 align-items: baseline;398 align-items: baseline;
399}399}
400400
401.mes:has(.mes_reasoning:empty) .mes_reasoning_header {
402 cursor: default;
403}
404
401/* TWIMC: Remove with custom CSS to show the icon */405/* TWIMC: Remove with custom CSS to show the icon */
402.mes_reasoning_header > .icon-svg {406.mes_reasoning_header > .icon-svg {
403 display: none;407 display: none;