fix(hermes): persist conversation history across modal sessions

- Save chat history to localStorage after each AI response
- Load complete conversation history with TTS buttons on modal open
- Add TTS and delete buttons to historical AI messages
- Ensure conversation continuity when reopening modal
- Add debugging logs for history save operations
This commit is contained in:
Russell Ballestrini 2025-07-02 07:29:04 -04:00
parent 8651aaa54a
commit a8ef25ef6c

View file

@ -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);
}
});