From caa18e8a51e5d0664543f8cf07ce1135e604b300 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Sun, 23 Aug 2026 20:35:59 +0300 Subject: [PATCH] Reset board preview when switching chats (0.15.15). Co-authored-by: Cursor --- Assets/assistent.bundle.js | 21 +++++++++++++++++---- SwarmAssistentExtension.cs | 2 +- src/app.js | 23 +++++++++++++++++++---- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Assets/assistent.bundle.js b/Assets/assistent.bundle.js index 21627ab..2a63bc2 100644 --- a/Assets/assistent.bundle.js +++ b/Assets/assistent.bundle.js @@ -4468,11 +4468,12 @@ ${patch.prompt}`; const S = window.SA && window.SA.session; state.chatSession = S && typeof S.sessionFromLegacyParams === "function" ? S.sessionFromLegacyParams(params) : params && params.gen ? params : S && S.emptySession ? S.emptySession() : { gen: {}, board: {} }; if (!params || typeof params !== "object") { - if (typeof clearGenResults === "function") clearGenResults(); + resetBoardToDefault(); if (typeof renderBoard === "function") renderBoard(); setContextMemory(null, { persist: false }); return { restored: false }; } + resetBoardToDefault(); await pushSessionToSwarm(state.chatSession); const board = state.chatSession.board || {}; if (Array.isArray(board.slots) && board.slots.length) { @@ -4491,8 +4492,6 @@ ${patch.prompt}`; const selected = state.genResults.find((x) => x.id === state.selectedGenResultId); const gen = typeof generateSlot === "function" ? generateSlot() : null; if (gen && selected?.src) gen.src = selected.src; - } else if (typeof clearGenResults === "function") { - clearGenResults(); } if (typeof syncBuildGenButton === "function") syncBuildGenButton(); if (typeof syncLiveParamsBar === "function") syncLiveParamsBar(); @@ -4892,7 +4891,7 @@ ${patch.prompt}`; state.lastUserParamIntent = false; state.pendingSilentGen = false; state.lastPatch = null; - clearGenResults(); + resetBoardToDefault(); const chat = { id: chatUid(), title: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442", @@ -6318,10 +6317,24 @@ ${patch.prompt}`; function clearGenResults() { state.genResults = []; state.selectedGenResultId = null; + const gen = typeof generateSlot === "function" ? generateSlot() : null; + if (gen) { + gen.src = null; + } if (state.lightboxIndex >= 0) { closeGenLightbox(); } } + function resetBoardToDefault() { + state.slots = [ + { id: GEN_ID, type: "generate", label: "Generate", src: null, attach: false }, + { id: "ref1", type: "ref", label: "Ref 1", src: null, attach: true } + ]; + state.refSeq = 1; + state.selectedSlotId = "ref1"; + clearGenResults(); + syncLastImageAlias(); + } function selectGenResult(id, { restore = true, openViewer = false } = {}) { const row = (state.genResults || []).find((r) => r.id === id); if (!row) { diff --git a/SwarmAssistentExtension.cs b/SwarmAssistentExtension.cs index 6c1d4df..5dd6d1a 100644 --- a/SwarmAssistentExtension.cs +++ b/SwarmAssistentExtension.cs @@ -33,7 +33,7 @@ public partial class SwarmAssistentExtension : Extension ExtensionAuthor = "mrleo1nid"; Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop."; License = "MIT"; - Version = "0.15.14"; + Version = "0.15.15"; Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint", "memory", "training", "heard", "qlora"]; } diff --git a/src/app.js b/src/app.js index da63b7c..5a59ac4 100644 --- a/src/app.js +++ b/src/app.js @@ -3376,11 +3376,12 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable } ? S.sessionFromLegacyParams(params) : (params && params.gen ? params : (S && S.emptySession ? S.emptySession() : { gen: {}, board: {} })); if (!params || typeof params !== 'object') { - if (typeof clearGenResults === 'function') clearGenResults(); + resetBoardToDefault(); if (typeof renderBoard === 'function') renderBoard(); setContextMemory(null, { persist: false }); return { restored: false }; } + resetBoardToDefault(); await pushSessionToSwarm(state.chatSession); const board = state.chatSession.board || {}; if (Array.isArray(board.slots) && board.slots.length) { @@ -3401,8 +3402,6 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable } const selected = state.genResults.find((x) => x.id === state.selectedGenResultId); const gen = typeof generateSlot === 'function' ? generateSlot() : null; if (gen && selected?.src) gen.src = selected.src; - } else if (typeof clearGenResults === 'function') { - clearGenResults(); } if (typeof syncBuildGenButton === 'function') syncBuildGenButton(); if (typeof syncLiveParamsBar === 'function') syncLiveParamsBar(); @@ -3843,7 +3842,7 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable } state.lastUserParamIntent = false; state.pendingSilentGen = false; state.lastPatch = null; - clearGenResults(); + resetBoardToDefault(); const chat = { id: chatUid(), title: 'Новый чат', @@ -5378,11 +5377,27 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable } function clearGenResults() { state.genResults = []; state.selectedGenResultId = null; + const gen = typeof generateSlot === 'function' ? generateSlot() : null; + if (gen) { + gen.src = null; + } if (state.lightboxIndex >= 0) { closeGenLightbox(); } } + /** Empty board — used when switching chats so the previous preview does not leak. */ + function resetBoardToDefault() { + state.slots = [ + { id: GEN_ID, type: 'generate', label: 'Generate', src: null, attach: false }, + { id: 'ref1', type: 'ref', label: 'Ref 1', src: null, attach: true }, + ]; + state.refSeq = 1; + state.selectedSlotId = 'ref1'; + clearGenResults(); + syncLastImageAlias(); + } + function selectGenResult(id, { restore = true, openViewer = false } = {}) { const row = (state.genResults || []).find((r) => r.id === id); if (!row) {