fix(dashboard): sync widget data and fix refresh on chat load
- Update onMessageReceived to populate extensionSettings.infoBoxData and characterThoughts for dashboard widgets - Update updateRPGData (separate mode) with same extensionSettings population - Add refreshDashboard() calls after data updates in both generation paths - Fix onCharacterChanged to populate extensionSettings from loaded chat data - Fix refreshDashboard() to use correct property name (registry not widgetRegistry) - Reduce mood and weather widget font sizes to fit in 1x1 layout This fixes Scene tab widgets not updating when receiving messages or loading chats from welcome screen.
This commit is contained in:
@@ -390,11 +390,15 @@ export function createDefaultLayout(manager) {
|
||||
* Refresh all widgets (called after data updates)
|
||||
*/
|
||||
export function refreshDashboard() {
|
||||
if (dashboardManager) {
|
||||
// Get all active widgets and re-render them
|
||||
const widgets = dashboardManager.getAllWidgets();
|
||||
widgets.forEach(widget => {
|
||||
dashboardManager.renderWidget(widget.id);
|
||||
if (dashboardManager && dashboardManager.widgets) {
|
||||
// Re-render all active widgets by accessing the widgets Map directly
|
||||
dashboardManager.widgets.forEach((widgetData, widgetId) => {
|
||||
// Get the widget definition from registry
|
||||
const definition = dashboardManager.registry.get(widgetData.widget.type);
|
||||
if (definition && widgetData.element) {
|
||||
// Re-render the widget content
|
||||
dashboardManager.renderWidgetContent(widgetData.element, widgetData.widget, definition);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import { saveChatData } from '../../core/persistence.js';
|
||||
import { generateSeparateUpdatePrompt } from './promptBuilder.js';
|
||||
import { parseResponse, parseUserStats } from './parser.js';
|
||||
import { refreshDashboard } from '../dashboard/dashboardIntegration.js';
|
||||
|
||||
// Store the original preset name to restore after tracker generation
|
||||
let originalPresetName = null;
|
||||
@@ -155,16 +156,18 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
|
||||
|
||||
// console.log('[RPG Companion] Stored separate mode RPG data for message swipe', currentSwipeId);
|
||||
|
||||
// Update lastGeneratedData for display AND future commit
|
||||
// Update lastGeneratedData for display AND future commit, plus extensionSettings for dashboard widgets
|
||||
if (parsedData.userStats) {
|
||||
lastGeneratedData.userStats = parsedData.userStats;
|
||||
parseUserStats(parsedData.userStats);
|
||||
parseUserStats(parsedData.userStats); // Updates extensionSettings.userStats
|
||||
}
|
||||
if (parsedData.infoBox) {
|
||||
lastGeneratedData.infoBox = parsedData.infoBox;
|
||||
extensionSettings.infoBoxData = parsedData.infoBox; // Update for dashboard widgets
|
||||
}
|
||||
if (parsedData.characterThoughts) {
|
||||
lastGeneratedData.characterThoughts = parsedData.characterThoughts;
|
||||
extensionSettings.characterThoughts = parsedData.characterThoughts; // Update for dashboard widgets
|
||||
}
|
||||
// console.log('[RPG Companion] 💾 SEPARATE MODE: Updated lastGeneratedData:', {
|
||||
// userStats: lastGeneratedData.userStats ? 'exists' : 'null',
|
||||
@@ -187,11 +190,14 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
|
||||
// console.log('[RPG Companion] 🔆 FIRST TIME: Auto-committed tracker data');
|
||||
}
|
||||
|
||||
// Render the updated data
|
||||
// Render the updated data (old panel UI)
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
} else {
|
||||
// No assistant message to attach to - just update display
|
||||
if (parsedData.userStats) {
|
||||
@@ -201,6 +207,9 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
}
|
||||
|
||||
// Save to chat metadata
|
||||
|
||||
@@ -31,6 +31,9 @@ import { renderInfoBox } from '../rendering/infoBox.js';
|
||||
import { renderThoughts, updateChatThoughts } from '../rendering/thoughts.js';
|
||||
import { renderInventory } from '../rendering/inventory.js';
|
||||
|
||||
// Dashboard
|
||||
import { refreshDashboard } from '../dashboard/dashboardIntegration.js';
|
||||
|
||||
// Utils
|
||||
import { getSafeThumbnailUrl } from '../../utils/avatars.js';
|
||||
|
||||
@@ -99,17 +102,26 @@ export async function onMessageReceived(data) {
|
||||
// console.log('[RPG Companion] Parsing together mode response:', responseText);
|
||||
|
||||
const parsedData = parseResponse(responseText);
|
||||
console.log('[RPG Companion] Parsed data results:', {
|
||||
hasUserStats: !!parsedData.userStats,
|
||||
hasInfoBox: !!parsedData.infoBox,
|
||||
hasCharacterThoughts: !!parsedData.characterThoughts
|
||||
});
|
||||
|
||||
// Update stored data
|
||||
// Update stored data (both lastGeneratedData for old UI and extensionSettings for dashboard widgets)
|
||||
if (parsedData.userStats) {
|
||||
lastGeneratedData.userStats = parsedData.userStats;
|
||||
parseUserStats(parsedData.userStats);
|
||||
parseUserStats(parsedData.userStats); // Updates extensionSettings.userStats
|
||||
}
|
||||
if (parsedData.infoBox) {
|
||||
lastGeneratedData.infoBox = parsedData.infoBox;
|
||||
extensionSettings.infoBoxData = parsedData.infoBox; // Update for dashboard widgets
|
||||
console.log('[RPG Companion] Updated extensionSettings.infoBoxData:', extensionSettings.infoBoxData.substring(0, 100));
|
||||
}
|
||||
if (parsedData.characterThoughts) {
|
||||
lastGeneratedData.characterThoughts = parsedData.characterThoughts;
|
||||
extensionSettings.characterThoughts = parsedData.characterThoughts; // Update for dashboard widgets
|
||||
console.log('[RPG Companion] Updated extensionSettings.characterThoughts:', extensionSettings.characterThoughts.substring(0, 100));
|
||||
}
|
||||
|
||||
// Store RPG data for this specific swipe in the message's extra field
|
||||
@@ -160,12 +172,15 @@ export async function onMessageReceived(data) {
|
||||
|
||||
// console.log('[RPG Companion] Cleaned message, removed tracker code blocks');
|
||||
|
||||
// Render the updated data
|
||||
// Render the updated data (old panel UI)
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
|
||||
// Save to chat metadata
|
||||
saveChatData();
|
||||
}
|
||||
@@ -209,12 +224,23 @@ export function onCharacterChanged() {
|
||||
// Commit tracker data from the last assistant message to initialize for this chat
|
||||
commitTrackerData();
|
||||
|
||||
// Populate extensionSettings for dashboard widgets from loaded chat data
|
||||
if (lastGeneratedData.infoBox) {
|
||||
extensionSettings.infoBoxData = lastGeneratedData.infoBox;
|
||||
}
|
||||
if (lastGeneratedData.characterThoughts) {
|
||||
extensionSettings.characterThoughts = lastGeneratedData.characterThoughts;
|
||||
}
|
||||
|
||||
// Re-render with the loaded data
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
|
||||
// Update chat thought overlays
|
||||
updateChatThoughts();
|
||||
}
|
||||
|
||||
@@ -1553,26 +1553,29 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
|
||||
}
|
||||
|
||||
.rpg-weather-icon {
|
||||
font-size: 2rem;
|
||||
font-size: 1rem;
|
||||
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
|
||||
flex-shrink: 1;
|
||||
flex-shrink: 0;
|
||||
line-height: 1;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.rpg-weather-forecast {
|
||||
font-size: 0.65rem;
|
||||
font-size: 0.45rem;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.013em;
|
||||
opacity: 0.85;
|
||||
line-height: 1.1;
|
||||
line-height: 1;
|
||||
word-wrap: break-word;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.rpg-weather-forecast.rpg-editable {
|
||||
|
||||
Reference in New Issue
Block a user