mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
- added edit message auto saving
- toggle in PowerUser settings - removed consolelog spam from RA-mods and expressions
This commit is contained in:
@ -1277,6 +1277,9 @@
|
|||||||
<label for="auto-load-chat-checkbox"><input id="auto-load-chat-checkbox" type="checkbox" />
|
<label for="auto-load-chat-checkbox"><input id="auto-load-chat-checkbox" type="checkbox" />
|
||||||
Auto-load Last Chat
|
Auto-load Last Chat
|
||||||
</label>
|
</label>
|
||||||
|
<label for="auto_save_msg_edits"><input id="auto_save_msg_edits" type="checkbox" />
|
||||||
|
Auto-load Message Edits
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -1892,4 +1895,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -202,10 +202,12 @@ let dialogueResolve = null;
|
|||||||
let chat_metadata = {};
|
let chat_metadata = {};
|
||||||
let streamingProcessor = null;
|
let streamingProcessor = null;
|
||||||
|
|
||||||
|
|
||||||
const durationSaveEdit = 200;
|
const durationSaveEdit = 200;
|
||||||
const saveSettingsDebounced = debounce(() => saveSettings(), durationSaveEdit);
|
const saveSettingsDebounced = debounce(() => saveSettings(), durationSaveEdit);
|
||||||
const saveCharacterDebounced = debounce(() => $("#create_button").click(), durationSaveEdit);
|
const saveCharacterDebounced = debounce(() => $("#create_button").click(), durationSaveEdit);
|
||||||
const getStatusDebounced = debounce(() => getStatus(), 90000);
|
const getStatusDebounced = debounce(() => getStatus(), 90000);
|
||||||
|
const saveChatDebounced = debounce(() => saveChatConditional(), 1000);
|
||||||
|
|
||||||
const system_message_types = {
|
const system_message_types = {
|
||||||
HELP: "help",
|
HELP: "help",
|
||||||
@ -2905,6 +2907,22 @@ function isInt(value) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function messageEditAuto(div) {
|
||||||
|
let mesBlock = div.closest(".mes_block");
|
||||||
|
var text = mesBlock.find(".edit_textarea").val().trim();
|
||||||
|
const bias = extractMessageBias(text);
|
||||||
|
chat[this_edit_mes_id]["mes"] = text;
|
||||||
|
|
||||||
|
// editing old messages
|
||||||
|
if (!chat[this_edit_mes_id]["extra"]) {
|
||||||
|
chat[this_edit_mes_id]["extra"] = {};
|
||||||
|
}
|
||||||
|
chat[this_edit_mes_id]["extra"]["bias"] = bias ?? null;
|
||||||
|
mesBlock.find(".mes_text").val('');
|
||||||
|
mesBlock.find(".mes_text").val(messageFormating(text));
|
||||||
|
saveChatDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
function messageEditDone(div) {
|
function messageEditDone(div) {
|
||||||
let mesBlock = div.closest(".mes_block");
|
let mesBlock = div.closest(".mes_block");
|
||||||
var text = mesBlock.find(".edit_textarea").val().trim();
|
var text = mesBlock.find(".edit_textarea").val().trim();
|
||||||
@ -2921,7 +2939,9 @@ function messageEditDone(div) {
|
|||||||
mesBlock.find(".mes_text").empty();
|
mesBlock.find(".mes_text").empty();
|
||||||
mesBlock.find(".mes_edit_buttons").css("display", "none");
|
mesBlock.find(".mes_edit_buttons").css("display", "none");
|
||||||
mesBlock.find(".mes_edit").css("display", "inline-block");
|
mesBlock.find(".mes_edit").css("display", "inline-block");
|
||||||
mesBlock.find(".mes_text").append(messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar));
|
mesBlock.find(".mes_text").append(
|
||||||
|
messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar)
|
||||||
|
);
|
||||||
mesBlock.find(".mes_bias").empty();
|
mesBlock.find(".mes_bias").empty();
|
||||||
mesBlock.find(".mes_bias").append(messageFormating(bias));
|
mesBlock.find(".mes_bias").append(messageFormating(bias));
|
||||||
appendImageToMessage(chat[this_edit_mes_id], div.closest(".mes"));
|
appendImageToMessage(chat[this_edit_mes_id], div.closest(".mes"));
|
||||||
@ -4248,6 +4268,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("#talkativeness_slider").on("input", function () {
|
$("#talkativeness_slider").on("input", function () {
|
||||||
if (menu_type == "create") {
|
if (menu_type == "create") {
|
||||||
create_save_talkativeness = $("#talkativeness_slider").val();
|
create_save_talkativeness = $("#talkativeness_slider").val();
|
||||||
@ -4664,9 +4685,7 @@ $(document).ready(function () {
|
|||||||
.closest(".mes_block")
|
.closest(".mes_block")
|
||||||
.find(".mes_text")
|
.find(".mes_text")
|
||||||
.append(
|
.append(
|
||||||
'<textarea class=edit_textarea style="max-width:auto; ">' +
|
`<textarea id='curEditTextarea' class='edit_textarea' style='max-width:auto; '>${text}</textarea>`
|
||||||
text +
|
|
||||||
"</textarea>"
|
|
||||||
);
|
);
|
||||||
let edit_textarea = $(this)
|
let edit_textarea = $(this)
|
||||||
.closest(".mes_block")
|
.closest(".mes_block")
|
||||||
@ -4685,6 +4704,13 @@ $(document).ready(function () {
|
|||||||
updateEditArrowClasses();
|
updateEditArrowClasses();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('input', '#curEditTextarea', function () {
|
||||||
|
if (power_user.auto_save_msg_edits === true) {
|
||||||
|
messageEditAuto($(this));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$(document).on("click", ".mes_edit_cancel", function () {
|
$(document).on("click", ".mes_edit_cancel", function () {
|
||||||
let text = chat[this_edit_mes_id]["mes"];
|
let text = chat[this_edit_mes_id]["mes"];
|
||||||
|
|
||||||
@ -5072,8 +5098,15 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$(document).keyup(function (e) {
|
$(document).keyup(function (e) {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
closeMessageEditor();
|
if (power_user.auto_save_msg_edits === false) {
|
||||||
$("#send_textarea").focus();
|
closeMessageEditor();
|
||||||
|
$("#send_textarea").focus();
|
||||||
|
}
|
||||||
|
if (power_user.auto_save_msg_edits === true) {
|
||||||
|
$(`#chat .mes[mesid="${this_edit_mes_id}"] .mes_edit_done`).click()
|
||||||
|
$("#send_textarea").focus();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ function waitForElement(querySelector, timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
waitForElement("#expression-image", 10000).then(function () {
|
waitForElement("#expression-image", 10000).then(function () {
|
||||||
console.log("expression image loaded, now draggable.");
|
|
||||||
dragElement(document.getElementById("expression-holder"));
|
dragElement(document.getElementById("expression-holder"));
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log("expression holder not loaded yet");
|
console.log("expression holder not loaded yet");
|
||||||
@ -591,13 +591,10 @@ $("document").ready(function () {
|
|||||||
var chatbarInFocus = false;
|
var chatbarInFocus = false;
|
||||||
$('#send_textarea').focus(function () {
|
$('#send_textarea').focus(function () {
|
||||||
chatbarInFocus = true;
|
chatbarInFocus = true;
|
||||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#send_textarea').blur(function () {
|
$('#send_textarea').blur(function () {
|
||||||
|
|
||||||
chatbarInFocus = false;
|
chatbarInFocus = false;
|
||||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -677,28 +674,11 @@ $("document").ready(function () {
|
|||||||
if (event.ctrlKey && event.key == "Enter") {
|
if (event.ctrlKey && event.key == "Enter") {
|
||||||
// Ctrl+Enter for Regeneration Last Response
|
// Ctrl+Enter for Regeneration Last Response
|
||||||
if (is_send_press == false) {
|
if (is_send_press == false) {
|
||||||
|
|
||||||
$('#option_regenerate').click();
|
$('#option_regenerate').click();
|
||||||
$('#options').hide();
|
$('#options').hide();
|
||||||
//setTimeout(function () { $('#chat').click(); }, 50) //needed to remove the options menu popping up..
|
|
||||||
//Generate("regenerate");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* if (event.ctrlKey && event.key == "ArrowUp") {
|
|
||||||
//Ctrl+UpArrow for Connect to last server
|
|
||||||
console.log(main_api);
|
|
||||||
if (online_status === "no_connection") {
|
|
||||||
if (main_api == "kobold") {
|
|
||||||
document.getElementById("api_button").click();
|
|
||||||
}
|
|
||||||
if (main_api == "novel") {
|
|
||||||
document.getElementById("api_button_novel").click();
|
|
||||||
}
|
|
||||||
if (main_api == "textgenerationwebui") {
|
|
||||||
document.getElementById("api_button_textgenerationwebui").click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
if (event.ctrlKey && event.key == "ArrowLeft") { //for debug, show all local stored vars
|
if (event.ctrlKey && event.key == "ArrowLeft") { //for debug, show all local stored vars
|
||||||
CheckLocal();
|
CheckLocal();
|
||||||
}
|
}
|
||||||
|
@ -208,15 +208,15 @@ function getListItem(item, imageSrc, textClass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getExpressionsList() {
|
async function getExpressionsList() {
|
||||||
console.log('getting expressions list');
|
|
||||||
// get something for offline mode (6 default images)
|
// get something for offline mode (6 default images)
|
||||||
if (!modules.includes('classify')) {
|
if (!modules.includes('classify')) {
|
||||||
console.log('classify not available, loading default');
|
|
||||||
return DEFAULT_EXPRESSIONS;
|
return DEFAULT_EXPRESSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(expressionsList)) {
|
if (Array.isArray(expressionsList)) {
|
||||||
console.log('got array, loading array');
|
|
||||||
return expressionsList;
|
return expressionsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,33 +224,33 @@ async function getExpressionsList() {
|
|||||||
url.pathname = '/api/classify/labels';
|
url.pathname = '/api/classify/labels';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('trying for API');
|
|
||||||
const apiResult = await fetch(url, {
|
const apiResult = await fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { 'Bypass-Tunnel-Reminder': 'bypass' },
|
headers: { 'Bypass-Tunnel-Reminder': 'bypass' },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (apiResult.ok) {
|
if (apiResult.ok) {
|
||||||
console.log('API ok, adding labels');
|
|
||||||
const data = await apiResult.json();
|
const data = await apiResult.json();
|
||||||
expressionsList = data.labels;
|
expressionsList = data.labels;
|
||||||
return expressionsList;
|
return expressionsList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log('got error!');
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setExpression(character, expression, force) {
|
async function setExpression(character, expression, force) {
|
||||||
console.log('entered setExpressions');
|
|
||||||
const filename = `${expression}.png`;
|
const filename = `${expression}.png`;
|
||||||
const img = $('img.expression');
|
const img = $('img.expression');
|
||||||
console.log('checking for expression images to show..');
|
|
||||||
if (force || (existingExpressions.includes(expression))) {
|
if (force || (existingExpressions.includes(expression))) {
|
||||||
console.log('setting expression from character images folder');
|
|
||||||
const imgUrl = `/characters/${character}/${filename}`;
|
const imgUrl = `/characters/${character}/${filename}`;
|
||||||
img.attr('src', imgUrl);
|
img.attr('src', imgUrl);
|
||||||
img.removeClass('default');
|
img.removeClass('default');
|
||||||
@ -263,13 +263,13 @@ async function setExpression(character, expression, force) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (extension_settings.expressions.showDefault) {
|
if (extension_settings.expressions.showDefault) {
|
||||||
console.log('no character images, trying default expressions');
|
|
||||||
setDefault();
|
setDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefault() {
|
function setDefault() {
|
||||||
console.log('setting default');
|
|
||||||
const defImgUrl = `/img/default-expressions/${filename}`;
|
const defImgUrl = `/img/default-expressions/${filename}`;
|
||||||
//console.log(defImgUrl);
|
//console.log(defImgUrl);
|
||||||
img.attr('src', defImgUrl);
|
img.attr('src', defImgUrl);
|
||||||
@ -294,7 +294,7 @@ function onClickExpressionImage() {
|
|||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
function addExpressionImage() {
|
function addExpressionImage() {
|
||||||
console.log('entered addExpressionImage');
|
|
||||||
const html = `
|
const html = `
|
||||||
<div id="expression-holder" class="expression-holder" style="display:none;">
|
<div id="expression-holder" class="expression-holder" style="display:none;">
|
||||||
<div id="expression-holderheader" class="fa-solid fa-grip drag-grabber"></div>
|
<div id="expression-holderheader" class="fa-solid fa-grip drag-grabber"></div>
|
||||||
@ -303,7 +303,7 @@ function onClickExpressionImage() {
|
|||||||
$('body').append(html);
|
$('body').append(html);
|
||||||
}
|
}
|
||||||
function addSettings() {
|
function addSettings() {
|
||||||
console.log('entered addSettings');
|
|
||||||
const html = `
|
const html = `
|
||||||
<div class="expression_settings">
|
<div class="expression_settings">
|
||||||
<div class="inline-drawer">
|
<div class="inline-drawer">
|
||||||
|
@ -59,6 +59,7 @@ let power_user = {
|
|||||||
sheld_width: sheld_width.DEFAULT,
|
sheld_width: sheld_width.DEFAULT,
|
||||||
play_message_sound: false,
|
play_message_sound: false,
|
||||||
play_sound_unfocused: true,
|
play_sound_unfocused: true,
|
||||||
|
auto_save_msg_edits: false,
|
||||||
sort_field: 'name',
|
sort_field: 'name',
|
||||||
sort_order: 'asc',
|
sort_order: 'asc',
|
||||||
font_scale: 1,
|
font_scale: 1,
|
||||||
@ -307,6 +308,7 @@ function loadPowerUserSettings(settings, data) {
|
|||||||
$("#multigen_next_chunks").val(power_user.multigen_next_chunks);
|
$("#multigen_next_chunks").val(power_user.multigen_next_chunks);
|
||||||
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
||||||
$("#play_sound_unfocused").prop("checked", power_user.play_sound_unfocused);
|
$("#play_sound_unfocused").prop("checked", power_user.play_sound_unfocused);
|
||||||
|
$("#auto_save_msg_edits").prop("checked", power_user.auto_save_msg_edits);
|
||||||
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
||||||
$(`input[name="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
$(`input[name="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
||||||
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
||||||
@ -573,6 +575,11 @@ $(document).ready(() => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#auto_save_msg_edits").on('input', function () {
|
||||||
|
power_user.auto_save_msg_edits = !!$(this).prop('checked');
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$("#character_sort_order").on('change', function () {
|
$("#character_sort_order").on('change', function () {
|
||||||
power_user.sort_field = $(this).find(":selected").data('field');
|
power_user.sort_field = $(this).find(":selected").data('field');
|
||||||
power_user.sort_order = $(this).find(":selected").data('order');
|
power_user.sort_order = $(this).find(":selected").data('order');
|
||||||
|
Reference in New Issue
Block a user