v3.4.1: Fix Present Characters not included in <previous> section for separate generation mode
- Fixed bug where Present Characters data wasn't appearing in the <previous> section when generating new trackers in separate mode - Root cause: committedTrackerData.characterThoughts is stored as a JS array, not a JSON string - Solution: Check data type before parsing - handle both object/array and string formats - Present Characters data now correctly included in unified previous tracker JSON regardless of showCharacterThoughts setting
This commit is contained in:
+1
-1
@@ -6,6 +6,6 @@
|
||||
"js": "index.js",
|
||||
"css": "style.css",
|
||||
"author": "Marinara",
|
||||
"version": "3.3.2",
|
||||
"version": "3.4.1",
|
||||
"homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern"
|
||||
}
|
||||
|
||||
@@ -1055,16 +1055,34 @@ export function generateRPGPromptText() {
|
||||
}
|
||||
}
|
||||
|
||||
if (extensionSettings.showCharacterThoughts && committedTrackerData.characterThoughts) {
|
||||
// Include Present Characters data if it exists, regardless of current showCharacterThoughts setting
|
||||
// This ensures existing character data is preserved in context even if the setting is toggled off
|
||||
if (committedTrackerData.characterThoughts) {
|
||||
try {
|
||||
// Try to parse as JSON - apply locks before adding to previous
|
||||
let parsed;
|
||||
// Check if it's already a JavaScript object/array (not a JSON string)
|
||||
if (typeof committedTrackerData.characterThoughts === 'object') {
|
||||
// Already parsed - apply locks and use directly
|
||||
parsed = applyLocks(committedTrackerData.characterThoughts, 'characters');
|
||||
} else {
|
||||
// It's a JSON string - apply locks and parse
|
||||
const lockedData = applyLocks(committedTrackerData.characterThoughts, 'characters');
|
||||
const parsed = JSON.parse(lockedData);
|
||||
parsed = JSON.parse(lockedData);
|
||||
}
|
||||
|
||||
// Only include if there's actual character data (non-empty array or object with content)
|
||||
if (parsed && ((Array.isArray(parsed) && parsed.length > 0) ||
|
||||
(parsed.characters && Array.isArray(parsed.characters) && parsed.characters.length > 0))) {
|
||||
unifiedPrevious.characters = parsed;
|
||||
} catch {
|
||||
}
|
||||
} catch (e) {
|
||||
// console.warn('[RPG Companion] Failed to process characters for previous section:', e);
|
||||
// Old text format - show it separately for backward compat
|
||||
if (!unifiedPrevious.userStats && !unifiedPrevious.infoBox) {
|
||||
promptText += `${committedTrackerData.characterThoughts}\n`;
|
||||
const charText = typeof committedTrackerData.characterThoughts === 'string'
|
||||
? committedTrackerData.characterThoughts
|
||||
: JSON.stringify(committedTrackerData.characterThoughts, null, 2);
|
||||
promptText += `${charText}\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user