diff --git a/Backend/server.py b/Backend/server.py index cb135f6..78254e4 100644 --- a/Backend/server.py +++ b/Backend/server.py @@ -119,7 +119,7 @@ def health_check(): # Socket event handlers @socketio.on('connect') -def handle_connect(): +def handle_connect(auth=None): session_id = request.sid logger.info(f"Client connected: {session_id}") @@ -137,9 +137,9 @@ def handle_connect(): emit('connection_status', {'status': 'connected'}) @socketio.on('disconnect') -def handle_disconnect(): +def handle_disconnect(reason=None): session_id = request.sid - logger.info(f"Client disconnected: {session_id}") + logger.info(f"Client disconnected: {session_id}. Reason: {reason}") # Cleanup if session_id in active_conversations: diff --git a/Backend/voice-chat.js b/Backend/voice-chat.js index 93bd434..2c9e949 100644 --- a/Backend/voice-chat.js +++ b/Backend/voice-chat.js @@ -574,6 +574,41 @@ function toggleVisualizerVisibility() { elements.visualizerCanvas.style.opacity = isVisible ? '1' : '0'; } +// Add a message to the conversation +function addMessage(text, type) { + if (!elements.conversation) return; + + const messageDiv = document.createElement('div'); + messageDiv.className = `message ${type}`; + + const textElement = document.createElement('p'); + textElement.textContent = text; + messageDiv.appendChild(textElement); + + elements.conversation.appendChild(messageDiv); + + // Auto-scroll to the bottom + elements.conversation.scrollTop = elements.conversation.scrollHeight; + + return messageDiv; +} + +// Add a system message to the conversation +function addSystemMessage(text) { + if (!elements.conversation) return; + + const messageDiv = document.createElement('div'); + messageDiv.className = 'message system'; + messageDiv.textContent = text; + + elements.conversation.appendChild(messageDiv); + + // Auto-scroll to the bottom + elements.conversation.scrollTop = elements.conversation.scrollHeight; + + return messageDiv; +} + // Handle transcription response from server function handleTranscription(data) { const speaker = data.speaker === 0 ? 'user' : 'ai';