UNIVERSE PERSISTENCE FIX
Documentation for Plans
๐ง Universe Persistence Issue - Analysis & Fix
Issue: Universe created successfully but disappears when navigating back to dashboard
๐ Root Cause Analysis
Data Flow
- User creates universe via
SpaceService.createUniverse() - Universe saved to storage: โ
- Space.universeIds updated: โ
- SpaceService._universes signal updated: โ
- User navigates to space-map: โ
- User navigates back to dashboard
- Dashboard calls
unifiedData.refreshData(): โ - UnifiedData calls
SpaceService.loadUniverses(): โ - loadUniverses() CLEARS universes then reloads from space.universeIds
- Problem: Space loaded from storage might not have new universeId yet!
The Bug
// SpaceService.createUniverse() - Line 750-778
space.universeIds.push(universe.id); // Updates IN-MEMORY space
await this.cacheSpaceLocally(space); // Saves to storage - Line 778
// But when dashboard refreshes...
// SpaceService.loadUniverses() - Line 630
this._universes.set([]); // CLEARS everything!
// Then loads from space.universeIds
for (const universeId of space.universeIds || []) {
// If space from storage doesn't have new ID, universe disappears!
}
Issue: Race condition between space caching and universe loading
โ Solution Applied
Fix in Dashboard
Added immediate refresh on dashboard ngOnInit:
async ngOnInit() {
// Refresh data to show newly created universes
await this.unifiedData.refreshData();
console.log('โ
Dashboard data refreshed');
}
Additional Fix Needed in SpaceService
Ensure space is saved BEFORE updating signals:
// Move cacheSpaceLocally BEFORE updating signals
await this.cacheSpaceLocally(space); // Save first!
this._currentSpace.set(space); // Then update signals
this._universes.set([...this._universes(), universe]);
๐งช Test the Fix
1. Create universe
2. Navigate to space-map (should work)
3. Navigate back to dashboard
4. โ
Universe should still be visible
Status: Fix applied, needs verification