From e01a2c3bcf209f048a51a6dd716ab3a5892acf11 Mon Sep 17 00:00:00 2001 From: BlipRanger <1860540+BlipRanger@users.noreply.github.com> Date: Sat, 1 Jul 2023 18:32:51 -0400 Subject: [PATCH 01/12] Store metadata for swipes, pull it back --- public/script.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/public/script.js b/public/script.js index a9b5fd187..8f27c8ae7 100644 --- a/public/script.js +++ b/public/script.js @@ -1342,6 +1342,7 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').append(messageText); appendImageToMessage(mes, $("#chat").find(`[mesid="${count_view_mes - 1}"]`)); $("#chat").find(`[mesid="${count_view_mes - 1}"]`).attr('title', title); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.timestamp').text(timestamp); if (mes.swipe_id == mes.swipes.length - 1) { $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').text(params.timerValue); @@ -1758,6 +1759,7 @@ class StreamingProcessor { if (this.type == 'swipe' && Array.isArray(chat[messageId]['swipes'])) { chat[messageId]['swipes'][chat[messageId]['swipe_id']] = processedText; + chat[messageId]['swipe_info'][chat[messageId]['swipe_id']] = { 'send_date': chat[messageId]['send_date'], 'gen_started': chat[messageId]['gen_started'], 'gen_finished': chat[messageId]['gen_finished']}; } let formattedText = messageFormatting( @@ -1839,6 +1841,7 @@ class StreamingProcessor { if (this.type !== 'swipe' && this.type !== 'impersonate') { if (Array.isArray(chat[messageId]['swipes']) && chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { chat[messageId]['swipes'][0] = chat[messageId]['mes']; + chat[messageId]['swipe_info'][0] = [chat[messageId]['gen_started'], chat[messageId]['gen_finished']]; } } } @@ -3430,6 +3433,7 @@ function saveReply(type, getMessage, this_mes_is_name, title) { chat[chat.length - 1]['mes'] = getMessage; chat[chat.length - 1]['gen_started'] = generation_started; chat[chat.length - 1]['gen_finished'] = generationFinished; + chat[chat.length - 1]['send_date'] = getMessageTimeStamp(); addOneMessage(chat[chat.length - 1], { type: 'swipe' }); } else { chat[chat.length - 1]['mes'] = getMessage; @@ -3440,6 +3444,7 @@ function saveReply(type, getMessage, this_mes_is_name, title) { chat[chat.length - 1]['mes'] += getMessage; chat[chat.length - 1]['gen_started'] = generation_started; chat[chat.length - 1]['gen_finished'] = generationFinished; + chat[chat.length - 1]['send_date'] = getMessageTimeStamp(); addOneMessage(chat[chat.length - 1], { type: 'swipe' }); } else if (type === 'appendFinal') { console.debug("Trying to appendFinal.") @@ -3447,6 +3452,7 @@ function saveReply(type, getMessage, this_mes_is_name, title) { chat[chat.length - 1]['mes'] = getMessage; chat[chat.length - 1]['gen_started'] = generation_started; chat[chat.length - 1]['gen_finished'] = generationFinished; + chat[chat.length - 1]['send_date'] = getMessageTimeStamp(); addOneMessage(chat[chat.length - 1], { type: 'swipe' }); } else { @@ -3478,16 +3484,19 @@ function saveReply(type, getMessage, this_mes_is_name, title) { saveImageToMessage(img, chat[chat.length - 1]); addOneMessage(chat[chat.length - 1]); } - const item = chat[chat.length - 1]; + if(item['swipe_info'] === undefined) { + item['swipe_info'] = []; + } if (item['swipe_id'] !== undefined) { item['swipes'][item['swipes'].length - 1] = item['mes']; + item['swipe_info'][item['swipes'].length - 1] = { 'send_date': item['send_date'], 'gen_started': item['gen_started'], 'gen_finished': item['gen_finished']}; } else { item['swipe_id'] = 0; item['swipes'] = []; item['swipes'][0] = chat[chat.length - 1]['mes']; + item['swipe_info'][0] = { 'send_date': chat[chat.length - 1]['send_date'], 'gen_started': chat[chat.length - 1]['gen_started'], 'gen_finished': chat[chat.length - 1]['gen_finished'] }; } - return { type, getMessage }; } @@ -5942,6 +5951,8 @@ function swipe_left() { // when we swipe left..but no generation. this_mes_div.css('height', this_mes_div_height); const this_mes_block_height = this_mes_block[0].scrollHeight; chat[chat.length - 1]['mes'] = chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipe_id']]; + chat[chat.length - 1]['send_date'] = chat[chat.length - 1]['swipe_info'][chat[chat.length - 1]['swipe_id']]['send_date']; //load the last mes box with the latest generation + if (chat[chat.length - 1].extra) { // if message has memory attached - remove it to allow regen if (chat[chat.length - 1].extra.memory) { @@ -6054,7 +6065,9 @@ const swipe_right = () => { if (chat[chat.length - 1]['swipe_id'] === undefined) { // if there is no swipe-message in the last spot of the chat array chat[chat.length - 1]['swipe_id'] = 0; // set it to id 0 chat[chat.length - 1]['swipes'] = []; // empty the array + chat[chat.length - 1]['swipe_info'] = []; chat[chat.length - 1]['swipes'][0] = chat[chat.length - 1]['mes']; //assign swipe array with last message from chat + chat[chat.length - 1]['swipe_info'][0] = [chat[chat.length - 1]['gen_started'], chat[chat.length - 1]['gen_finished']]; //assign swipe info array with last message from chat } chat[chat.length - 1]['swipe_id']++; //make new slot in array if (chat[chat.length - 1].extra) { @@ -6074,6 +6087,7 @@ const swipe_right = () => { run_generate = true; } else if (parseInt(chat[chat.length - 1]['swipe_id']) < chat[chat.length - 1]['swipes'].length) { //otherwise, if the id is less than the number of swipes chat[chat.length - 1]['mes'] = chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipe_id']]; //load the last mes box with the latest generation + chat[chat.length - 1]['send_date'] = chat[chat.length - 1]['swipe_info'][chat[chat.length - 1]['swipe_id']]['send_date']; //update send date run_swipe_right = true; //then prepare to do normal right swipe to show next message } @@ -6123,7 +6137,8 @@ const swipe_right = () => { /* } */ } else { //console.log('showing previously generated swipe candidate, or "..."'); - //console.log('onclick right swipe calling addOneMessage'); + console.log('onclick right swipe calling addOneMessage'); + console.log(chat); addOneMessage(chat[chat.length - 1], { type: 'swipe' }); } let new_height = this_mes_div_height - (this_mes_block_height - this_mes_block[0].scrollHeight); From 715a6f1bfff174cacf8299c32614ed23e9dbdec7 Mon Sep 17 00:00:00 2001 From: BlipRanger <1860540+BlipRanger@users.noreply.github.com> Date: Sat, 1 Jul 2023 18:35:47 -0400 Subject: [PATCH 02/12] Cleanup --- public/script.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index 8f27c8ae7..ace486c83 100644 --- a/public/script.js +++ b/public/script.js @@ -1841,7 +1841,7 @@ class StreamingProcessor { if (this.type !== 'swipe' && this.type !== 'impersonate') { if (Array.isArray(chat[messageId]['swipes']) && chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { chat[messageId]['swipes'][0] = chat[messageId]['mes']; - chat[messageId]['swipe_info'][0] = [chat[messageId]['gen_started'], chat[messageId]['gen_finished']]; + chat[messageId]['swipe_info'][0] = { 'send_date': chat[messageId]['send_date'], 'gen_started': chat[messageId]['gen_started'], 'gen_finished': chat[messageId]['gen_finished'] }; } } } @@ -6067,7 +6067,7 @@ const swipe_right = () => { chat[chat.length - 1]['swipes'] = []; // empty the array chat[chat.length - 1]['swipe_info'] = []; chat[chat.length - 1]['swipes'][0] = chat[chat.length - 1]['mes']; //assign swipe array with last message from chat - chat[chat.length - 1]['swipe_info'][0] = [chat[chat.length - 1]['gen_started'], chat[chat.length - 1]['gen_finished']]; //assign swipe info array with last message from chat + chat[chat.length - 1]['swipe_info'][0] = { 'send_date': chat[chat.length - 1]['send_date'], 'gen_started': chat[chat.length - 1]['gen_started'], 'gen_finished': chat[chat.length - 1]['gen_finished'] }; //assign swipe info array with last message from chat } chat[chat.length - 1]['swipe_id']++; //make new slot in array if (chat[chat.length - 1].extra) { @@ -6137,8 +6137,7 @@ const swipe_right = () => { /* } */ } else { //console.log('showing previously generated swipe candidate, or "..."'); - console.log('onclick right swipe calling addOneMessage'); - console.log(chat); + //console.log('onclick right swipe calling addOneMessage'); addOneMessage(chat[chat.length - 1], { type: 'swipe' }); } let new_height = this_mes_div_height - (this_mes_block_height - this_mes_block[0].scrollHeight); From 0c3f3f952d3d45defe6f43080055c694d110472c Mon Sep 17 00:00:00 2001 From: Cohee Date: Sun, 2 Jul 2023 23:47:33 +0300 Subject: [PATCH 03/12] Toggle for space trimming --- public/index.html | 4 ++++ public/script.js | 25 ++++++++++++++++++++----- public/scripts/power-user.js | 8 ++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 611640279..79df2c168 100644 --- a/public/index.html +++ b/public/index.html @@ -1689,6 +1689,10 @@ Disable chat start formatting +