From 3f20e884b5cc75ef6dc336998b26bc64c994a9a6 Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 8 Sep 2023 14:28:35 -0400 Subject: [PATCH 1/3] Added password transmit block when on --host mode --- aiserver.py | 3 ++- koboldai_settings.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index ae9b1f67..c8d0d1f0 100644 --- a/aiserver.py +++ b/aiserver.py @@ -657,6 +657,7 @@ logger.add(UI_2_log_history, serialize=True, colorize=True, enqueue=True, level= #logger.add("log_file_1.log", rotation="500 MB") # Automatically rotate too big file koboldai_vars = koboldai_settings.koboldai_vars(socketio) +koboldai_settings.koboldai_vars_main = koboldai_vars utils.koboldai_vars = koboldai_vars utils.socketio = socketio @@ -7992,7 +7993,7 @@ def model_info(): @require_allowed_ip @logger.catch def show_vars(): - if args.no_ui: + if args.no_ui or koboldai_vars.host: return redirect('/api/latest') json_data = {} json_data['story_settings'] = json.loads(koboldai_vars.to_json("story_settings")) diff --git a/koboldai_settings.py b/koboldai_settings.py index f447f3ee..38570783 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -37,12 +37,12 @@ def clean_var_for_emit(value): return value def process_variable_changes(socketio, classname, name, value, old_value, debug_message=None): - global multi_story + global multi_story, koboldai_vars_main if serverstarted and name != "serverstarted": transmit_time = str(datetime.datetime.now()) if debug_message is not None: print("{} {}: {} changed from {} to {}".format(debug_message, classname, name, old_value, value)) - if value != old_value: + if value != old_value and (not koboldai_vars_main.host or name not in ["horde_api_key", "privacy_password", "img_gen_api_password"]): #Get which room we'll send the messages to if multi_story: if classname != 'story': From 37a419d8d0d62438c19fad636765c8d641af07d0 Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 8 Sep 2023 20:43:29 -0400 Subject: [PATCH 2/3] Changed password variables to transmit **** (length = length of text) if --host is on --- koboldai_settings.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index 38570783..8d3c0838 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -25,6 +25,8 @@ enable_whitelist = False if importlib.util.find_spec("tortoise") is not None: from tortoise import api from tortoise.utils.audio import load_voices + +password_vars = ["horde_api_key", "privacy_password", "img_gen_api_password"] def clean_var_for_emit(value): if isinstance(value, KoboldStoryRegister) or isinstance(value, KoboldWorldInfo): @@ -42,7 +44,7 @@ def process_variable_changes(socketio, classname, name, value, old_value, debug_ transmit_time = str(datetime.datetime.now()) if debug_message is not None: print("{} {}: {} changed from {} to {}".format(debug_message, classname, name, old_value, value)) - if value != old_value and (not koboldai_vars_main.host or name not in ["horde_api_key", "privacy_password", "img_gen_api_password"]): + if value != old_value: #Get which room we'll send the messages to if multi_story: if classname != 'story': @@ -83,14 +85,20 @@ def process_variable_changes(socketio, classname, name, value, old_value, debug_ else: #If we got a variable change from a thread other than what the app is run it, eventlet seems to block and no further messages are sent. Instead, we'll rely the message to the app and have the main thread send it if not has_request_context(): - data = ["var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}] + if not koboldai_vars_main.host or name not in password_vars: + data = ["var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}] + else: + data = ["var_changed", {"classname": classname, "name": name, "old_value": "*" * len(old_value) if old_value is not None else "", "value": "*" * len(value) if value is not None else "", "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}] if queue is not None: #logger.debug("Had to use queue") queue.put(data) else: if socketio is not None: - socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room) + if not koboldai_vars_main.host or name not in password_vars: + socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room) + else: + socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": "*" * len(old_value) if old_value is not None else "", "value": "*" * len(value) if value is not None else "", "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room) class koboldai_vars(object): def __init__(self, socketio): From b46d5ad2c4c627ee034b672faecf4e883db3eddd Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 8 Sep 2023 20:59:40 -0400 Subject: [PATCH 3/3] Fix for mobile close box overlaps --- static/koboldai.css | 8 ++++++++ static/koboldai.js | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/static/koboldai.css b/static/koboldai.css index 9aca6da1..a419a4f3 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -906,6 +906,10 @@ border-top-right-radius: var(--tabs_rounding); grid-area: lefticon; } +.high_z.right_menu_icon { + z-index: 51; +} + @media only screen and (max-aspect-ratio: 5/6) { /* mobile */ .right_menu_icon.hidden { @@ -932,6 +936,10 @@ border-top-right-radius: var(--tabs_rounding); will-change: transform; } +.high_z.rightSideMenu { + z-index: 50; +} + .rightSideMenu.open { left: calc(100% - var(--flyout_menu_width)); } diff --git a/static/koboldai.js b/static/koboldai.js index b2a5f0ed..038b6e87 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -4963,11 +4963,17 @@ function toggle_flyout_right(x) { x.classList.remove("change"); document.getElementById("rightSideMenu").classList.remove("open"); document.getElementById("main-grid").classList.remove("story_menu-open"); + //need to set the layer priority back down + document.getElementById("rightSideMenu").classList.remove("high_z"); + document.getElementById("story_menu_icon").classList.remove("high_z"); } else { x.classList.add("change"); document.getElementById("rightSideMenu").classList.add("open"); document.getElementById("main-grid").classList.add("story_menu-open"); document.getElementById("story_menu_pin").classList.remove("hidden"); + //need to set the layer priority up (due to mobile overlap + document.getElementById("rightSideMenu").classList.add("high_z"); + document.getElementById("story_menu_icon").classList.add("high_z"); } }