mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/SillyLossy/TavernAI into dev
This commit is contained in:
@ -1277,6 +1277,9 @@
|
||||
<label for="auto-load-chat-checkbox"><input id="auto-load-chat-checkbox" type="checkbox" />
|
||||
Auto-load Last Chat
|
||||
</label>
|
||||
<label for="auto_save_msg_edits"><input id="auto_save_msg_edits" type="checkbox" />
|
||||
Auto-load Message Edits
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -203,10 +203,12 @@ let dialogueResolve = null;
|
||||
let chat_metadata = {};
|
||||
let streamingProcessor = null;
|
||||
|
||||
|
||||
const durationSaveEdit = 200;
|
||||
const saveSettingsDebounced = debounce(() => saveSettings(), durationSaveEdit);
|
||||
const saveCharacterDebounced = debounce(() => $("#create_button").click(), durationSaveEdit);
|
||||
const getStatusDebounced = debounce(() => getStatus(), 90000);
|
||||
const saveChatDebounced = debounce(() => saveChatConditional(), 1000);
|
||||
|
||||
const system_message_types = {
|
||||
HELP: "help",
|
||||
@ -2908,6 +2910,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) {
|
||||
let mesBlock = div.closest(".mes_block");
|
||||
var text = mesBlock.find(".edit_textarea").val().trim();
|
||||
@ -2924,7 +2942,9 @@ function messageEditDone(div) {
|
||||
mesBlock.find(".mes_text").empty();
|
||||
mesBlock.find(".mes_edit_buttons").css("display", "none");
|
||||
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").append(messageFormating(bias));
|
||||
appendImageToMessage(chat[this_edit_mes_id], div.closest(".mes"));
|
||||
@ -4251,6 +4271,7 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#talkativeness_slider").on("input", function () {
|
||||
if (menu_type == "create") {
|
||||
create_save_talkativeness = $("#talkativeness_slider").val();
|
||||
@ -4667,9 +4688,7 @@ $(document).ready(function () {
|
||||
.closest(".mes_block")
|
||||
.find(".mes_text")
|
||||
.append(
|
||||
'<textarea class=edit_textarea style="max-width:auto; ">' +
|
||||
text +
|
||||
"</textarea>"
|
||||
`<textarea id='curEditTextarea' class='edit_textarea' style='max-width:auto; '>${text}</textarea>`
|
||||
);
|
||||
let edit_textarea = $(this)
|
||||
.closest(".mes_block")
|
||||
@ -4688,6 +4707,13 @@ $(document).ready(function () {
|
||||
updateEditArrowClasses();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('input', '#curEditTextarea', function () {
|
||||
if (power_user.auto_save_msg_edits === true) {
|
||||
messageEditAuto($(this));
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on("click", ".mes_edit_cancel", function () {
|
||||
let text = chat[this_edit_mes_id]["mes"];
|
||||
|
||||
@ -5075,8 +5101,15 @@ $(document).ready(function () {
|
||||
|
||||
$(document).keyup(function (e) {
|
||||
if (e.key === "Escape") {
|
||||
closeMessageEditor();
|
||||
$("#send_textarea").focus();
|
||||
if (power_user.auto_save_msg_edits === false) {
|
||||
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 () {
|
||||
console.log("expression image loaded, now draggable.");
|
||||
|
||||
dragElement(document.getElementById("expression-holder"));
|
||||
}).catch(() => {
|
||||
console.log("expression holder not loaded yet");
|
||||
@ -591,13 +591,10 @@ $("document").ready(function () {
|
||||
var chatbarInFocus = false;
|
||||
$('#send_textarea').focus(function () {
|
||||
chatbarInFocus = true;
|
||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
||||
});
|
||||
|
||||
$('#send_textarea').blur(function () {
|
||||
|
||||
chatbarInFocus = false;
|
||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
||||
});
|
||||
|
||||
|
||||
@ -677,28 +674,11 @@ $("document").ready(function () {
|
||||
if (event.ctrlKey && event.key == "Enter") {
|
||||
// Ctrl+Enter for Regeneration Last Response
|
||||
if (is_send_press == false) {
|
||||
|
||||
$('#option_regenerate').click();
|
||||
$('#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
|
||||
CheckLocal();
|
||||
}
|
||||
|
@ -260,12 +260,12 @@ async function getExpressionsList() {
|
||||
console.log('getting expressions list');
|
||||
// get something for offline mode (default images)
|
||||
if (!modules.includes('classify')) {
|
||||
console.log('classify not available, loading default');
|
||||
|
||||
return DEFAULT_EXPRESSIONS;
|
||||
}
|
||||
|
||||
if (Array.isArray(expressionsList)) {
|
||||
console.log('got array, loading array');
|
||||
|
||||
return expressionsList;
|
||||
}
|
||||
|
||||
@ -273,21 +273,21 @@ async function getExpressionsList() {
|
||||
url.pathname = '/api/classify/labels';
|
||||
|
||||
try {
|
||||
console.log('trying for API');
|
||||
|
||||
const apiResult = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: { 'Bypass-Tunnel-Reminder': 'bypass' },
|
||||
});
|
||||
|
||||
if (apiResult.ok) {
|
||||
console.log('API ok, adding labels');
|
||||
|
||||
const data = await apiResult.json();
|
||||
expressionsList = data.labels;
|
||||
return expressionsList;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log('got error!');
|
||||
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
@ -313,7 +313,7 @@ async function setExpression(character, expression, force) {
|
||||
});
|
||||
} else {
|
||||
if (extension_settings.expressions.showDefault) {
|
||||
console.log('no character images, trying default expressions');
|
||||
|
||||
setDefault();
|
||||
}
|
||||
}
|
||||
@ -344,7 +344,7 @@ function onClickExpressionImage() {
|
||||
|
||||
(function () {
|
||||
function addExpressionImage() {
|
||||
console.log('entered addExpressionImage');
|
||||
|
||||
const html = `
|
||||
<div id="expression-holder" class="expression-holder" style="display:none;">
|
||||
<div id="expression-holderheader" class="fa-solid fa-grip drag-grabber"></div>
|
||||
@ -353,7 +353,7 @@ function onClickExpressionImage() {
|
||||
$('body').append(html);
|
||||
}
|
||||
function addSettings() {
|
||||
console.log('entered addSettings');
|
||||
|
||||
const html = `
|
||||
<div class="expression_settings">
|
||||
<div class="inline-drawer">
|
||||
|
@ -59,6 +59,7 @@ let power_user = {
|
||||
sheld_width: sheld_width.DEFAULT,
|
||||
play_message_sound: false,
|
||||
play_sound_unfocused: true,
|
||||
auto_save_msg_edits: false,
|
||||
sort_field: 'name',
|
||||
sort_order: 'asc',
|
||||
font_scale: 1,
|
||||
@ -307,6 +308,7 @@ function loadPowerUserSettings(settings, data) {
|
||||
$("#multigen_next_chunks").val(power_user.multigen_next_chunks);
|
||||
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
||||
$("#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="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
||||
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
||||
@ -573,6 +575,11 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#auto_save_msg_edits").on('input', function () {
|
||||
power_user.auto_save_msg_edits = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#character_sort_order").on('change', function () {
|
||||
power_user.sort_field = $(this).find(":selected").data('field');
|
||||
power_user.sort_order = $(this).find(":selected").data('order');
|
||||
|
Reference in New Issue
Block a user