From c5a888c3bfad70eb5e963d0f704e80fbbd9635cc Mon Sep 17 00:00:00 2001 From: Lucas 'Paperboy' Rose-Winters Date: Thu, 6 Nov 2025 21:04:07 +1100 Subject: [PATCH] fix: prevent blank screen for new users migrating to widget dashboard Fixed critical initialization timing bug where new users saw a blank screen with error "Tab not found: main" when migrating from v1.x to v2.0. Root Cause: - dashboardManager.init() created a premature fallback "main" tab before loading the default layout - TabManager was initialized with activeTabId='main' - loadLayout() then replaced tabs with proper IDs ('tab-status', etc.) - TabManager still referenced the non-existent 'main' tab - Result: blank screen Changes: 1. Removed premature fallback tab creation (lines 189-198) - Default layout is always set via setDefaultLayout() before init() - No need to create "main" tab before layout loads 2. Added safety check after loadLayout() completes (line 1506-1520) - If no tabs exist after loading, create emergency fallback - Uses correct tab ID 'tab-status' instead of 'main' - Updates TabManager's activeTab to match Flow now: - init() creates TabManager with empty tabs - loadLayout() populates tabs from default or saved layout - Safety check ensures at least one tab exists - TabManager references only valid tab IDs Fixes blank screen bug for users migrating from v1.x to v2.0. --- src/systems/dashboard/dashboardManager.js | 30 ++++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/systems/dashboard/dashboardManager.js b/src/systems/dashboard/dashboardManager.js index c0003d9..eb000fb 100644 --- a/src/systems/dashboard/dashboardManager.js +++ b/src/systems/dashboard/dashboardManager.js @@ -185,18 +185,8 @@ export class DashboardManager { }); // Initialize Tab Manager with dashboard data structure - // Create default tab if no tabs exist - if (this.dashboard.tabs.length === 0) { - this.dashboard.tabs.push({ - id: 'main', - name: 'Main', - icon: 'fa-solid fa-house', - order: 0, - widgets: [] - }); - this.dashboard.defaultTab = 'main'; - } - + // Note: Tabs will be populated by loadLayout() which runs after init() + // Default layout is set via setDefaultLayout() before init() is called this.tabManager = new TabManager(this.dashboard); // Set current tab to active tab from TabManager @@ -1512,6 +1502,22 @@ export class DashboardManager { this.applyDashboardConfig(this.defaultLayout); } } + + // Safety check: If still no tabs after loading, create emergency fallback + // This should never happen if setDefaultLayout() was called properly + if (this.dashboard.tabs.length === 0) { + console.warn('[DashboardManager] No tabs loaded, creating emergency fallback'); + this.dashboard.tabs.push({ + id: 'tab-status', + name: 'Status', + icon: 'fa-solid fa-user', + order: 0, + widgets: [] + }); + this.dashboard.defaultTab = 'tab-status'; + // Update TabManager's active tab + this.tabManager.setActiveTab('tab-status'); + } } /**