Implement swipe data persistence between reloads and ensure all tracker data commits are based on prior assistant message when generating/swiping

This commit is contained in:
Daryl
2026-02-21 21:40:52 -04:00
parent f3e7518622
commit 8f2dbd2f88
4 changed files with 92 additions and 68 deletions
+6 -2
View File
@@ -20,7 +20,7 @@ import {
setLastActionWasSwipe,
$musicPlayerContainer
} from '../../core/state.js';
import { saveChatData } from '../../core/persistence.js';
import { saveChatData, mirrorToSwipeInfo } from '../../core/persistence.js';
import {
generateSeparateUpdatePrompt
} from './promptBuilder.js';
@@ -317,11 +317,15 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
}
const currentSwipeId = lastMessage.swipe_id || 0;
lastMessage.extra.rpg_companion_swipes[currentSwipeId] = {
const swipeEntry = {
userStats: parsedData.userStats,
infoBox: parsedData.infoBox,
characterThoughts: parsedData.characterThoughts
};
lastMessage.extra.rpg_companion_swipes[currentSwipeId] = swipeEntry;
// Mirror to swipe_info so this swipe survives page reload even if never manually edited
mirrorToSwipeInfo(lastMessage, currentSwipeId, swipeEntry);
// console.log('[RPG Companion] Stored separate mode RPG data for message swipe', currentSwipeId);
}