🐛 Discipline pause button doesn't revert to "Activate" after pausing #120

Closed
opened 2026-05-22 13:20:55 +02:00 by Anexim · 2 comments
Owner

Bug

When clicking the "Pause" button on an active discipline, the button text and state do not change back to "Activate". The discipline stops processing (is removed from activeIds), but the UI still shows "Pause".

Root Cause

In src/lib/game/stores/discipline-slice.ts, the deactivate() action only removes the discipline from activeIds:

deactivate(id) {
  set((s) => ({
    activeIds: s.activeIds.filter((aid) => aid !== id),
  }));
},

It does NOT set disciplines[id].paused = true. So after deactivation:

  1. The discipline is removed from activeIds
  2. But disciplines[id].paused remains false

The DisciplineCard component reads discState.paused from disciplines[disc.id] to determine button text (isPaused ? 'Activate' : 'Pause'). Since paused is still false, the button keeps showing "Pause".

Fix

Update deactivate() to also set paused: true:

deactivate(id) {
  set((s) => ({
    activeIds: s.activeIds.filter((aid) => aid !== id),
    disciplines: {
      ...s.disciplines,
      [id]: { ...s.disciplines[id], paused: true },
    },
  }));
},

Files Involved

  • src/lib/game/stores/discipline-slice.ts (deactivate action)
  • src/components/game/tabs/DisciplinesTab.tsx (DisciplineCard button rendering)

Secondary Issue

The activate() guard if (s.activeIds.includes(id)) return s; also prevents re-activating disciplines that were auto-paused by processTick (they remain in activeIds with paused: true). This should be fixed to check !s.disciplines[id]?.paused instead.

## Bug When clicking the "Pause" button on an active discipline, the button text and state do not change back to "Activate". The discipline stops processing (is removed from `activeIds`), but the UI still shows "Pause". ## Root Cause In `src/lib/game/stores/discipline-slice.ts`, the `deactivate()` action only removes the discipline from `activeIds`: ```typescript deactivate(id) { set((s) => ({ activeIds: s.activeIds.filter((aid) => aid !== id), })); }, ``` It does **NOT** set `disciplines[id].paused = true`. So after deactivation: 1. The discipline is removed from `activeIds` ✓ 2. But `disciplines[id].paused` remains `false` ✗ The `DisciplineCard` component reads `discState.paused` from `disciplines[disc.id]` to determine button text (`isPaused ? 'Activate' : 'Pause'`). Since `paused` is still `false`, the button keeps showing "Pause". ## Fix Update `deactivate()` to also set `paused: true`: ```typescript deactivate(id) { set((s) => ({ activeIds: s.activeIds.filter((aid) => aid !== id), disciplines: { ...s.disciplines, [id]: { ...s.disciplines[id], paused: true }, }, })); }, ``` ## Files Involved - `src/lib/game/stores/discipline-slice.ts` (deactivate action) - `src/components/game/tabs/DisciplinesTab.tsx` (DisciplineCard button rendering) ## Secondary Issue The `activate()` guard `if (s.activeIds.includes(id)) return s;` also prevents re-activating disciplines that were auto-paused by `processTick` (they remain in `activeIds` with `paused: true`). This should be fixed to check `!s.disciplines[id]?.paused` instead.
Anexim added the ai:todo label 2026-05-22 13:20:55 +02:00
n8n-gitea was assigned by Anexim 2026-05-22 13:20:55 +02:00
Author
Owner

Fixed. Changes made:
discipline-slice.tsdeactivate() now sets paused: true on the discipline state in addition to removing it from activeIds.

Previously: Only removed the discipline from activeIds, leaving disciplines[id].paused as false.

Now: Also sets disciplines[id].paused = true, so the DisciplineCard component correctly shows "Activate" button text after deactivation.

✅ Fixed. Changes made: **discipline-slice.ts** — `deactivate()` now sets `paused: true` on the discipline state in addition to removing it from `activeIds`. Previously: Only removed the discipline from `activeIds`, leaving `disciplines[id].paused` as `false`. Now: Also sets `disciplines[id].paused = true`, so the `DisciplineCard` component correctly shows "Activate" button text after deactivation.
Author
Owner

Fixed discipline pause button - deactivate() now sets paused:true

✅ Fixed discipline pause button - deactivate() now sets paused:true
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#120