Reset board preview when switching chats (0.15.15).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 20:35:59 +03:00
co-authored by Cursor
parent 61b4b51118
commit caa18e8a51
3 changed files with 37 additions and 9 deletions
+17 -4
View File
@@ -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) {