[Medium] [Bug] Earth element desync between localStorage and UI after Unlock All #338

Open
opened 2026-06-09 12:51:55 +02:00 by Anexim · 1 comment
Owner

Bug: Earth element desync between localStorage and UI

Steps to reproduce

  1. Open the game
  2. Go to Debug → Elements
  3. Click "Unlock All Elements"
  4. Check localStorage → mana-loop-manaelements.earth

Expected

All elements including earth show unlocked: true in localStorage, matching the UI.

Actual

The UI shows earth as unlocked (with 0/10 and a +10 button), but localStorage shows earth: { unlocked: false, ... }. This is a desync between the persisted state and the in-memory state.

Root cause

The handleUnlockAll function in ElementDebugSection.tsx calls handleUnlockElement(id) which calls useManaStore.getState().unlockElement(element, 0). The unlockElement function updates the in-memory state but the persist middleware may not be writing it correctly for all elements, or there's a race condition where the earth element's unlocked state is not being persisted.

Store

useManaStoremanaStore.tsunlockElement action

## Bug: Earth element desync between localStorage and UI ### Steps to reproduce 1. Open the game 2. Go to Debug → Elements 3. Click "Unlock All Elements" 4. Check localStorage → `mana-loop-mana` → `elements.earth` ### Expected All elements including `earth` show `unlocked: true` in localStorage, matching the UI. ### Actual The UI shows earth as unlocked (with 0/10 and a +10 button), but localStorage shows `earth: { unlocked: false, ... }`. This is a desync between the persisted state and the in-memory state. ### Root cause The `handleUnlockAll` function in `ElementDebugSection.tsx` calls `handleUnlockElement(id)` which calls `useManaStore.getState().unlockElement(element, 0)`. The `unlockElement` function updates the in-memory state but the persist middleware may not be writing it correctly for all elements, or there's a race condition where the earth element's unlocked state is not being persisted. ### Store `useManaStore` → `manaStore.ts` → `unlockElement` action
Anexim added the ai:todo label 2026-06-09 12:51:55 +02:00
n8n-gitea was assigned by Anexim 2026-06-09 12:51:55 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-09 19:10:00 +02:00
Author
Owner

Starting work. Investigating Earth element desync between localStorage and UI after Unlock All.

Starting work. Investigating Earth element desync between localStorage and UI after Unlock All.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#338