Bug: Cannot reactivate raw-mana disciplines after deactivating them #214

Closed
opened 2026-05-30 19:46:57 +02:00 by Anexim · 0 comments
Owner

Bug Description

When a player deactivates a discipline (e.g. Raw Mana Mastery) and tries to reactivate it by clicking the button in the Disciplines tab, the reactivation silently fails. The discipline remains inactive with no error message.

Root Cause

Two-part bug:

  1. UI layer (src/components/game/tabs/DisciplinesTab.tsx line 92): rawMana is read from the mana store and included in the useCallback dependency array, but is never passed to activate():

    activate(id, { elements, signedPacts }); // missing rawMana!
    
  2. API layer (src/lib/game/stores/discipline-slice.ts): The activate method's type signature doesn't include rawMana in the gameState parameter:

    activate: (id: string, gameState?: { elements?: Record<string, ElementState>; signedPacts?: number[] }) => void;
    

When gameState is provided but rawMana is undefined, canProceedDiscipline() in discipline-math.ts evaluates (undefined || 0) >= drainfalse, silently blocking reactivation.

Reproduction

  1. Activate Raw Mana Mastery discipline
  2. Deactivate it
  3. Try to reactivate it → silently fails, discipline stays inactive

Fix Required

  1. Add rawMana to the activate method's gameState type in discipline-slice.ts
  2. Pass rawMana from DisciplinesTab.tsx: activate(id, { elements, signedPacts, rawMana })
  3. Also fix DisciplineDebugSection.tsx which has the same issue

Existing Test

The test in discipline-reactivate-bug.test.ts passes because it directly passes rawMana: 1000 in the gameState, bypassing the broken UI layer. The test should be updated to also test the UI code path.

## Bug Description When a player deactivates a discipline (e.g. Raw Mana Mastery) and tries to reactivate it by clicking the button in the Disciplines tab, the reactivation silently fails. The discipline remains inactive with no error message. ## Root Cause Two-part bug: 1. **UI layer** (`src/components/game/tabs/DisciplinesTab.tsx` line 92): `rawMana` is read from the mana store and included in the `useCallback` dependency array, but is **never passed** to `activate()`: ```ts activate(id, { elements, signedPacts }); // missing rawMana! ``` 2. **API layer** (`src/lib/game/stores/discipline-slice.ts`): The `activate` method's type signature doesn't include `rawMana` in the `gameState` parameter: ```ts activate: (id: string, gameState?: { elements?: Record<string, ElementState>; signedPacts?: number[] }) => void; ``` When `gameState` is provided but `rawMana` is undefined, `canProceedDiscipline()` in `discipline-math.ts` evaluates `(undefined || 0) >= drain` → `false`, silently blocking reactivation. ## Reproduction 1. Activate Raw Mana Mastery discipline 2. Deactivate it 3. Try to reactivate it → silently fails, discipline stays inactive ## Fix Required 1. Add `rawMana` to the `activate` method's `gameState` type in `discipline-slice.ts` 2. Pass `rawMana` from `DisciplinesTab.tsx`: `activate(id, { elements, signedPacts, rawMana })` 3. Also fix `DisciplineDebugSection.tsx` which has the same issue ## Existing Test The test in `discipline-reactivate-bug.test.ts` passes because it directly passes `rawMana: 1000` in the gameState, bypassing the broken UI layer. The test should be updated to also test the UI code path.
Anexim added the ai:todo label 2026-05-30 19:46:57 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 19:46:57 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#214