From ded3694d5442c5b1fb360498981a06ce6ee3a0d3 Mon Sep 17 00:00:00 2001 From: Lucas 'Paperboy' Rose-Winters Date: Sun, 2 Nov 2025 17:28:15 +1100 Subject: [PATCH] fix(dashboard): resolve widget sizing and detection issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue 1: PresentCharacters widget too small with gaps - Increase height from h:3 to h:4 in defaultLayout.js - Widget's defaultSize is h:2 but layout had h:3, creating mismatch - Now properly fills vertical space without gaps Issue 2: Recent Events not appearing in reset/auto-arrange Root cause: previousTrackerConfig starts as null, preventing widget detection Fixes: - Initialize previousTrackerConfig on dashboard load (dashboardIntegration.js) - Deep clone trackerConfig after dashboard init - Enables detectConfigChanges() to work on first load - Reset previousTrackerConfig to null in resetLayout() (dashboardManager.js) - Ensures fresh detection after layout reset - Prevents stale comparison data Verified: Recent Events enabled by default in tracker config (state.js:95) Result: ✅ PresentCharacters fills space properly ✅ Recent Events appears in reset layout ✅ Recent Events appears in auto-arrange ✅ Tracker editor enable/disable now works correctly --- src/systems/dashboard/dashboardIntegration.js | 8 ++++++++ src/systems/dashboard/dashboardManager.js | 5 +++++ src/systems/dashboard/defaultLayout.js | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/systems/dashboard/dashboardIntegration.js b/src/systems/dashboard/dashboardIntegration.js index 7878c08..aa9f816 100644 --- a/src/systems/dashboard/dashboardIntegration.js +++ b/src/systems/dashboard/dashboardIntegration.js @@ -104,6 +104,14 @@ export async function initializeDashboard(dependencies) { dashboardManager.setDefaultLayout(defaultLayout); console.log('[RPG Companion] Default layout set with', defaultLayout.tabs.length, 'tabs'); + // Initialize previousTrackerConfig to enable widget detection on first load + // Without this, detectConfigChanges() returns [] because oldConfig is null + const settings = dependencies.getExtensionSettings(); + if (settings?.trackerConfig && dashboardManager) { + dashboardManager.previousTrackerConfig = JSON.parse(JSON.stringify(settings.trackerConfig)); + console.log('[RPG Companion] Initialized previousTrackerConfig for widget detection'); + } + // Set up dashboard event listeners setupDashboardEventListeners(dependencies); diff --git a/src/systems/dashboard/dashboardManager.js b/src/systems/dashboard/dashboardManager.js index 2358e99..56abb18 100644 --- a/src/systems/dashboard/dashboardManager.js +++ b/src/systems/dashboard/dashboardManager.js @@ -1439,6 +1439,11 @@ export class DashboardManager { console.log('[DashboardManager] Regenerating fresh default layout...'); this.defaultLayout = generateDefaultDashboard(); + // Reset previousTrackerConfig for fresh widget detection + // This ensures the comparison logic works correctly after reset + this.previousTrackerConfig = null; + console.log('[DashboardManager] Reset previousTrackerConfig for fresh widget detection'); + if (!this.defaultLayout) { console.warn('[DashboardManager] Failed to generate default layout'); return; diff --git a/src/systems/dashboard/defaultLayout.js b/src/systems/dashboard/defaultLayout.js index 092d169..db994d1 100644 --- a/src/systems/dashboard/defaultLayout.js +++ b/src/systems/dashboard/defaultLayout.js @@ -155,14 +155,14 @@ export function generateDefaultDashboard() { maxEvents: 3 } }, - // Row 6-8: Present Characters (full width, will expand with auto-layout) + // Row 6-10: Present Characters (full width, will expand with auto-layout) { id: 'widget-presentchars', type: 'presentCharacters', x: 0, y: 6, w: 2, - h: 3, + h: 4, config: { cardLayout: 'grid', showThoughtBubbles: true