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
+35 -1
View File
@@ -528,7 +528,41 @@ export class GridEngine {
console.log(`[GridEngine] Auto-layout positioned: ${widget.id} at (${pos.x},${pos.y}) size ${targetW}×${targetH}`);
});
console.log('[GridEngine] Auto-layout complete');
// Compact pass: Move widgets up to fill gaps
console.log('[GridEngine] Compacting layout to fill gaps...');
let compactedCount = 0;
// Sort widgets by current Y position (process top to bottom)
const sortedForCompact = [...sorted].sort((a, b) => a.y - b.y);
sortedForCompact.forEach(widget => {
const originalY = widget.y;
// Try to move widget up as far as possible
for (let tryY = 0; tryY < originalY; tryY++) {
// Clear current position from occupied map
for (let row = originalY; row < originalY + widget.h; row++) {
for (let col = widget.x; col < widget.x + widget.w; col++) {
occupied.delete(`${col},${row}`);
}
}
// Check if new position is free
if (isFree(widget.x, tryY, widget.w, widget.h)) {
// Move widget up
widget.y = tryY;
markOccupied(widget, widget.x, tryY, widget.w, widget.h);
compactedCount++;
console.log(`[GridEngine] Compacted ${widget.id} from y=${originalY} to y=${tryY}`);
break;
} else {
// Re-mark original position and continue
markOccupied(widget, widget.x, originalY, widget.w, widget.h);
}
}
});
console.log(`[GridEngine] Auto-layout complete (compacted ${compactedCount} widgets)`);
return widgets;
}
}