(cmdText)
| 128 | } |
| 129 | |
| 130 | export async function sendBotCommand(cmdText) { |
| 131 | const chatArea = document.getElementById("chat-area"); |
| 132 | if (chatArea.classList.contains("mode-welcome")) { |
| 133 | chatArea.classList.remove("mode-welcome"); |
| 134 | chatArea.classList.add("mode-chat"); |
| 135 | } |
| 136 | |
| 137 | appendMessage("user", cmdText); |
| 138 | chatHistory.push({ role: "user", content: cmdText }); |
| 139 | |
| 140 | const sendBtn = document.getElementById("send-btn"); |
| 141 | sendBtn.disabled = true; |
| 142 | |
| 143 | currentAssistantMsg = appendMessage("assistant", ""); |
| 144 | showLoadingIndicator(); |
| 145 | |
| 146 | try { |
| 147 | const socket = await getOrCreateWs(); |
| 148 | socket.send(JSON.stringify({ text: cmdText })); |
| 149 | } catch (err) { |
| 150 | handleError(err.message); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // ========== Internal Rendering & WS logic ========== |
| 155 |
nothing calls this directly
no test coverage detected