[Mnemosyne] Persist spatial memory state to localStorage #1158

Closed
opened 2026-04-10 12:42:04 +00:00 by Rockachopa · 2 comments
Owner

What

The Spatial Memory Schema (merged in #1156) maps memories to 3D regions, but all state is lost on page reload. Memories need to survive across sessions.

Why

A holographic archive that forgets everything when you close the browser is not an archive. Persistence is the foundation that makes every future Mnemosyne feature (search, ingestion, decay) meaningful.

How

  1. Auto-save on change: Call SpatialMemory.exportIndex() and save to localStorage whenever a memory is placed or removed
  2. Auto-load on init: In SpatialMemory.init(), check for saved state and restore via importIndex()
  3. Change detection: Only write when the index actually changed (avoid thrashing on every update tick)
  4. Quota handling: Wrap localStorage.setItem in try/catch — if quota exceeded, prune oldest archive-region memories first

Acceptance Criteria

  • Place a memory, reload page, memory reappears in same position
  • Remove a memory, reload page, memory stays removed
  • Console shows [SpatialMemory] Saved N memories to localStorage on save
  • Console shows [SpatialMemory] Restored N memories from localStorage on load
  • Graceful degradation if localStorage unavailable (no crash, just warn)
## What The Spatial Memory Schema (merged in #1156) maps memories to 3D regions, but all state is lost on page reload. Memories need to survive across sessions. ## Why A holographic archive that forgets everything when you close the browser is not an archive. Persistence is the foundation that makes every future Mnemosyne feature (search, ingestion, decay) meaningful. ## How 1. **Auto-save on change**: Call `SpatialMemory.exportIndex()` and save to `localStorage` whenever a memory is placed or removed 2. **Auto-load on init**: In `SpatialMemory.init()`, check for saved state and restore via `importIndex()` 3. **Change detection**: Only write when the index actually changed (avoid thrashing on every update tick) 4. **Quota handling**: Wrap `localStorage.setItem` in try/catch — if quota exceeded, prune oldest archive-region memories first ## Acceptance Criteria - [ ] Place a memory, reload page, memory reappears in same position - [ ] Remove a memory, reload page, memory stays removed - [ ] Console shows `[SpatialMemory] Saved N memories to localStorage` on save - [ ] Console shows `[SpatialMemory] Restored N memories from localStorage` on load - [ ] Graceful degradation if localStorage unavailable (no crash, just warn)
Timmy was assigned by Rockachopa 2026-04-10 12:42:04 +00:00
Author
Owner

Claiming this issue

Claiming this issue
Author
Owner

PR submitted: #1159

Adds localStorage persistence — auto-saves on memory place/remove, auto-restores on page load, handles quota exhaustion by pruning archive memories.

PR submitted: #1159 Adds localStorage persistence — auto-saves on memory place/remove, auto-restores on page load, handles quota exhaustion by pruning archive memories.
Timmy closed this issue 2026-04-10 19:03:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/the-nexus#1158