[High] [Bug] Discipline auto-pause flag not cleared on deactivate→reactivate, causing silent failure #351
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug Summary
When a discipline auto-pauses due to insufficient mana and the user manually deactivates then reactivates it, the
autoPausedflag is not cleared. The discipline appears active (button shows "Stop Practicing", it's inactiveIds) butprocessTicksilently skips it becausedisc.autoPaused === true. No mana is drained and no XP is accrued.Root Cause
In
src/lib/game/stores/discipline-slice.ts, theactivate()method has two code paths:activeIds): Correctly clearsautoPaused: false✅activeIds): Does{ ...discState, paused: false }which preserves the staleautoPaused: truefrom the previous auto-pause ❌The
deactivate()method setspaused: truebut does NOT clearautoPaused. Whenactivate()later spreads the existing state,autoPaused: truepersists.Reproduction Steps
raw-mastery) with sufficient manaautoPaused: true, still inactiveIds)deactivate()setspaused: true, removes fromactiveIdsactivate()re-adds toactiveIdswithpaused: falsebutautoPaused: trueprocessTickskips it (no drain, no XP)Evidence
Reproduction test at
src/lib/game/__tests__/discipline-auto-pause-reactivate-bug.test.ts:activeIds)Severity
High — Core gameplay loop is broken. The discipline system is a primary progression mechanic. Players lose progress silently with no feedback.
Files Involved
src/lib/game/stores/discipline-slice.ts—activate()anddeactivate()methodssrc/components/game/tabs/DisciplineCard.tsx— UI shows "Stop Practicing" for auto-paused disciplines (secondary issue:autoPausedstate not displayed)Suggested Fix
In
activate(), the new activation path should clearautoPaused:Also consider clearing
autoPausedindeactivate()for defense-in-depth.Starting work on fixing the discipline auto-pause flag not being cleared on deactivate→reactivate. Investigating the discipline store slice.
Fixed. Added
autoPaused: falseto the discipline deactivation logic indeactivate(). Previously, when a discipline was auto-paused (due to insufficient mana) and then manually deactivated, theautoPausedflag was not cleared. On re-activation, the discipline state still hadautoPaused: truewhich caused the activate function to silently skip re-activation. All 1158 tests pass.