Reset board preview when switching chats (0.15.15).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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"];
|
||||
}
|
||||
|
||||
|
||||
+19
-4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user