diff --git a/gensettings.py b/gensettings.py index 498d44e0..2367c16b 100644 --- a/gensettings.py +++ b/gensettings.py @@ -618,7 +618,7 @@ gensettingstf = [ "label": "Chat Style", "id": "chat_style", "default": 0, - "tooltip": "How to represent chat messages in the UI", + "tooltip": "How chat messages are shown", "menu_path": "Interface", "sub_path": "UI", "classname": "story", diff --git a/static/koboldai.js b/static/koboldai.js index 932400c9..cdbe5baa 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -5943,9 +5943,6 @@ function deleteChatPromptIfEmpty() { prompt.remove(); } -// Initial message -//addMessage(null, null, -1); - function computeChatGametext(actionId) { // TODO: Customizable format? let lines = []; @@ -5962,6 +5959,8 @@ function computeChatGametext(actionId) { } function updateChatStyle() { + const storyArea = document.getElementById("Selected Text"); + if (chat.useV2) { // Already bubbles, do nothing if (document.getElementsByClassName("chat-message").length) { @@ -5969,6 +5968,12 @@ function updateChatStyle() { return; } + // Delete normal text + + for (const child of storyArea.children) { + child.remove(); + } + let addedMessages = 0; for (const [chunkId, chunk] of Object.entries(actions_data)) { @@ -5983,11 +5988,29 @@ function updateChatStyle() { } else { console.info("TODO: Convert 2 text") - if (!document.getElementsByClassName("chat-message").length) { - console.info("Already text, do nothing") - return; + if (!storyArea.children.length) { + for (const [chunkId, action] of Object.entries(actions_data)) { + let item = document.createElement("span"); + item.id = 'Selected Text Chunk '+chunkId; + item.classList.add("rawtext"); + item.setAttribute("chunk", chunkId); + //need to find the closest element + next_id = chunkId+1; + if (Math.max.apply(null,Object.keys(actions_data).map(Number)) <= next_id) { + storyArea.append(item); + } else { + storyArea.prepend(item); + } + + chunk_element = document.createElement("span"); + chunk_element.textContent = action['Selected Text']; + item.append(chunk_element); + + item.original_text = action['Selected Text']; + } } - $(".chat-message").remove(); + const jQCM = $(".chat-message"); + if (jQCM.length) jQCM.remove(); } } \ No newline at end of file