PERSISTENCE BUG TESTING

Documentation for Plans

๐Ÿงช Universe Persistence Bug - Diagnostic Testing

Date: November 3, 2025
Status: DIAGNOSTIC LOGGING ADDED
Goal: Find why universes disappear after refresh


๐Ÿ”ฌ What Was Added

Enhanced logging in SpaceService to trace every step:

  1. Universe Loading - Shows what universeIds the space has
  2. Storage Checks - Verifies each universe exists in storage
  3. Validation - Shows spaceId comparison for each universe
  4. Merge Logic - Shows what IDs are merged from backend/local
  5. Backend Sync - Shows what backend returns after sync

๐Ÿงช Test Procedure

Step 1: Clear Browser State

IMPORTANT: Start fresh to avoid old data interfering

  1. Open DevTools Console (F12)
  2. Run: clearCachedSpaceData()
  3. Or manually: Clear IndexedDB โ†’ Delete "gograb-space" database
  4. Refresh page

NEW: You can also run debugUniverseStorage() at any time to see:

Step 2: Create Universe

  1. Navigate to: http://localhost:5200/chrome-space-1/dashboard
  2. Click "Create Universe"
  3. Fill form:
    • Name: "Test Universe Persist"
    • Description: "Testing persistence"
  4. Click "Create Universe"
  5. WATCH CONSOLE: Look for these logs:
    [SpaceService] ๐Ÿ’พ Universe saved to local storage
    [SpaceService] ๐ŸŒ Syncing space to backend with new universe...
    [SpaceService] โœ… Space synced to backend with universeIds
    

Step 3: Navigate to Space Map

  1. Should see universe in the overview
  2. WATCH CONSOLE: Look for:
    [SpaceService] ๐Ÿ” Loading universes for space:
    [SpaceService] ๐Ÿ” Checking universe from storage:
    [SpaceService] ๐Ÿ” Validating universe:
    [SpaceService] โœ… Universe INCLUDED: Test Universe Persist
    

Step 4: Refresh Page (THE CRITICAL TEST)

  1. Press F5 to refresh
  2. WATCH CONSOLE CAREFULLY: Look for:
    [SpaceService] ๐Ÿ” Merging validated universeIds from local storage:
    [SpaceService] ๐Ÿ” Backend returned after sync:
    [SpaceService] ๐Ÿ” Loading universes for space:
    [SpaceService] ๐Ÿ” Checking universe from storage:
    [SpaceService] ๐Ÿ” Validating universe:
    

Step 5: Navigate to Dashboard

  1. Click "Dashboard" in sidebar
  2. WATCH CONSOLE: Look for universe validation logs
  3. Check dashboard: Does it show 0 or 1 universe?

๐Ÿ” What To Look For

โœ… GOOD SIGNS (Universe Persists)

[SpaceService] ๐Ÿ” Validating universe:
  universeId: "universe_xxxxx"
  universeName: "Test Universe Persist"
  universeSpaceId: "69067c087ebb621cd9ff8c3f"  โœ… Has spaceId
  currentSpaceId: "69067c087ebb621cd9ff8c3f"   โœ… Matches
  hasSpaceId: true                              โœ…
  idsMatch: true                                โœ…
  willBeIncluded: true                          โœ…

[SpaceService] โœ… Universe INCLUDED: Test Universe Persist

โŒ BAD SIGNS (Universe Lost)

Missing spaceId:

[SpaceService] โŒ Universe missing spaceId property, filtering out
  universeSpaceId: undefined                    โŒ No spaceId!
  currentSpaceId: "69067c087ebb621cd9ff8c3f"

Space ID Mismatch:

[SpaceService] โŒ Universe does not belong to current space
  universeSpaceId: "some-other-space-id"       โŒ Wrong spaceId!
  currentSpaceId: "69067c087ebb621cd9ff8c3f"

Not Found in Storage:

[SpaceService] โŒ Universe not found in storage
  universeId: "universe_xxxxx"                  โŒ Not in storage!
  storageKey: "universe_universe_xxxxx"

Backend Returned Empty:

[SpaceService] ๐Ÿ” Backend returned after sync:
  returnedUniverseIds: []                       โŒ Backend lost data!
  returnedCount: 0
  sentCount: 1

๐Ÿ“Š Copy ALL Console Logs

When you see the issue, copy the ENTIRE console output from:

  1. Universe creation
  2. Navigation to space-map
  3. Page refresh
  4. Navigation to dashboard

Send the logs so we can pinpoint the exact failure point.


๐Ÿ’ก Expected Diagnosis

The enhanced logging will reveal ONE of these issues:

  1. Universe not saved with spaceId โ†’ Fix createUniverse()
  2. Space ID changed between creation and reload โ†’ Fix initializeSpace()
  3. Backend not returning universeIds โ†’ Fix backend API
  4. Storage key mismatch โ†’ Fix storage.get() key
  5. Merge logic filtering out valid universes โ†’ Fix merge validation

Ready to test! ๐Ÿš€
Run the test procedure and share the console logs.