()
| 97 | } |
| 98 | |
| 99 | export async function sendMessage() { |
| 100 | const input = document.getElementById("user-input"); |
| 101 | const text = input.value.trim(); |
| 102 | if (!text) return; |
| 103 | |
| 104 | const chatArea = document.getElementById("chat-area"); |
| 105 | if (chatArea.classList.contains("mode-welcome")) { |
| 106 | chatArea.classList.remove("mode-welcome"); |
| 107 | chatArea.classList.add("mode-chat"); |
| 108 | } |
| 109 | |
| 110 | input.value = ""; |
| 111 | input.style.height = "auto"; |
| 112 | |
| 113 | appendMessage("user", text); |
| 114 | chatHistory.push({ role: "user", content: text }); |
| 115 | |
| 116 | const sendBtn = document.getElementById("send-btn"); |
| 117 | sendBtn.disabled = true; |
| 118 | |
| 119 | currentAssistantMsg = appendMessage("assistant", ""); |
| 120 | showLoadingIndicator(); |
| 121 | |
| 122 | try { |
| 123 | const socket = await getOrCreateWs(); |
| 124 | socket.send(JSON.stringify({ text })); |
| 125 | } catch (err) { |
| 126 | handleError(err.message); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | export async function sendBotCommand(cmdText) { |
| 131 | const chatArea = document.getElementById("chat-area"); |
no test coverage detected