fix: prevent demo mode from overwriting real user data #22
No reviewers
Labels
No labels
bug
code
docs
duplicate
enhancement
help wanted
invalid
question
styles
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
uwayss/muhsin!22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/fix-demo-mode-data-loss"
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?
Fixes #18 — Demo mode could permanently destroy the user's real data.
Problem
persistState()tried to distinguish "real" data from demo data by checkinguseAppStore.getState(), but that's the same in-memory store that had just been overwritten withMOCK_DEEDS/ fake demo logs when demo mode was enabled — it was circular, not a real fallback to disk. As a result, any store action while demo mode was active (logging a deed, adding a deed, etc.) would write the fake demo data to disk, overwriting the user's real save file. Turning demo mode back off then reloaded from disk, which now only contained demo data — the user's real deeds/logs were gone for good.Fix
Added a
realDeeds/realLogsslice to the store that holds the user's actual data and is never touched by demo mode. All mutating actions now route through a small helper (applyDeedDataUpdate) that updates the displayeddeeds/logsalways, but only updatesrealDeeds/realLogswhen demo mode is off.persistState()now always saves fromrealDeeds/realLogs, so demo data can never reach disk.Test plan
npm run checks:tscpassesnpm run checks:lintpasses (pre-existing unrelated warnings only)935cf5c165ca25231851