From fe69a15a48703d30d88075107c89445c313f6f73 Mon Sep 17 00:00:00 2001 From: Spicy_Marinara Date: Thu, 6 Nov 2025 09:37:41 +0100 Subject: [PATCH] Fix: Use configured relationship emojis from tracker config instead of hardcoded defaults - Load relationshipEmojis from config.relationshipEmojis in thoughts.js - Custom relationships added in Edit Trackers now display correctly as emojis - Falls back to default emojis if config not available --- src/systems/integration/sillytavern.js | 6 ++++-- src/systems/rendering/thoughts.js | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/systems/integration/sillytavern.js b/src/systems/integration/sillytavern.js index b40b0ca..56b3471 100644 --- a/src/systems/integration/sillytavern.js +++ b/src/systems/integration/sillytavern.js @@ -217,8 +217,10 @@ export function onCharacterChanged() { // Load chat-specific data when switching chats loadChatData(); - // Commit tracker data from the last assistant message to initialize for this chat - commitTrackerData(); + // Don't call commitTrackerData() here - it would overwrite the loaded committedTrackerData + // with data from the last message, which may be null/empty. The loaded committedTrackerData + // already contains the committed state from when we last left this chat. + // commitTrackerData() will be called naturally when new messages arrive. // Re-render with the loaded data renderUserStats(); diff --git a/src/systems/rendering/thoughts.js b/src/systems/rendering/thoughts.js index d263ed1..19ae5b5 100644 --- a/src/systems/rendering/thoughts.js +++ b/src/systems/rendering/thoughts.js @@ -215,8 +215,8 @@ export function renderThoughts() { } } - // Relationship status to emoji mapping (for backward compatibility with old "relationship" field) - const relationshipEmojis = { + // Get relationship emojis from config (with fallback defaults) + const relationshipEmojis = config?.relationshipEmojis || { 'Enemy': '⚔️', 'Neutral': '⚖️', 'Friend': '⭐', @@ -498,6 +498,10 @@ export function updateCharacterField(characterName, field, value) { let statsLineExists = false; let statsLineIndex = -1; + // Get the configured thoughts field name + const thoughtsFieldName = presentCharsConfig?.thoughts?.name || 'Thoughts'; + const isThoughtsField = field.toLowerCase() === 'thoughts' || field === thoughtsFieldName; + // First pass: check if Stats line exists and update other fields for (let i = characterStartIndex; i < characterEndIndex; i++) { const line = lines[i].trim(); @@ -530,6 +534,11 @@ export function updateCharacterField(characterName, field, value) { const relationshipValue = emojiToRelationship[value] || value; lines[i] = `Relationship: ${relationshipValue}`; } + else if (isThoughtsField && line.startsWith(thoughtsFieldName + ':')) { + // Update thoughts field + lines[i] = `${thoughtsFieldName}: ${value}`; + console.log('[RPG Companion] Updated thoughts:', lines[i]); + } } // Handle stat updates