fix(dashboard): fix persistent px values, auto-layout, widget loss, gaps, and tabs

This commit resolves 6 critical dashboard issues reported by user:

1. **Persistent px values causing 264rem widget heights**
   - Root cause: state.js had hardcoded rowHeight: 80, gap: 12 (px)
   - Root cause: index.js double-loaded layout, overwriting migration
   - Fix: Changed state.js gridConfig to rem units (5, 0.75)
   - Fix: Removed redundant applyDashboardConfig in index.js
   - Fix: Added migration in layoutPersistence.js for old saves
   - Dashboard now uses rem consistently throughout

2. **Auto-layout on first load**
   - Added auto-layout in loadLayout() when no saved layout exists
   - Prevents overlap from hardcoded default positions
   - Saves auto-laid-out result as initial layout

3. **Reset layout causes overlap**
   - Added auto-layout loop in resetLayout() after applying config
   - Each tab auto-lays out to prevent widget overlap

4. **Auto-arrange loses inventory/social widgets**
   - Fixed autoLayoutWidgets to gather ALL widgets from ALL tabs
   - Previously only gathered current tab, lost other tabs
   - Now always uses multi-tab distribution to preserve all widgets

5. **Auto-arrange leaves 2x2 gaps**
   - Added compact pass in gridEngine.js after bin-packing
   - Moves widgets upward to fill gaps
   - Eliminates empty spaces at bottom of layout

6. **Tabs not compact (icon-only)**
   - Updated tab styling: icons only, names show on hover
   - Allows more tabs in compact space
   - min-width: 2.5rem, larger icon size

Also added debug logging to track config values through initialization.

Fixes refresh sizing bug, reset overlap, widget loss, and layout gaps.
This commit is contained in:
Lucas 'Paperboy' Rose-Winters
2025-10-23 19:32:27 +11:00
parent 79582070f0
commit c4485971fa
6 changed files with 121 additions and 51 deletions
@@ -148,6 +148,17 @@ export class LayoutPersistence {
const layoutData = JSON.parse(stored);
// Migrate old pixel values to rem units
if (layoutData.gridConfig) {
// Check if we have old pixel values (rowHeight > 20 is likely pixels)
if (layoutData.gridConfig.rowHeight > 20) {
console.log('[LayoutPersistence] Migrating old px values to rem');
layoutData.gridConfig.rowHeight = 5; // 80px → 5rem
layoutData.gridConfig.gap = 0.75; // 12px → 0.75rem
console.log('[LayoutPersistence] Converted gridConfig: rowHeight=5rem, gap=0.75rem');
}
}
// Validate loaded data
if (!this.validateDashboard(layoutData)) {
throw new Error('Loaded layout is invalid');