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;
|
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: {} };
|
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 (!params || typeof params !== "object") {
|
||||||
if (typeof clearGenResults === "function") clearGenResults();
|
resetBoardToDefault();
|
||||||
if (typeof renderBoard === "function") renderBoard();
|
if (typeof renderBoard === "function") renderBoard();
|
||||||
setContextMemory(null, { persist: false });
|
setContextMemory(null, { persist: false });
|
||||||
return { restored: false };
|
return { restored: false };
|
||||||
}
|
}
|
||||||
|
resetBoardToDefault();
|
||||||
await pushSessionToSwarm(state.chatSession);
|
await pushSessionToSwarm(state.chatSession);
|
||||||
const board = state.chatSession.board || {};
|
const board = state.chatSession.board || {};
|
||||||
if (Array.isArray(board.slots) && board.slots.length) {
|
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 selected = state.genResults.find((x) => x.id === state.selectedGenResultId);
|
||||||
const gen = typeof generateSlot === "function" ? generateSlot() : null;
|
const gen = typeof generateSlot === "function" ? generateSlot() : null;
|
||||||
if (gen && selected?.src) gen.src = selected.src;
|
if (gen && selected?.src) gen.src = selected.src;
|
||||||
} else if (typeof clearGenResults === "function") {
|
|
||||||
clearGenResults();
|
|
||||||
}
|
}
|
||||||
if (typeof syncBuildGenButton === "function") syncBuildGenButton();
|
if (typeof syncBuildGenButton === "function") syncBuildGenButton();
|
||||||
if (typeof syncLiveParamsBar === "function") syncLiveParamsBar();
|
if (typeof syncLiveParamsBar === "function") syncLiveParamsBar();
|
||||||
@@ -4892,7 +4891,7 @@ ${patch.prompt}`;
|
|||||||
state.lastUserParamIntent = false;
|
state.lastUserParamIntent = false;
|
||||||
state.pendingSilentGen = false;
|
state.pendingSilentGen = false;
|
||||||
state.lastPatch = null;
|
state.lastPatch = null;
|
||||||
clearGenResults();
|
resetBoardToDefault();
|
||||||
const chat = {
|
const chat = {
|
||||||
id: chatUid(),
|
id: chatUid(),
|
||||||
title: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442",
|
title: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442",
|
||||||
@@ -6318,10 +6317,24 @@ ${patch.prompt}`;
|
|||||||
function clearGenResults() {
|
function clearGenResults() {
|
||||||
state.genResults = [];
|
state.genResults = [];
|
||||||
state.selectedGenResultId = null;
|
state.selectedGenResultId = null;
|
||||||
|
const gen = typeof generateSlot === "function" ? generateSlot() : null;
|
||||||
|
if (gen) {
|
||||||
|
gen.src = null;
|
||||||
|
}
|
||||||
if (state.lightboxIndex >= 0) {
|
if (state.lightboxIndex >= 0) {
|
||||||
closeGenLightbox();
|
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 } = {}) {
|
function selectGenResult(id, { restore = true, openViewer = false } = {}) {
|
||||||
const row = (state.genResults || []).find((r) => r.id === id);
|
const row = (state.genResults || []).find((r) => r.id === id);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public partial class SwarmAssistentExtension : Extension
|
|||||||
ExtensionAuthor = "mrleo1nid";
|
ExtensionAuthor = "mrleo1nid";
|
||||||
Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop.";
|
Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop.";
|
||||||
License = "MIT";
|
License = "MIT";
|
||||||
Version = "0.15.14";
|
Version = "0.15.15";
|
||||||
Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint", "memory", "training", "heard", "qlora"];
|
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)
|
? S.sessionFromLegacyParams(params)
|
||||||
: (params && params.gen ? params : (S && S.emptySession ? S.emptySession() : { gen: {}, board: {} }));
|
: (params && params.gen ? params : (S && S.emptySession ? S.emptySession() : { gen: {}, board: {} }));
|
||||||
if (!params || typeof params !== 'object') {
|
if (!params || typeof params !== 'object') {
|
||||||
if (typeof clearGenResults === 'function') clearGenResults();
|
resetBoardToDefault();
|
||||||
if (typeof renderBoard === 'function') renderBoard();
|
if (typeof renderBoard === 'function') renderBoard();
|
||||||
setContextMemory(null, { persist: false });
|
setContextMemory(null, { persist: false });
|
||||||
return { restored: false };
|
return { restored: false };
|
||||||
}
|
}
|
||||||
|
resetBoardToDefault();
|
||||||
await pushSessionToSwarm(state.chatSession);
|
await pushSessionToSwarm(state.chatSession);
|
||||||
const board = state.chatSession.board || {};
|
const board = state.chatSession.board || {};
|
||||||
if (Array.isArray(board.slots) && board.slots.length) {
|
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 selected = state.genResults.find((x) => x.id === state.selectedGenResultId);
|
||||||
const gen = typeof generateSlot === 'function' ? generateSlot() : null;
|
const gen = typeof generateSlot === 'function' ? generateSlot() : null;
|
||||||
if (gen && selected?.src) gen.src = selected.src;
|
if (gen && selected?.src) gen.src = selected.src;
|
||||||
} else if (typeof clearGenResults === 'function') {
|
|
||||||
clearGenResults();
|
|
||||||
}
|
}
|
||||||
if (typeof syncBuildGenButton === 'function') syncBuildGenButton();
|
if (typeof syncBuildGenButton === 'function') syncBuildGenButton();
|
||||||
if (typeof syncLiveParamsBar === 'function') syncLiveParamsBar();
|
if (typeof syncLiveParamsBar === 'function') syncLiveParamsBar();
|
||||||
@@ -3843,7 +3842,7 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable }
|
|||||||
state.lastUserParamIntent = false;
|
state.lastUserParamIntent = false;
|
||||||
state.pendingSilentGen = false;
|
state.pendingSilentGen = false;
|
||||||
state.lastPatch = null;
|
state.lastPatch = null;
|
||||||
clearGenResults();
|
resetBoardToDefault();
|
||||||
const chat = {
|
const chat = {
|
||||||
id: chatUid(),
|
id: chatUid(),
|
||||||
title: 'Новый чат',
|
title: 'Новый чат',
|
||||||
@@ -5378,11 +5377,27 @@ import { DEFAULT_ASPECT_TABLE, applyAspectTableFromObject as mergeAspectTable }
|
|||||||
function clearGenResults() {
|
function clearGenResults() {
|
||||||
state.genResults = [];
|
state.genResults = [];
|
||||||
state.selectedGenResultId = null;
|
state.selectedGenResultId = null;
|
||||||
|
const gen = typeof generateSlot === 'function' ? generateSlot() : null;
|
||||||
|
if (gen) {
|
||||||
|
gen.src = null;
|
||||||
|
}
|
||||||
if (state.lightboxIndex >= 0) {
|
if (state.lightboxIndex >= 0) {
|
||||||
closeGenLightbox();
|
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 } = {}) {
|
function selectGenResult(id, { restore = true, openViewer = false } = {}) {
|
||||||
const row = (state.genResults || []).find((r) => r.id === id);
|
const row = (state.genResults || []).find((r) => r.id === id);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user