PERSISTENCE BUG DIAGNOSTIC CHANGES
Documentation for Plans
๐ฌ Universe Persistence Bug - Diagnostic Changes
Date: November 3, 2025
Status: DIAGNOSTIC LOGGING ADDED
Next Step: TEST & ANALYZE LOGS
๐ Summary
Added comprehensive diagnostic logging to SpaceService to identify exactly why universes disappear after page refresh. The enhanced logging will reveal the root cause by tracking every step of universe loading and validation.
๐ง Changes Made
1. Enhanced SpaceService Logging
File: libs/core-angular/src/lib/services/space.service.ts
loadUniverses() Method
Added detailed logging for:
- Space details before loading (ID, slug, universeIds array)
- Each universe check from storage (found/not found)
- Validation for each universe (spaceId comparison)
- Whether each universe will be included or filtered out
initializeFromApi() Method
Enhanced merge logging to show:
- Backend universe IDs
- Local universe IDs
- Valid local IDs (after validation)
- Merged IDs (final result)
- What backend returns after sync
Key diagnostic logs to watch for:
๐ Loading universes for space: {spaceId, spaceSlug, universeIds, ...}
๐ Checking universe from storage: {universeId, found, ...}
๐ Validating universe: {universeSpaceId, currentSpaceId, hasSpaceId, idsMatch, willBeIncluded}
โ
Universe INCLUDED: <name>
โ Universe missing spaceId property, filtering out
โ Universe does not belong to current space, filtering out
โ Universe not found in storage
๐ Merging validated universeIds from local storage: {backendIds, localIds, validLocalIds, mergedIds}
๐ Backend returned after sync: {returnedUniverseIds, returnedCount, sentCount}
2. Debug Utility
File: libs/core-angular/src/lib/utils/debug-universe-storage.ts
Created a comprehensive debug utility that can be run in the console:
debugUniverseStorage()
What it shows:
- Current space details (ID, slug, name, universeIds array)
- All universe keys in IndexedDB
- Detailed validation for each universe:
- Universe ID and name
- Universe spaceId vs current space ID
- Whether IDs match
- Whether universe is in space.universeIds array
- Full universe object for inspection
- Summary statistics
Usage:
- Open DevTools Console
- Run:
debugUniverseStorage() - Inspect the grouped output
3. Global Exposure
Files:
apps/gograb-space/src/main.tslibs/core-angular/src/lib/utils/index.tslibs/core-angular/src/index.ts
Exposed services globally for debugging:
window.__spaceService__- Access to SpaceService instancewindow.__ggStorageInstance__- Access to GgStorage instancewindow.debugUniverseStorage()- Debug utility functionwindow.clearCachedSpaceData()- Existing cleanup utility
๐งช Testing Instructions
See PERSISTENCE_BUG_TESTING.md for detailed test procedure.
Quick test:
- Clear browser data:
clearCachedSpaceData() - Create universe: "Test Universe Persist"
- Navigate to Space Map (universe visible)
- Refresh page (F5)
- Check console for diagnostic logs
- Navigate to Dashboard
- Run:
debugUniverseStorage()to inspect state
๐ Expected Findings
The diagnostic logs will reveal ONE of these issues:
1. Universe Missing spaceId
Log pattern:
โ Universe missing spaceId property, filtering out
universeSpaceId: undefined
Fix: Ensure universe is created with spaceId in createUniverse()
2. Space ID Mismatch
Log pattern:
โ Universe does not belong to current space
universeSpaceId: "different-id"
currentSpaceId: "69067c087ebb621cd9ff8c3f"
Fix: Ensure space ID consistency across sessions
3. Universe Not in Storage
Log pattern:
โ Universe not found in storage
storageKey: "universe_universe_xxxxx"
Fix: Ensure universe save completes before navigation
4. Backend Loses Data
Log pattern:
๐ Backend returned after sync:
returnedUniverseIds: []
sentCount: 1
Fix: Backend not persisting universeIds properly
5. Merge Filters Out Valid Universe
Log pattern:
๐ Merging validated universeIds from local storage:
validLocalIds: []
filteredOut: 1
Fix: Merge validation logic too strict
๐ What to Share
When you test and see the issue, please share:
Complete console logs from:
- Universe creation
- Navigation to space-map
- Page refresh
- Navigation to dashboard
debugUniverseStorage() output showing:
- Current space details
- Universe validation results
- Summary statistics
Screenshot of dashboard showing:
- Universe count (should be 1, probably shows 0)
- Any error messages
๐ก Next Steps
After analyzing the logs, we will:
- Identify root cause from diagnostic output
- Implement targeted fix for the specific issue
- Remove diagnostic logging (keep it clean for production)
- Add automated test to prevent regression
Current Status: Ready for diagnostic testing
Estimated Time: 5-10 minutes to test and capture logs
Expected Outcome: Clear identification of failure point
๐ฏ Goal
By the end of this diagnostic session, we will know exactly where and why the universe is being lost, allowing us to implement a precise fix rather than guessing.