Merge branch 'staging' into integrity

This commit is contained in:
Cohee
2025-03-18 01:51:07 +02:00
38 changed files with 631 additions and 133 deletions

View File

@ -1144,7 +1144,7 @@ export async function clearItemizedPrompts() {
async function getStatusHorde() {
try {
const hordeStatus = await checkHordeStatus();
setOnlineStatus(hordeStatus ? 'Connected' : 'no_connection');
setOnlineStatus(hordeStatus ? t`Connected` : 'no_connection');
}
catch {
setOnlineStatus('no_connection');
@ -1211,7 +1211,7 @@ async function getStatusTextgen() {
}
if ([textgen_types.GENERIC, textgen_types.OOBA].includes(textgen_settings.type) && textgen_settings.bypass_status_check) {
setOnlineStatus('Status check bypassed');
setOnlineStatus(t`Status check bypassed`);
return resultCheckStatus();
}
@ -1236,7 +1236,7 @@ async function getStatusTextgen() {
setOnlineStatus(textgen_settings.togetherai_model);
} else if (textgen_settings.type === textgen_types.OLLAMA) {
loadOllamaModels(data?.data);
setOnlineStatus(textgen_settings.ollama_model || 'Connected');
setOnlineStatus(textgen_settings.ollama_model || t`Connected`);
} else if (textgen_settings.type === textgen_types.INFERMATICAI) {
loadInfermaticAIModels(data?.data);
setOnlineStatus(textgen_settings.infermaticai_model);
@ -1260,7 +1260,7 @@ async function getStatusTextgen() {
setOnlineStatus(textgen_settings.tabby_model || data?.result);
} else if (textgen_settings.type === textgen_types.GENERIC) {
loadGenericModels(data?.data);
setOnlineStatus(textgen_settings.generic_model || data?.result || 'Connected');
setOnlineStatus(textgen_settings.generic_model || data?.result || t`Connected`);
} else {
setOnlineStatus(data?.result);
}
@ -6277,7 +6277,6 @@ export function syncMesToSwipe(messageId = null) {
}
const targetMessage = chat[targetMessageId];
if (!targetMessage) {
return false;
}
@ -6310,6 +6309,68 @@ export function syncMesToSwipe(messageId = null) {
return true;
}
/**
* Syncs swipe data back to the message data at the given message ID (or the last message if no ID is given).
* If the swipe ID is not provided, the current swipe ID in the message object is used.
*
* If the swipe data is invalid in some way, this function will exit out without doing anything.
* @param {number?} [messageId=null] - The ID of the message to sync with the swipe data. If no ID is given, the last message is used.
* @param {number?} [swipeId=null] - The ID of the swipe to sync. If no ID is given, the current swipe ID in the message object is used.
* @returns {boolean} Whether the swipe data was successfully synced to the message
*/
export function syncSwipeToMes(messageId = null, swipeId = null) {
if (!chat.length) {
return false;
}
const targetMessageId = messageId ?? chat.length - 1;
if (targetMessageId >= chat.length || targetMessageId < 0) {
console.warn(`[syncSwipeToMes] Invalid message ID: ${messageId}`);
return false;
}
const targetMessage = chat[targetMessageId];
if (!targetMessage) {
return false;
}
if (swipeId !== null) {
if (isNaN(swipeId) || swipeId < 0) {
console.warn(`[syncSwipeToMes] Invalid swipe ID: ${swipeId}`);
return false;
}
targetMessage.swipe_id = swipeId;
}
// No swipe data there yet, exit out
if (typeof targetMessage.swipe_id !== 'number') {
return false;
}
// If swipes structure is invalid, exit out
if (!Array.isArray(targetMessage.swipe_info) || !Array.isArray(targetMessage.swipes)) {
return false;
}
const targetSwipeId = targetMessage.swipe_id;
if (!targetMessage.swipes[targetSwipeId] || !targetMessage.swipe_info[targetSwipeId]) {
console.warn(`[syncSwipeToMes] Invalid swipe ID: ${targetSwipeId}`);
return false;
}
const targetSwipeInfo = targetMessage.swipe_info[targetSwipeId];
if (typeof targetSwipeInfo !== 'object') {
return false;
}
targetMessage.mes = targetMessage.swipes[targetSwipeId];
targetMessage.send_date = targetSwipeInfo.send_date;
targetMessage.gen_started = targetSwipeInfo.gen_started;
targetMessage.gen_finished = targetSwipeInfo.gen_finished;
targetMessage.extra = structuredClone(targetSwipeInfo.extra);
return true;
}
/**
* Saves the image to the message object.
* @param {ParsedImage} img Image object
@ -8342,10 +8403,9 @@ export async function deleteSwipe(swipeId = null) {
lastMessage.swipe_info.splice(swipeId, 1);
}
// Select the next swip, or the one before if it was the last one
// Select the next swipe, or the one before if it was the last one
const newSwipeId = Math.min(swipeId, lastMessage.swipes.length - 1);
lastMessage.swipe_id = newSwipeId;
lastMessage.mes = lastMessage.swipes[newSwipeId];
syncSwipeToMes(null, newSwipeId);
await saveChatConditional();
await reloadCurrentChat();
@ -10477,7 +10537,7 @@ jQuery(async function () {
e.stopPropagation();
chat_file_for_del = $(this).attr('file_name');
console.debug('detected cross click for' + chat_file_for_del);
callPopup('<h3>Delete the Chat File?</h3>', 'del_chat');
callPopup('<h3>' + t`Delete the Chat File?` + '</h3>', 'del_chat');
});
$('#advanced_div').click(function () {