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
+19 -4
View File
@@ -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) {