mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-26 00:47:42 +01:00
Configurable chat truncation amount
This commit is contained in:
parent
a02446c4cc
commit
ac07c8324d
@ -2756,6 +2756,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="chat-truncation-block" class="range-block">
|
||||
<div class="range-block-title" data-i18n="Chat Truncation">
|
||||
Chat Truncation <small>(0 = unlimited)</small>
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="chat_truncation" name="chat_truncation" min="0" max="1000" step="25">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<input type="number" min="0" max="1000" step="1" data-for="chat_truncation" id="chat_truncation_counter">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1297,11 +1297,9 @@ async function replaceCurrentChat() {
|
||||
}
|
||||
}
|
||||
|
||||
const TRUNCATION_THRESHOLD = 100;
|
||||
|
||||
export function showMoreMessages() {
|
||||
let messageId = Number($('#chat').children('.mes').first().attr('mesid'));
|
||||
let count = TRUNCATION_THRESHOLD;
|
||||
let count = power_user.chat_truncation || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
console.debug('Inserting messages before', messageId, 'count', count, 'chat length', chat.length);
|
||||
const prevHeight = $('#chat').prop('scrollHeight');
|
||||
@ -1322,9 +1320,10 @@ export function showMoreMessages() {
|
||||
|
||||
async function printMessages() {
|
||||
let startIndex = 0;
|
||||
let count = power_user.chat_truncation || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
if (chat.length > TRUNCATION_THRESHOLD) {
|
||||
count_view_mes = chat.length - TRUNCATION_THRESHOLD;
|
||||
if (chat.length > count) {
|
||||
count_view_mes = chat.length - count;
|
||||
startIndex = count_view_mes;
|
||||
$('#chat').append('<div id="show_more_messages">Show more messages</div>');
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ let power_user = {
|
||||
target_length: 400,
|
||||
},
|
||||
markdown_escape_strings: '',
|
||||
chat_truncation: 100,
|
||||
|
||||
ui_mode: ui_mode.POWER,
|
||||
fast_ui_mode: true,
|
||||
@ -1373,6 +1374,9 @@ function loadPowerUserSettings(settings, data) {
|
||||
$("#token_padding").val(power_user.token_padding);
|
||||
$("#aux_field").val(power_user.aux_field);
|
||||
|
||||
$("#chat_truncation").val(power_user.chat_truncation);
|
||||
$('#chat_truncation_counter').val(power_user.chat_truncation);
|
||||
|
||||
$("#font_scale").val(power_user.font_scale);
|
||||
$("#font_scale_counter").val(power_user.font_scale);
|
||||
|
||||
@ -2559,6 +2563,12 @@ $(document).ready(() => {
|
||||
setHotswapsDebounced();
|
||||
});
|
||||
|
||||
$('#chat_truncation').on('input', function () {
|
||||
power_user.chat_truncation = Number($('#chat_truncation').val());
|
||||
$('#chat_truncation_counter').val(power_user.chat_truncation);
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(`input[name="font_scale"]`).on('input', async function (e) {
|
||||
power_user.font_scale = Number(e.target.value);
|
||||
$("#font_scale_counter").val(power_user.font_scale);
|
||||
|
@ -3730,11 +3730,15 @@ a {
|
||||
|
||||
#show_more_messages {
|
||||
text-align: center;
|
||||
margin: 10px 0;
|
||||
margin: 10px auto;
|
||||
font-weight: 500;
|
||||
text-decoration: underline;
|
||||
order: -1;
|
||||
cursor: pointer;
|
||||
padding: 0.5em 1em;
|
||||
background-color: var(--SmartThemeBlurTintColor);
|
||||
width: fit-content;
|
||||
border-radius: 10px;
|
||||
outline: 1px solid var(--SmartThemeBorderColor);
|
||||
}
|
||||
|
||||
.draggable img {
|
||||
|
Loading…
x
Reference in New Issue
Block a user