Demo mode destroys the user's real data permanently #18

Closed
opened 2026-08-30 20:10:46 +00:00 by uwayss · 2 comments
Owner
No description provided.
uwayss changed title from Bug: Demo mode destroys the user's real data permanently to Demo mode destroys the user's real data permanently 2026-08-30 20:11:09 +00:00
Author
Owner

@claude take a look and fix it please. push to a branch and create a PR and i'll take a look

@claude take a look and fix it please. push to a branch and create a PR and i'll take a look
Collaborator

Fixed: demo mode was silently overwriting real user data

Root cause (src/core/store/appStore.ts): persistState() tried to figure out which data was "real" vs. demo by re-reading useAppStore.getState() — but that's the exact same in-memory store that had just been overwritten with MOCK_DEEDS/fake demo logs when demo mode turned on. The check was circular, not an actual fallback to disk. So any store action while demo mode was active (logging a prayer, adding a deed, etc.) wrote the fake demo data straight to disk, permanently overwriting the user's real save file. Turning demo mode back off then reloaded from disk — which now only held demo data — so the user's real deeds/logs were gone for good.

Fix: added a realDeeds/realLogs slice to the store that holds the user's actual data and is never touched while demo mode is on. All mutating actions route through a small helper that updates the displayed deeds/logs always, but only syncs realDeeds/realLogs when demo mode is off. persistState() now always writes from realDeeds/realLogs, so demo data can never reach disk.

Verified npm run checks:tsc and npm run checks:lint pass (only pre-existing, unrelated formatting warnings).

Pushed to branch claude/fix-demo-mode-data-loss and opened PR: #22

## Fixed: demo mode was silently overwriting real user data **Root cause** (`src/core/store/appStore.ts`): `persistState()` tried to figure out which data was "real" vs. demo by re-reading `useAppStore.getState()` — but that's the exact same in-memory store that had just been overwritten with `MOCK_DEEDS`/fake demo logs when demo mode turned on. The check was circular, not an actual fallback to disk. So any store action while demo mode was active (logging a prayer, adding a deed, etc.) wrote the fake demo data straight to disk, permanently overwriting the user's real save file. Turning demo mode back off then reloaded from disk — which now only held demo data — so the user's real deeds/logs were gone for good. **Fix**: added a `realDeeds`/`realLogs` slice to the store that holds the user's actual data and is never touched while demo mode is on. All mutating actions route through a small helper that updates the displayed `deeds`/`logs` always, but only syncs `realDeeds`/`realLogs` when demo mode is off. `persistState()` now always writes from `realDeeds`/`realLogs`, so demo data can never reach disk. Verified `npm run checks:tsc` and `npm run checks:lint` pass (only pre-existing, unrelated formatting warnings). Pushed to branch `claude/fix-demo-mode-data-loss` and opened PR: **https://code.uwayss.com/uwayss/muhsin/pulls/22**
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
uwayss/muhsin#18
No description provided.