mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Editor: Don't allow editing or syncing during generation
Only bad things can come from that! Also filter out stream buffer when fixing dirty game text (just in case!)
This commit is contained in:
@@ -85,6 +85,7 @@ var dirty_chunks = [];
|
||||
var initial_socketio_connection_occured = false;
|
||||
var selected_model_data;
|
||||
var privacy_mode_enabled = false;
|
||||
var ai_busy = false;
|
||||
|
||||
var streaming = {
|
||||
windowOpen: false,
|
||||
@@ -775,6 +776,11 @@ function update_status_bar(data) {
|
||||
}
|
||||
|
||||
function do_ai_busy(data) {
|
||||
console.log("AIBUSY", data.value)
|
||||
ai_busy = data.value;
|
||||
// Don't allow editing while Mr. Kobold is thinking
|
||||
document.getElementById("Selected Text").contentEditable = !ai_busy;
|
||||
|
||||
if (data.value) {
|
||||
ai_busy_start = Date.now();
|
||||
favicon.start_swap()
|
||||
@@ -3265,6 +3271,11 @@ function fix_dirty_game_text() {
|
||||
//This should get fired if we have deleted chunks or have added text outside of a node.
|
||||
//We wait until after the game text has lost focus to fix things otherwise it messes with typing
|
||||
var game_text = document.getElementById("Selected Text");
|
||||
|
||||
// Fix stray stream
|
||||
const streamBufferEl = document.getElementById("#token-stream-buffer");
|
||||
if (streamBufferEl) streamBufferEl.remove();
|
||||
|
||||
//Fix missing story prompt
|
||||
if (dirty_chunks.includes("-1")) {
|
||||
if (!document.getElementById("story_prompt")) {
|
||||
@@ -3277,6 +3288,7 @@ function fix_dirty_game_text() {
|
||||
game_text.prepend(story_prompt);
|
||||
}
|
||||
}
|
||||
|
||||
if (dirty_chunks.includes("game_text")) {
|
||||
dirty_chunks = dirty_chunks.filter(item => item != "game_text");
|
||||
console.log("Firing Fix messed up text");
|
||||
@@ -3312,7 +3324,7 @@ function fix_dirty_game_text() {
|
||||
|
||||
function savegametextchanges() {
|
||||
fix_dirty_game_text();
|
||||
for (item of document.getElementsByClassName("editing")) {
|
||||
for (const item of document.getElementsByClassName("editing")) {
|
||||
item.classList.remove("editing");
|
||||
}
|
||||
if (dirty_chunks.length > 0) {
|
||||
@@ -7632,3 +7644,31 @@ $el("#gamescreen").addEventListener("paste", function(event) {
|
||||
event.clipboardData.getData("text/plain")
|
||||
);
|
||||
});
|
||||
|
||||
const gameText = document.getElementById("Selected Text");
|
||||
gameText.addEventListener("click", function(event) {
|
||||
if (ai_busy) {
|
||||
event.stopPropagation();
|
||||
return;
|
||||
};
|
||||
|
||||
set_edit(event);
|
||||
});
|
||||
|
||||
gameText.addEventListener("focusout", function(event) {
|
||||
if (ai_busy) {
|
||||
event.stopPropagation();
|
||||
return;
|
||||
};
|
||||
|
||||
savegametextchanges();
|
||||
});
|
||||
|
||||
gameText.addEventListener("paste", function(event) {
|
||||
if (ai_busy) {
|
||||
event.stopPropagation();
|
||||
return;
|
||||
};
|
||||
|
||||
check_game_after_paste();
|
||||
});
|
@@ -53,7 +53,7 @@
|
||||
<div id="welcome_text" class="var_sync_model_welcome" draggable="False"></div>
|
||||
</div>
|
||||
|
||||
<div class="gametext" id="Selected Text" contenteditable=false tabindex=0 onpaste="check_game_after_paste()" onfocusout="savegametextchanges();" onclick="return set_edit(event)" onkeyup="return set_edit(event);">
|
||||
<div class="gametext" id="Selected Text" contenteditable="false" tabindex="0" onkeyup="return set_edit(event);">
|
||||
<span id="story_prompt" class="var_sync_story_prompt var_sync_alt_story_prompt_in_ai rawtext hidden" chunk="-1"></span></div><!--don't move the /div down or it'll cause odd spacing issues in the UI--->
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user