diff --git a/src/interface/desktop/chat.html b/src/interface/desktop/chat.html index 82ab0f16..958cb5d9 100644 --- a/src/interface/desktop/chat.html +++ b/src/interface/desktop/chat.html @@ -516,6 +516,18 @@ } } + function flashStatusInChatInput(message) { + // Get chat input element and original placeholder + let chatInput = document.getElementById("chat-input"); + let originalPlaceholder = chatInput.placeholder; + // Set placeholder to message + chatInput.placeholder = message; + // Reset placeholder after 2 seconds + setTimeout(() => { + chatInput.placeholder = originalPlaceholder; + }, 2000); + } + async function clearConversationHistory() { let chatInput = document.getElementById("chat-input"); let originalPlaceholder = chatInput.placeholder; @@ -530,16 +542,11 @@ .then(data => { chatBody.innerHTML = ""; loadChat(); - chatInput.placeholder = "Cleared conversation history"; + flashStatusInChatInput("🗑 Cleared conversation history"); }) .catch(err => { - chatInput.placeholder = "Failed to clear conversation history"; + flashStatusInChatInput("⛔️ Failed to clear conversation history"); }) - .finally(() => { - setTimeout(() => { - chatInput.placeholder = originalPlaceholder; - }, 2000); - }); } let mediaRecorder; @@ -560,7 +567,11 @@ fetch(url, { method: 'POST', body: formData, headers}) .then(response => response.ok ? response.json() : Promise.reject(response)) .then(data => { chatInput.value += data.text; }) - .catch(err => err.status == 422 ? console.error("Configure speech-to-text model on server.") : console.error("Failed to transcribe audio")); + .catch(err => { + err.status == 422 + ? flashStatusInChatInput("⛔️ Configure speech-to-text model on server.") + : flashStatusInChatInput("⛔️ Failed to transcribe audio") + }); }; const handleRecording = (stream) => { @@ -579,7 +590,7 @@ mediaRecorder.start(); speakButtonImg.src = './assets/icons/stop-solid.svg'; - speakButtonImg.alt = 'Stop Speaking'; + speakButtonImg.alt = 'Stop Transcription'; }; // Toggle recording @@ -588,12 +599,12 @@ .getUserMedia({ audio: true }) .then(handleRecording) .catch((e) => { - console.error(e); + flashStatusInChatInput("⛔️ Failed to access microphone"); }); } else if (mediaRecorder.state === 'recording') { mediaRecorder.stop(); speakButtonImg.src = './assets/icons/microphone-solid.svg'; - speakButtonImg.alt = 'Speak'; + speakButtonImg.alt = 'Transcribe'; } } @@ -626,7 +637,7 @@