Merge pull request #3154 from SillyTavern/optimize-past-swipes Optimize past swipes
Signed| @@ -4184,7 +4184,7 @@ | |||
| 4184 | </label> | 4184 | </label> |
| 4185 | <label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last."> | 4185 | <label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last."> |
| 4186 | <input id="show_swipe_num_all_messages" type="checkbox" /> | 4186 | <input id="show_swipe_num_all_messages" type="checkbox" /> |
| 4187 | <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i> | 4187 | <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small> |
| 4188 | </label> | 4188 | </label> |
| 4189 | <label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters"> | 4189 | <label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters"> |
| 4190 | <input id="hotswapEnabled" type="checkbox" /> | 4190 | <input id="hotswapEnabled" type="checkbox" /> |
| @@ -98,7 +98,6 @@ import { | |||
| 98 | resetMovableStyles, | 98 | resetMovableStyles, |
| 99 | forceCharacterEditorTokenize, | 99 | forceCharacterEditorTokenize, |
| 100 | applyPowerUserSettings, | 100 | applyPowerUserSettings, |
| 101 | switchSwipeNumAllMessages, | ||
| 102 | } from './scripts/power-user.js'; | 101 | } from './scripts/power-user.js'; |
| 103 | 102 | ||
| 104 | import { | 103 | import { |
| @@ -7664,14 +7663,12 @@ export function showSwipeButtons() { | |||
| 7664 | //allows for writing individual swipe counters for past messages | 7663 | //allows for writing individual swipe counters for past messages |
| 7665 | const lastSwipeCounter = $('.last_mes .swipes-counter'); | 7664 | const lastSwipeCounter = $('.last_mes .swipes-counter'); |
| 7666 | lastSwipeCounter.text(swipeCounterText).show(); | 7665 | lastSwipeCounter.text(swipeCounterText).show(); |
| 7667 | |||
| 7668 | switchSwipeNumAllMessages(); | ||
| 7669 | } | 7666 | } |
| 7670 | 7667 | ||
| 7671 | export function hideSwipeButtons() { | 7668 | export function hideSwipeButtons() { |
| 7672 | $('#chat').find('.swipe_right').hide(); | 7669 | chatElement.find('.swipe_right').hide(); |
| 7673 | $('#chat').find('.last_mes .swipes-counter').hide(); | 7670 | chatElement.find('.last_mes .swipes-counter').hide(); |
| 7674 | $('#chat').find('.swipe_left').hide(); | 7671 | chatElement.find('.swipe_left').hide(); |
| 7675 | } | 7672 | } |
| 7676 | 7673 | ||
| 7677 | /** | 7674 | /** |
| @@ -60,7 +60,6 @@ import { ToolManager } from '../../tool-calling.js'; | |||
| 60 | export { MODULE_NAME }; | 60 | export { MODULE_NAME }; |
| 61 | 61 | ||
| 62 | const MODULE_NAME = 'sd'; | 62 | const MODULE_NAME = 'sd'; |
| 63 | const UPDATE_INTERVAL = 1000; | ||
| 64 | // This is a 1x1 transparent PNG | 63 | // This is a 1x1 transparent PNG |
| 65 | const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; | 64 | const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; |
| 66 | const CUSTOM_STOP_EVENT = 'sd_stop_generation'; | 65 | const CUSTOM_STOP_EVENT = 'sd_stop_generation'; |
| @@ -3687,8 +3686,6 @@ async function addSDGenButtons() { | |||
| 3687 | const button = $('#sd_gen'); | 3686 | const button = $('#sd_gen'); |
| 3688 | const dropdown = $('#sd_dropdown'); | 3687 | const dropdown = $('#sd_dropdown'); |
| 3689 | dropdown.hide(); | 3688 | dropdown.hide(); |
| 3690 | button.hide(); | ||
| 3691 | messageButton.hide(); | ||
| 3692 | 3689 | ||
| 3693 | let popper = Popper.createPopper(button.get(0), dropdown.get(0), { | 3690 | let popper = Popper.createPopper(button.get(0), dropdown.get(0), { |
| 3694 | placement: 'top', | 3691 | placement: 'top', |
| @@ -3770,18 +3767,6 @@ function isValidState() { | |||
| 3770 | } | 3767 | } |
| 3771 | } | 3768 | } |
| 3772 | 3769 | ||
| 3773 | async function moduleWorker() { | ||
| 3774 | if (isValidState()) { | ||
| 3775 | $('#sd_gen').show(); | ||
| 3776 | $('.sd_message_gen').show(); | ||
| 3777 | } | ||
| 3778 | else { | ||
| 3779 | $('#sd_gen').hide(); | ||
| 3780 | $('.sd_message_gen').hide(); | ||
| 3781 | } | ||
| 3782 | } | ||
| 3783 | |||
| 3784 | setInterval(moduleWorker, UPDATE_INTERVAL); | ||
| 3785 | let buttonAbortController = null; | 3770 | let buttonAbortController = null; |
| 3786 | 3771 | ||
| 3787 | async function sdMessageButton(e) { | 3772 | async function sdMessageButton(e) { |
| @@ -472,9 +472,9 @@ function switchCompactInputArea() { | |||
| 472 | $('#compact_input_area').prop('checked', power_user.compact_input_area); | 472 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | export function switchSwipeNumAllMessages() { | 475 | function switchSwipeNumAllMessages() { |
| 476 | $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); | 476 | $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); |
| 477 | $('.mes:not(.last_mes) .swipes-counter').css('opacity', '').toggle(power_user.show_swipe_num_all_messages); | 477 | $('body').toggleClass('swipeAllMessages', !!power_user.show_swipe_num_all_messages); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | var originalSliderValues = []; | 480 | var originalSliderValues = []; |
| @@ -1040,8 +1040,14 @@ body .panelControlBar { | |||
| 1040 | height: var(--swipeCounterHeight); | 1040 | height: var(--swipeCounterHeight); |
| 1041 | } | 1041 | } |
| 1042 | 1042 | ||
| 1043 | .mes:not(.last_mes) .swipes-counter { | 1043 | body:not(.swipeAllMessages) .mes:not(.last_mes) .swipes-counter { |
| 1044 | opacity: 0.3; | 1044 | visibility: hidden; |
| 1045 | } | ||
| 1046 | |||
| 1047 | body.swipeAllMessages .mes:not(.last_mes) .swipes-counter { | ||
| 1048 | /* Avoid expensive DOM queries */ | ||
| 1049 | opacity: 0.3 !important; | ||
| 1050 | display: flex !important; | ||
| 1045 | } | 1051 | } |
| 1046 | 1052 | ||
| 1047 | .swipe_left { | 1053 | .swipe_left { |