diff --git a/src/interface/desktop/chat.html b/src/interface/desktop/chat.html
index 859e2c07..16119bcf 100644
--- a/src/interface/desktop/chat.html
+++ b/src/interface/desktop/chat.html
@@ -98,9 +98,9 @@
autoResize();
document.getElementById("chat-input").setAttribute("disabled", "disabled");
- let chat_body = document.getElementById("chat-body");
+ let chatBody = document.getElementById("chat-body");
- let conversationID = chat_body.dataset.conversationId;
+ let conversationID = chatBody.dataset.conversationId;
let hostURL = await window.hostURLAPI.getURL();
const khojToken = await window.tokenAPI.getToken();
const headers = { 'Authorization': `Bearer ${khojToken}` };
@@ -109,14 +109,14 @@
let response = await fetch(`${hostURL}/api/chat/sessions`, { method: "POST", headers });
let data = await response.json();
conversationID = data.conversation_id;
- chat_body.dataset.conversationId = conversationID;
+ chatBody.dataset.conversationId = conversationID;
await refreshChatSessionsPanel();
}
let newResponseEl = document.createElement("div");
newResponseEl.classList.add("chat-message", "khoj");
newResponseEl.attributes["data-meta"] = "🏮 Khoj at " + formatDate(new Date());
- chat_body.appendChild(newResponseEl);
+ chatBody.appendChild(newResponseEl);
let newResponseTextEl = document.createElement("div");
newResponseTextEl.classList.add("chat-message-text", "khoj");
@@ -144,6 +144,9 @@
rawQuery: query,
isVoice: isVoice,
}
+ // Reset toggle to show speak and hide send button
+ document.getElementById("speak-button").style.display = "block";
+ document.getElementById("send-button").style.display = "none";
// Call Khoj chat API
let chatApi = `${hostURL}/api/chat?q=${encodeURIComponent(query)}&conversation_id=${conversationID}&stream=true&client=desktop`;
@@ -218,6 +221,18 @@
chatInput.classList.remove("option-enabled");
}
+ // Toggle visibility of speak and send buttons
+ let speakButton = document.getElementById("speak-button");
+ let sendButton = document.getElementById("send-button");
+
+ if (chatInput.value.trim().length > 0) {
+ speakButton.style.display = "none";
+ sendButton.style.display = "block";
+ } else {
+ speakButton.style.display = "block";
+ sendButton.style.display = "none";
+ }
+
autoResize();
}
@@ -853,7 +868,7 @@
-