From 8447ec44ab9d0b6ff6e24c5f529a0f2d979c9294 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 19:00:23 -0400 Subject: [PATCH 1/8] Fix world info screen and bump application.js version --- static/application.js | 2 ++ static/custom.css | 5 +++++ templates/index.html | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/static/application.js b/static/application.js index f8692b7e..c7290052 100644 --- a/static/application.js +++ b/static/application.js @@ -466,6 +466,7 @@ function enterWiMode() { hide([button_actback, button_actmem, button_actretry, game_text]); show([wi_menu]); disableSendBtn(); + $("#gamescreen").addClass("wigamescreen"); } function exitWiMode() { @@ -474,6 +475,7 @@ function exitWiMode() { hide([wi_menu]); show([button_actback, button_actmem, button_actretry, game_text]); enableSendBtn(); + $("#gamescreen").removeClass("wigamescreen"); scrollToBottom(); } diff --git a/static/custom.css b/static/custom.css index fa9be0b4..2d12c00c 100644 --- a/static/custom.css +++ b/static/custom.css @@ -77,6 +77,11 @@ chunk.editing, chunk.editing * { font-family: "Helvetica"; } +#gamescreen.wigamescreen { + padding: 10px; + overflow-y: scroll; +} + #gamescreen span { align-self: flex-end; } diff --git a/templates/index.html b/templates/index.html index fbb90294..01ec91cf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,14 +6,14 @@ - + - + From 4961273a26447e7d7c4d236d0429bf385830bf6d Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 19:03:43 -0400 Subject: [PATCH 2/8] Don't scroll to the bottom of screen when exiting world info One of my earlier commits apparently removed the need for this. --- static/application.js | 1 - templates/index.html | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/static/application.js b/static/application.js index c7290052..04ca8cb9 100644 --- a/static/application.js +++ b/static/application.js @@ -476,7 +476,6 @@ function exitWiMode() { show([button_actback, button_actmem, button_actretry, game_text]); enableSendBtn(); $("#gamescreen").removeClass("wigamescreen"); - scrollToBottom(); } function returnWiList(ar) { diff --git a/templates/index.html b/templates/index.html index 01ec91cf..e8bfdb7a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,7 +6,7 @@ - + From 9ab1d182ac8a5299a143f3327a302d43792bc070 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 19:48:43 -0400 Subject: [PATCH 3/8] Guard against empty prompts --- aiserver.py | 28 ++++++++++++++++++++++++---- static/application.js | 8 ++++++-- templates/index.html | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/aiserver.py b/aiserver.py index 765727f4..f8f5648a 100644 --- a/aiserver.py +++ b/aiserver.py @@ -951,6 +951,9 @@ def actionsubmit(data, actionmode=0): vars.lastact = data if(not vars.gamestarted): + if(len(data.strip()) == 0): + set_aibusy(0) + return # Start the game vars.gamestarted = True # Save this first action as the prompt @@ -971,7 +974,10 @@ def actionsubmit(data, actionmode=0): if(vars.actionmode == 0): data = applyinputformatting(data) # Store the result in the Action log - vars.actions.append(data) + if(len(vars.prompt.strip()) == 0): + vars.prompt = data + else: + vars.actions.append(data) update_story_chunk('last') if(not vars.noai): @@ -1284,7 +1290,10 @@ def genresult(genout): genout = applyoutputformatting(genout) # Add formatted text to Actions array and refresh the game screen - vars.actions.append(genout) + if(len(vars.prompt.strip()) == 0): + vars.prompt = genout + else: + vars.actions.append(genout) update_story_chunk('last') emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True) @@ -2102,8 +2111,19 @@ def loadRequest(loadpath): del vars.actions vars.actions = structures.KoboldStoryRegister() - for s in js["actions"]: - vars.actions.append(s) + actions = collections.deque(js["actions"]) + + if(len(vars.prompt.strip()) == 0): + while(len(actions)): + action = actions.popleft() + if(len(action.strip()) != 0): + vars.prompt = action + break + else: + vars.gamestarted = False + if(vars.gamestarted): + for s in actions: + vars.actions.append(s) # Try not to break older save files if("authorsnote" in js): diff --git a/static/application.js b/static/application.js index 04ca8cb9..17076459 100644 --- a/static/application.js +++ b/static/application.js @@ -494,7 +494,11 @@ function returnWiList(ar) { } function dosubmit() { - var txt = input_text.val(); + var txt = input_text.val().replace(/\u00a0/g, " "); + console.log(gamestarted) + if(!gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) { + return; + } socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'data': txt}); if(memorymode) { memorytext = input_text.val(); @@ -882,7 +886,7 @@ function syncAllModifiedChunks(including_selected_chunks=false) { } function restorePrompt() { - if(game_text[0].firstChild.nodeType === 3) { + if(game_text[0].firstChild && game_text[0].firstChild.nodeType === 3) { saved_prompt = game_text[0].firstChild.textContent.replace(/\u00a0/g, " "); unbindGametext(); game_text[0].innerText = ""; diff --git a/templates/index.html b/templates/index.html index e8bfdb7a..95f3c31f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,7 +6,7 @@ - + From af93c96c0f5c57b4f877a7256b4b73873d432013 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 19:50:00 -0400 Subject: [PATCH 4/8] Submit Action mode action in Story mode if action is empty --- aiserver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index f8f5648a..f8a3269b 100644 --- a/aiserver.py +++ b/aiserver.py @@ -944,7 +944,8 @@ def actionsubmit(data, actionmode=0): if(actionmode == 1): data = data.strip().lstrip('>') data = re.sub(r'\n+', ' ', data) - data = f"\n\n> {data}\n" + if(len(data)): + data = f"\n\n> {data}\n" # If we're not continuing, store a copy of the raw input if(data != ""): From 2b89bcb16efed0c21ef49c33dd4fca102a72f4eb Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 21:04:26 -0400 Subject: [PATCH 5/8] Fix random story generator --- aiserver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index f8a3269b..a11d04ea 100644 --- a/aiserver.py +++ b/aiserver.py @@ -930,7 +930,7 @@ def settingschanged(): #==================================================================# # Take input text from SocketIO and decide what to do with it #==================================================================# -def actionsubmit(data, actionmode=0): +def actionsubmit(data, actionmode=0, force_submit=False): # Ignore new submissions if the AI is currently busy if(vars.aibusy): return @@ -952,7 +952,7 @@ def actionsubmit(data, actionmode=0): vars.lastact = data if(not vars.gamestarted): - if(len(data.strip()) == 0): + if(not force_submit and len(data.strip()) == 0): set_aibusy(0) return # Start the game @@ -2398,7 +2398,7 @@ def newGameRequest(): def randomGameRequest(topic): newGameRequest() vars.memory = "You generate the following " + topic + " story concept :" - actionsubmit("") + actionsubmit("", force_submit=True) vars.memory = "" #==================================================================# From bb323152d73d17d2ef48f46b11ecf7d1484d90e2 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 21:24:08 -0400 Subject: [PATCH 6/8] Disable vars.recentedit again --- aiserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index a11d04ea..3175058b 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1001,7 +1001,7 @@ def actionretry(data): # Remove last action if possible and resubmit if(vars.gamestarted if vars.useprompt else len(vars.actions) > 0): set_aibusy(1) - if(not vars.recentback and not vars.recentedit and len(vars.actions) != 0 and len(vars.genseqs) == 0): # Don't pop if we're in the "Select sequence to keep" menu or if there are no non-prompt actions + if(not vars.recentback and len(vars.actions) != 0 and len(vars.genseqs) == 0): # Don't pop if we're in the "Select sequence to keep" menu or if there are no non-prompt actions last_key = vars.actions.get_last_key() vars.actions.pop() remove_story_chunk(last_key + 1) From e6cd28243e77eb0aeab7b5d077d146ce5d04e0cc Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 21:34:36 -0400 Subject: [PATCH 7/8] Scroll to the bottom of the gamescreen after retrying --- aiserver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aiserver.py b/aiserver.py index 3175058b..603ef0e7 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1007,6 +1007,7 @@ def actionretry(data): remove_story_chunk(last_key + 1) vars.genseqs = [] calcsubmit('') + emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True) vars.recentback = False vars.recentedit = False elif(not vars.useprompt): From a179bb2820f2d76608482e6daf44f4c3828eb931 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Tue, 28 Sep 2021 21:50:33 -0400 Subject: [PATCH 8/8] Bump version number to 1.16.2 --- aiserver.py | 2 +- templates/index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index 603ef0e7..567be4d0 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1,6 +1,6 @@ #==================================================================# # KoboldAI -# Version: 1.16.1 +# Version: 1.16.2 # By: KoboldAIDev and the KoboldAI Community #==================================================================# diff --git a/templates/index.html b/templates/index.html index 95f3c31f..8e3558b9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,14 +6,14 @@ - + - +