From 103f9e9f5c81f6b56bf339ed2e38e9f2c5147ff6 Mon Sep 17 00:00:00 2001 From: G-Fourteen Date: Thu, 11 Sep 2025 13:18:31 -0600 Subject: [PATCH] Add persistent gallery for screensaver images --- chat-storage.js | 54 +++++++++++++++++++++++++++++++------------ index.html | 53 +++++++++++++++++++++++------------------- memory-api.js | 61 ++++++++++++++++++++++++++++++++++--------------- styles.css | 54 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 159 insertions(+), 63 deletions(-) diff --git a/chat-storage.js b/chat-storage.js index e76fb78..083982a 100644 --- a/chat-storage.js +++ b/chat-storage.js @@ -1,7 +1,32 @@ document.addEventListener("DOMContentLoaded", () => { const { chatBox, chatInput, clearChatBtn, voiceToggleBtn, modelSelect, synth, autoSpeakEnabled, speakMessage, stopSpeaking, showToast, toggleSpeechRecognition, initSpeechRecognition, handleVoiceCommand, speakSentences } = window._chatInternals; const imagePatterns = window.imagePatterns; - function generateSessionTitle(messages) { + + function openImageModal(imageUrl) { + window.open(imageUrl, "_blank"); + } + + function addImageToGallery(imageUrl) { + const gallery = document.getElementById('past-image-gallery'); + if (!gallery) return; + if ([...gallery.querySelectorAll('img.thumbnail')].some(img => img.src === imageUrl)) return; + const img = document.createElement('img'); + img.src = imageUrl; + img.className = 'thumbnail'; + img.addEventListener('click', () => { + openImageModal(imageUrl); + }); + gallery.appendChild(img); + if (window.Memory && typeof window.Memory.saveImage === 'function') { + window.Memory.saveImage(imageUrl); + } + } + + if (window.Memory && typeof window.Memory.loadPastImages === 'function') { + window.Memory.loadPastImages(addImageToGallery); + } + + function generateSessionTitle(messages) { let title = ""; for (let i = 0; i < messages.length; i++) { if (messages[i].role === "ai") { @@ -205,19 +230,20 @@ document.addEventListener("DOMContentLoaded", () => { img.style.display = "block"; attachImageButtons(img, imageId); }; - img.onerror = () => { - loadingDiv.innerHTML = "⚠️ Failed to load image"; - loadingDiv.style.display = "flex"; - loadingDiv.style.justifyContent = "center"; - loadingDiv.style.alignItems = "center"; - }; - imageContainer.appendChild(img); - const imgButtonContainer = document.createElement("div"); - imgButtonContainer.className = "image-button-container"; - imgButtonContainer.dataset.imageId = imageId; - imageContainer.appendChild(imgButtonContainer); - return imageContainer; - } + img.onerror = () => { + loadingDiv.innerHTML = "⚠️ Failed to load image"; + loadingDiv.style.display = "flex"; + loadingDiv.style.justifyContent = "center"; + loadingDiv.style.alignItems = "center"; + }; + imageContainer.appendChild(img); + addImageToGallery(url); + const imgButtonContainer = document.createElement("div"); + imgButtonContainer.className = "image-button-container"; + imgButtonContainer.dataset.imageId = imageId; + imageContainer.appendChild(imgButtonContainer); + return imageContainer; + } function attachImageButtons(img, imageId) { const imgButtonContainer = document.querySelector(`.image-button-container[data-image-id="${imageId}"]`); if (!imgButtonContainer) { diff --git a/index.html b/index.html index 38cd6b1..0d2174f 100644 --- a/index.html +++ b/index.html @@ -126,30 +126,35 @@

Sessions

-
-
- - - - -
-
- -
-
- - - +
+
+ + + + +
+
+ +
+
+ + + +