MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / sendMessage

Function sendMessage

web/js/chat.js:99–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99export 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
130export async function sendBotCommand(cmdText) {
131 const chatArea = document.getElementById("chat-area");

Callers 1

initChatFunction · 0.85

Calls 5

appendMessageFunction · 0.85
showLoadingIndicatorFunction · 0.85
getOrCreateWsFunction · 0.85
handleErrorFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected