diff --git a/aiserver.py b/aiserver.py index a94e7ba6..4805515c 100644 --- a/aiserver.py +++ b/aiserver.py @@ -4083,9 +4083,12 @@ def execute_outmod(): #==================================================================# @socketio.on('connect') def do_connect(): - logger.info("Client connected! UI_{}".format(request.args.get('ui'))) if request.args.get("rely") == "true": return + logger.info("Client connected! UI_{}".format(request.args.get('ui'))) + #If this we have a message to send to the users and they haven't seen it we'll transmit it now + eventlet.spawn(send_one_time_messages, '', wait_time=1) + join_room("UI_{}".format(request.args.get('ui'))) if 'story' not in session: session['story'] = 'default' @@ -10177,6 +10180,30 @@ def UI_2_action_image(): mimetype="image/jpeg") else: return None + +#==================================================================# +# display messages if they have never been sent before on this install +#==================================================================# +@logger.catch +@socketio.on("check_messages") +def send_one_time_messages(data, wait_time=0): + time.sleep(wait_time) #Need to wait a bit for the web page to load as the connect event is very eary + messages = { + 1: {"id": 1, "title": "Warning New Save Format", "message": "This version of KoboldAI includes a new save game format which is incompatable with older versions of KoboldAI. Your old saves will not be modified and can be loaded on older versions but if you save and new actions taken will not be visible on older versions"}, + } + if data != '': + koboldai_vars.seen_messages.append(int(data)) + #Now let's save + filename = "settings/system_settings.v2_settings" + if not os.path.exists("settings"): + os.mkdir("settings") + with open(filename, "w") as settings_file: + settings_file.write(getattr(koboldai_vars, "_system_settings").to_json()) + for message in messages: + if message not in koboldai_vars.seen_messages: + socketio.emit("message", messages[message]) + break + #==================================================================# # Test #==================================================================# diff --git a/koboldai_settings.py b/koboldai_settings.py index d2eee277..c011eb30 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1280,6 +1280,7 @@ class system_settings(settings): elif torch.cuda.get_device_properties(device).major == 7 and torch.cuda.get_device_properties(device).minor >= 2: self.bit_8_available = True break + self.seen_messages = [] @dataclass diff --git a/static/koboldai.js b/static/koboldai.js index be6fe1eb..3021397b 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -26,6 +26,7 @@ socket.on("delete_new_world_info_entry", function(data){document.getElementById( socket.on("delete_world_info_entry", function(data){document.getElementById("world_info_"+data).remove();}); socket.on("delete_world_info_folder", function(data){document.getElementById("world_info_folder_"+data).remove();}); socket.on("error", function(data){show_error_message(data);}); +socket.on("message", function(data){show_message(data);}); socket.on('load_cookies', function(data){load_cookies(data);}); socket.on('load_tweaks', function(data){load_tweaks(data);}); socket.on("wi_results", updateWISearchListings); @@ -2584,23 +2585,38 @@ function world_info_folder(data) { } function show_error_message(data) { - const error_box_data = $el("#error-popup").querySelector("#popup_list_area") + const error_box_data = $el("#error-popup").querySelector("#popup_list_area"); //clear out the error box while (error_box_data.firstChild) { error_box_data.removeChild(error_box_data.firstChild); } if (Array.isArray(data)) { for (item of data) { - $e("div", error_box_data, {'innerHTML': item, 'classes': ['console_text']}) - $e("br", error_box_data) + $e("div", error_box_data, {'innerHTML': item, 'classes': ['console_text']}); + $e("br", error_box_data); } } else { //console.log(item); - $e("div", error_box_data, {'innerHTML': data, 'classes': ['console_text']}) + $e("div", error_box_data, {'innerHTML': data, 'classes': ['console_text']}); } openPopup("error-popup"); } +function show_message(data) { + const message_box_data = $el("#message-popup").querySelector("#popup_list_area"); + const message_box_title = $el("#message-popup").querySelector("#popup_title"); + const message_box_ok = $el("#message-popup").querySelector("#ok"); + //clear out the error box + while (message_box_data.firstChild) { + message_box_data.removeChild(message_box_data.firstChild); + } + $e("div", message_box_data, {'innerHTML': data['message'], 'classes': ['console_text']}) + message_box_title.innerText = data['title']; + message_box_ok.setAttribute("message_id", data['id']) + + openPopup("message-popup"); +} + function do_wpp(wpp_area) { wpp = {}; wpp['attributes'] = {}; diff --git a/templates/popups.html b/templates/popups.html index 43770103..4621a281 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -160,6 +160,21 @@ + + +