diff --git a/src/ui.js b/src/ui.js index 088bc5f..2b91a84 100644 --- a/src/ui.js +++ b/src/ui.js @@ -986,6 +986,11 @@ async function openHermesModalNew() { aiMsg.innerHTML = marked.parse(response); } + // Save conversation history after successful response + const { chatHistory } = await import('./chat.js'); + saveConversationHistory(chatHistory); + console.log("Conversation history saved:", chatHistory.length, "messages"); + // Add TTS and delete buttons to AI message const messageActions = document.createElement("div"); messageActions.style.cssText = ` @@ -1106,6 +1111,55 @@ async function openHermesModalNew() { box-shadow: 0 1px 2px rgba(0,0,0,0.1); `; aiMsg.innerHTML = marked.parse(msg.content); + + // Add TTS and delete buttons to historical AI messages + const messageActions = document.createElement("div"); + messageActions.style.cssText = ` + margin-top: 8px; + display: flex; + gap: 8px; + opacity: 0.7; + `; + + const ttsBtn = document.createElement("button"); + ttsBtn.textContent = "🔊"; + ttsBtn.title = "Read aloud"; + ttsBtn.style.cssText = ` + background: none; + border: 1px solid #dee2e6; + border-radius: 4px; + padding: 4px 8px; + cursor: pointer; + font-size: 12px; + transition: all 0.2s; + `; + ttsBtn.onclick = () => { + const modalVoiceSelect = document.getElementById('hermes-voice-select'); + const selectedVoice = modalVoiceSelect?.value || 'alloy'; + speakText(msg.content, selectedVoice, 1.0); + }; + + const deleteBtn = document.createElement("button"); + deleteBtn.textContent = "🗑️"; + deleteBtn.title = "Delete message"; + deleteBtn.style.cssText = ` + background: none; + border: 1px solid #dee2e6; + border-radius: 4px; + padding: 4px 8px; + cursor: pointer; + font-size: 12px; + transition: all 0.2s; + `; + deleteBtn.onclick = () => { + aiMsg.remove(); + // TODO: Remove from chat history + }; + + messageActions.appendChild(ttsBtn); + messageActions.appendChild(deleteBtn); + aiMsg.appendChild(messageActions); + chatBox.appendChild(aiMsg); } });