diff --git a/src/systems/generation/promptBuilder.js b/src/systems/generation/promptBuilder.js index 4049536..68f1e5b 100644 --- a/src/systems/generation/promptBuilder.js +++ b/src/systems/generation/promptBuilder.js @@ -170,7 +170,7 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon instructions += 'Weather: [Weather Emoji, Forecast]\n'; } if (widgets.temperature?.enabled) { - const unit = widgets.temperature.unit === 'fahrenheit' ? '°F' : '°C'; + const unit = widgets.temperature.unit === 'F' ? '°F' : '°C'; instructions += `Temperature: [Temperature in ${unit}]\n`; } if (widgets.time?.enabled) { diff --git a/src/systems/integration/sillytavern.js b/src/systems/integration/sillytavern.js index a0bb38e..b40b0ca 100644 --- a/src/systems/integration/sillytavern.js +++ b/src/systems/integration/sillytavern.js @@ -99,6 +99,7 @@ export async function onMessageReceived(data) { // console.log('[RPG Companion] Parsing together mode response:', responseText); const parsedData = parseResponse(responseText); + // console.log('[RPG Companion] Parsed data:', parsedData); // Update stored data if (parsedData.userStats) { @@ -158,15 +159,24 @@ export async function onMessageReceived(data) { lastMessage.swipes[currentSwipeId] = cleanedMessage.trim(); } - // console.log('[RPG Companion] Cleaned message, removed tracker code blocks'); - - // Render the updated data + // Render the updated data FIRST (before cleaning DOM) renderUserStats(); renderInfoBox(); renderThoughts(); renderInventory(); renderQuests(); + // Then update the DOM to reflect the cleaned message + const lastMessageElement = $('#chat').children('.mes').last(); + if (lastMessageElement.length) { + const messageText = lastMessageElement.find('.mes_text'); + if (messageText.length) { + messageText.html(substituteParams(cleanedMessage.trim())); + } + } + + // console.log('[RPG Companion] Cleaned message, removed tracker code blocks from DOM'); + // Save to chat metadata saveChatData(); } diff --git a/src/systems/rendering/infoBox.js b/src/systems/rendering/infoBox.js index 4a4a5e6..d223e84 100644 --- a/src/systems/rendering/infoBox.js +++ b/src/systems/rendering/infoBox.js @@ -329,18 +329,18 @@ export function renderInfoBox() { let tempValue = data.tempValue || 20; // Apply temperature unit conversion - const preferredUnit = config.widgets.temperature.unit || 'celsius'; + const preferredUnit = config.widgets.temperature.unit || 'C'; if (data.temperature) { // Detect current unit in the data const isCelsius = tempDisplay.includes('°C'); const isFahrenheit = tempDisplay.includes('°F'); - if (preferredUnit === 'fahrenheit' && isCelsius) { + if (preferredUnit === 'F' && isCelsius) { // Convert C to F const fahrenheit = Math.round((tempValue * 9/5) + 32); tempDisplay = `${fahrenheit}°F`; tempValue = fahrenheit; - } else if (preferredUnit === 'celsius' && isFahrenheit) { + } else if (preferredUnit === 'C' && isFahrenheit) { // Convert F to C const celsius = Math.round((tempValue - 32) * 5/9); tempDisplay = `${celsius}°C`; @@ -348,12 +348,14 @@ export function renderInfoBox() { } } else { // No data yet, use default for preferred unit - tempDisplay = preferredUnit === 'fahrenheit' ? '68°F' : '20°C'; - tempValue = preferredUnit === 'fahrenheit' ? 68 : 20; + tempDisplay = preferredUnit === 'F' ? '68°F' : '20°C'; + tempValue = preferredUnit === 'F' ? 68 : 20; } - const tempPercent = Math.min(100, Math.max(0, ((tempValue + 20) / 60) * 100)); - const tempColor = tempValue < 10 ? '#4a90e2' : tempValue < 25 ? '#67c23a' : '#e94560'; + // Calculate thermometer display (convert to Celsius for consistent thresholds) + const tempInCelsius = preferredUnit === 'F' ? Math.round((tempValue - 32) * 5/9) : tempValue; + const tempPercent = Math.min(100, Math.max(0, ((tempInCelsius + 20) / 60) * 100)); + const tempColor = tempInCelsius < 10 ? '#4a90e2' : tempInCelsius < 25 ? '#67c23a' : '#e94560'; row1Widgets.push(`