From 2048e25cd567726dfa9d3d29878301f284ba07de Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 2 Jul 2025 10:11:51 -0400 Subject: [PATCH] fix(hermes): ensure AI responses are saved to conversation history - Manually add AI response to chatHistory after streaming completes - Fix missing Hermes responses when reopening modal - Update modal title to 'uncloseai.' with link to Nous Research Hermes - Add comprehensive debugging for conversation history save/load - Ensure proper history synchronization between modules --- src/ui.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ui.js b/src/ui.js index 1f98358..5343ddb 100644 --- a/src/ui.js +++ b/src/ui.js @@ -629,7 +629,7 @@ async function openHermesModalNew() { titleContainer.style.cssText = `flex: 1; display: flex; flex-direction: column; gap: 4px;`; const title = document.createElement("h2"); - title.textContent = "🤖 Hermes AI"; + title.textContent = "🤖 uncloseai."; title.style.cssText = ` margin: 0; font-size: ${isMobile ? '18px' : '20px'}; @@ -640,7 +640,7 @@ async function openHermesModalNew() { const pageTitle = document.title || window.location.hostname; subtitle.innerHTML = `
- uncloseai. presents nous research's hermes large language model
+ uncloseai. presents nous research's hermes large language model
You are discussing: ${pageTitle}
`; @@ -1106,13 +1106,16 @@ async function openHermesModalNew() { aiMsg.innerHTML = marked.parse(response); } - // Get the updated chat history from chat.js module - const { getChatHistory } = await import('./chat.js'); - const updatedHistory = getChatHistory(); + // Add the AI response to chat history manually since sendMessage generator doesn't do it + const { getChatHistory, updateChatHistory } = await import('./chat.js'); + const currentHistory = getChatHistory(); + currentHistory.push({ role: 'assistant', content: response }); + updateChatHistory(currentHistory); // Save conversation history after successful response - saveConversationHistory(updatedHistory); - console.log("Conversation history saved:", updatedHistory.length, "messages"); + saveConversationHistory(currentHistory); + console.log("Conversation history saved:", currentHistory.length, "messages"); + console.log("Saved history content:", currentHistory.map(msg => ({ role: msg.role, content: msg.content.substring(0, 50) + '...' }))); // Add TTS and delete buttons to AI message const messageActions = document.createElement("div"); @@ -1269,6 +1272,8 @@ async function openHermesModalNew() { const loadHistory = async () => { try { const history = loadConversationHistory(); + console.log("Raw history from localStorage:", history); + console.log("History length:", history ? history.length : 0); if (history && history.length > 0) { // Set up page context for existing conversation const pageContent = extractWebpageContent(); @@ -1299,7 +1304,6 @@ You have complete knowledge of this page content and can reference any details, // Update the chat.js module's history updateChatHistory(newHistory); console.log("Chat history synced with loaded data:", newHistory.length, "messages"); - console.log("Current chatHistory contents:", chatHistory); console.log("History to display:", history); // Display previous conversation history.forEach((msg, index) => {