From 3b6d771be9ea29af76f7ba574d2f4034cf24a056 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Mon, 29 Jun 2026 01:19:50 +0000 Subject: [PATCH] Restore chat thumbnails and gallery OCR captions --- routes/gallery/gallery_helpers.py | 1 + static/js/chatRenderer.js | 3 ++- static/js/sessions.js | 21 ++------------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/routes/gallery/gallery_helpers.py b/routes/gallery/gallery_helpers.py index e4005b8a7..247ad4cb0 100644 --- a/routes/gallery/gallery_helpers.py +++ b/routes/gallery/gallery_helpers.py @@ -99,6 +99,7 @@ def _image_to_dict(img: GalleryImage, session_name: str = None) -> Dict[str, Any "filename": img.filename, "url": f"/api/generated-image/{img.filename}", "prompt": img.prompt, + "caption": img.caption or "", "model": img.model, "size": img.size, "quality": img.quality, diff --git a/static/js/chatRenderer.js b/static/js/chatRenderer.js index 76ebc4e3a..a6ed56c96 100644 --- a/static/js/chatRenderer.js +++ b/static/js/chatRenderer.js @@ -81,7 +81,7 @@ function _formatSize(bytes) { // Build the `.attach-cards` element for a message's attachment list. Shared by // addMessage and updateMessageAttachments so a live (optimistic) user bubble // can be re-rendered with real upload ids once the upload resolves. -function buildAttachCards(attachments) { +export function buildAttachCards(attachments) { const attachWrap = document.createElement('div'); attachWrap.className = 'attach-cards'; for (const att of attachments) { @@ -2672,6 +2672,7 @@ const chatRenderer = { createMsgFooter, displayMetrics, addMessage, + buildAttachCards, updateMessageAttachments, }; diff --git a/static/js/sessions.js b/static/js/sessions.js index e6a2bed4c..50e9dcb81 100644 --- a/static/js/sessions.js +++ b/static/js/sessions.js @@ -168,26 +168,9 @@ function _renderHistoryMessage(msg, modelName) { markdownModule.squashOutsideCode(markdownModule.renderContent(displayContent || '')) ); if (msg.role === 'user' && Array.isArray(meta?.attachments) && meta.attachments.length) { - const cards = document.createElement('div'); - cards.className = 'attach-cards history-attach-cards'; - for (const att of meta.attachments) { - const card = document.createElement('div'); - card.className = 'attach-card history-attach-card'; - const icon = document.createElement('span'); - icon.className = 'attach-card-icon'; - icon.innerHTML = ''; - const name = document.createElement('span'); - name.className = 'attach-card-name'; - name.textContent = att.name || 'Image attached'; - const size = document.createElement('span'); - size.className = 'attach-card-size'; - size.textContent = 'image'; - card.appendChild(icon); - card.appendChild(name); - card.appendChild(size); - cards.appendChild(card); + if (chatRenderer.buildAttachCards) { + body.appendChild(chatRenderer.buildAttachCards(meta.attachments)); } - body.appendChild(cards); } wrap.appendChild(roleEl);