diff --git a/js/main.js b/js/main.js index c212943b..404fc3ac 100644 --- a/js/main.js +++ b/js/main.js @@ -796,7 +796,6 @@ createMobileTopBar(); //------------------------------------------------ // --- Message Versioning Variables --- -// let versioningSelectedMessageElement = null; // Deprecated due to persistent selection state let selectedMessageHistoryIndex = null; let selectedMessageType = null; @@ -856,7 +855,6 @@ function versioningSelectMessage(element, historyIndex, messageType) { versioningDeselectMessages(); if (element) { - // versioningSelectedMessageElement = element; selectedMessageHistoryIndex = historyIndex; selectedMessageType = messageType; element.classList.add('selected-message'); @@ -865,12 +863,9 @@ function versioningSelectMessage(element, historyIndex, messageType) { function versioningDeselectMessages() { const selectedMessageElement = gradioApp().querySelector('#chat .selected-message'); - // if (versioningSelectedMessageElement) { - // versioningSelectedMessageElement.classList.remove('selected-message'); if (selectedMessageElement) { selectedMessageElement.classList.remove('selected-message'); } - // versioningSelectedMessageElement = null; selectedMessageHistoryIndex = null; selectedMessageType = null; } diff --git a/modules/chat.py b/modules/chat.py index 97c41a9c..68f335ca 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -667,7 +667,6 @@ def generate_chat_reply_wrapper(text, state, regenerate=False, _continue=False): send_dummy_reply(state['start_with'], state) history = state['history'] - last_save_time = time.monotonic() save_interval = 8 for i, history in enumerate(generate_chat_reply(text, state, regenerate, _continue, loading_message=True, for_ui=True)): @@ -711,9 +710,8 @@ def send_last_reply_to_input(history): return '' -def replace_last_reply(textbox, state): +def replace_last_reply(text, state): history = state['history'] - text = textbox['text'] # Initialize metadata if not present if 'metadata' not in history: @@ -1321,7 +1319,6 @@ def my_yaml_output(data): def handle_replace_last_reply_click(text, state): - last_reply = state['history']['internal'][-1][1] if len(state['history']['internal']) > 0 else None history = replace_last_reply(text, state) save_history(history, state['unique_id'], state['character_menu'], state['mode']) html = redraw_html(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu']) @@ -1378,17 +1375,8 @@ def handle_start_new_chat_click(state): def handle_delete_chat_confirm_click(state): - unique_id_to_delete = state['unique_id'] - character_to_delete = state['character_menu'] - mode_to_delete = state['mode'] - all_histories = find_all_histories(state) - index = '0' - if unique_id_to_delete in all_histories: - index = str(all_histories.index(unique_id_to_delete)) - - delete_history(unique_id_to_delete, character_to_delete, mode_to_delete) - - # Load the next appropriate history + index = str(find_all_histories(state).index(state['unique_id'])) + delete_history(state['unique_id'], state['character_menu'], state['mode']) history, unique_id = load_history_after_deletion(state, index) html = redraw_html(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu']) diff --git a/modules/html_generator.py b/modules/html_generator.py index 9cf37804..665cb4de 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -425,7 +425,6 @@ def generate_instruct_html(history): selected_class = " selected-message" if message_versioning.is_message_selected(i, 0) else "" output += ( f'
' f'
' f'
{converted_visible[0]}
' @@ -483,7 +482,6 @@ def generate_cai_chat_html(history, name1, name2, style, character, reset_cache= selected_class = " selected-message" if message_versioning.is_message_selected(i, 0) else "" output += ( f'
' f'
{img_me}
' f'
' @@ -547,7 +545,6 @@ def generate_chat_html(history, name1, name2, reset_cache=False): selected_class = " selected-message" if message_versioning.is_message_selected(i, 0) else "" output += ( f'
' f'
' f'
{converted_visible[0]}
' diff --git a/modules/ui_chat.py b/modules/ui_chat.py index d218247d..b2bc8210 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -94,7 +94,7 @@ def create_ui(): with gr.Row(): shared.gradio['chat_style'] = gr.Dropdown(choices=utils.get_available_chat_styles(), label='Chat style', value=shared.settings['chat_style'], visible=shared.settings['mode'] != 'instruct') - with gr.Row(visible=True): # TODO: Make visible based on mode + with gr.Row(visible=True): shared.gradio['message_versioning_display_mode'] = gr.Radio(choices=['html', 'off'], value='html', label="Message Versioning Display", info="Controls how message version navigation is displayed.", elem_id="message-versioning-display-mode", elem_classes=['slim-dropdown']) with gr.Row():