[priority: critical] Debug "Reset Game" does not reset discipline state #195

Closed
opened 2026-05-29 13:05:06 +02:00 by Anexim · 2 comments
Owner

CRITICAL BUG: Debug reset leaves discipline state stale in memory

Bug Summary

The Debug panel's "Reset Game" button clears localStorage but does NOT reset the in-memory discipline store state, causing disciplines to persist across resets without a page refresh.

Root Cause

  • File: src/lib/game/stores/gameActions.ts, lines 21-44 (createResetGame)
  • Problem: The reset function calls reset() on UI, Prestige, Mana, and Combat stores, but NEVER calls useDisciplineStore.getState().resetDisciplines()
  • The resetDisciplines() function exists at src/lib/game/stores/discipline-slice.ts lines 158-165 but is never invoked by the reset logic

What Happens

  1. Player clicks "Reset Game" in Debug panel
  2. mana-loop-discipline-store key is deleted from localStorage
  3. Other stores (UI, Prestige, Mana, Combat) are properly reset
  4. Discipline store retains ALL in-memory state: XP, activeIds, concurrentLimit, totalXP, processedPerks
  5. Player sees disciplines still practiced with old XP values
  6. Only a page refresh would clear the stale discipline state

Additional State at Risk

The reset should also verify these stores are properly cleared:

  • Attunement store (attunement levels and XP)
  • Crafting store (equipment instances, designs, prepared equipment)
  • Any other store with persistent in-progress state

Steps to Reproduce

  1. Practice a discipline to gain some XP
  2. Open Debug panel → click "Reset Game"
  3. Check Disciplines tab - discipline XP and active state persist
  4. Check other progression systems (attunements, crafting) for stale state

Fix Required

Add useDisciplineStore.getState().resetDisciplines() to createResetGame() in gameActions.ts after the other reset* calls (around line 37). Also audit all other stores for similar missing reset calls.

Priority

CRITICAL - Debug reset is broken; also affects any future soft-reset functionality

**CRITICAL BUG: Debug reset leaves discipline state stale in memory** ### Bug Summary The Debug panel's "Reset Game" button clears localStorage but does NOT reset the in-memory discipline store state, causing disciplines to persist across resets without a page refresh. ### Root Cause - **File:** `src/lib/game/stores/gameActions.ts`, lines 21-44 (`createResetGame`) - **Problem:** The reset function calls `reset()` on UI, Prestige, Mana, and Combat stores, but NEVER calls `useDisciplineStore.getState().resetDisciplines()` - **The `resetDisciplines()` function exists** at `src/lib/game/stores/discipline-slice.ts` lines 158-165 but is never invoked by the reset logic ### What Happens 1. Player clicks "Reset Game" in Debug panel 2. `mana-loop-discipline-store` key is deleted from localStorage ✅ 3. Other stores (UI, Prestige, Mana, Combat) are properly reset ✅ 4. **Discipline store retains ALL in-memory state**: XP, activeIds, concurrentLimit, totalXP, processedPerks ❌ 5. Player sees disciplines still practiced with old XP values 6. Only a page refresh would clear the stale discipline state ### Additional State at Risk The reset should also verify these stores are properly cleared: - Attunement store (attunement levels and XP) - Crafting store (equipment instances, designs, prepared equipment) - Any other store with persistent in-progress state ### Steps to Reproduce 1. Practice a discipline to gain some XP 2. Open Debug panel → click "Reset Game" 3. Check Disciplines tab - discipline XP and active state persist 4. Check other progression systems (attunements, crafting) for stale state ### Fix Required Add `useDisciplineStore.getState().resetDisciplines()` to `createResetGame()` in `gameActions.ts` after the other `reset*` calls (around line 37). Also audit all other stores for similar missing reset calls. ### Priority CRITICAL - Debug reset is broken; also affects any future soft-reset functionality
Anexim added the ai:todo label 2026-05-29 13:05:06 +02:00
n8n-gitea was assigned by Anexim 2026-05-29 13:05:06 +02:00
Author
Owner

Starting investigation of debug reset not clearing discipline state.

Starting investigation of debug reset not clearing discipline state.
Author
Owner

Fixed: Added useDisciplineStore.getState().resetDisciplines(), useAttunementStore.getState().resetAttunements(), and useCraftingStore.getState().resetCrafting() to createResetGame() in gameActions.ts. Also added the resetCrafting() action to the crafting store (craftingStore.ts) and its type definition (craftingStore.types.ts), supported by a new createDefaultCraftingState() helper in crafting-initial-state.ts.

Fixed: Added useDisciplineStore.getState().resetDisciplines(), useAttunementStore.getState().resetAttunements(), and useCraftingStore.getState().resetCrafting() to createResetGame() in gameActions.ts. Also added the resetCrafting() action to the crafting store (craftingStore.ts) and its type definition (craftingStore.types.ts), supported by a new createDefaultCraftingState() helper in crafting-initial-state.ts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#195