You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Atomic cutover: replace flat position-and-clock fields in timerState with the Schedule module from #11. End-user behavior must remain identical — this is a pure refactor, but a risky one because every read and write site in src/lib/timer.js shifts at once.
Changes:
Drop phase, currentPeriodIndex, timestampStarted, timestampPaused from initialState. After this slice timerState shrinks to { periods, types }.
Switch every read of those four fields to the corresponding Schedule computed.
Switch every write (across all ~28 mutation sites) to the corresponding Schedule verb.
Wrap mixed verbs that touch both Schedule and Periods (moveToNextPeriod, moveToPreviousPeriod, addPeriod, etc.) in batch() so reactive subscribers don't see torn state.
Migrate persistence: the storage effect() reads a computed() snapshot of Schedule.snapshot + periods; loadState parses persisted shape into Schedule + periods at boot.
Update src/lib/timer-simple.test.js to read phase/index via Schedule computeds.
updateTimerState's timerProperties branch becomes dead code after this slice but is not deleted yet — that's slice 3 (#TBD).
Acceptance criteria
phase, currentPeriodIndex, timestampStarted, timestampPaused are no longer in initialState; timerState is { periods, types }
All reads of those four fields go through Schedule computeds
All writes go through Schedule verbs
Mixed Schedule+Period verbs are wrapped in batch()
Storage round-trips correctly: a persisted state from before this slice loads into the new shape (or, if backward compatibility is out of scope per project memory, fresh persistence works)
src/lib/timer-simple.test.js and src/lib/schedule.test.js both pass
pnpm test and pnpm run build both pass
Manual QA passes for: start, pause, resume, complete (last period), navigate forward, navigate backward, edit Current Period duration, edit Past Period duration, edit Future Period duration, reset, browser reload mid-run, browser reload while paused
Parent
#10
What to build
Atomic cutover: replace flat position-and-clock fields in
timerStatewith the Schedule module from #11. End-user behavior must remain identical — this is a pure refactor, but a risky one because every read and write site insrc/lib/timer.jsshifts at once.Changes:
phase,currentPeriodIndex,timestampStarted,timestampPausedfrominitialState. After this slicetimerStateshrinks to{ periods, types }.moveToNextPeriod,moveToPreviousPeriod,addPeriod, etc.) inbatch()so reactive subscribers don't see torn state.effect()reads acomputed()snapshot ofSchedule.snapshot+ periods;loadStateparses persisted shape into Schedule + periods at boot.src/lib/timer-simple.test.jsto read phase/index via Schedule computeds.updateTimerState'stimerPropertiesbranch becomes dead code after this slice but is not deleted yet — that's slice 3 (#TBD).Acceptance criteria
phase,currentPeriodIndex,timestampStarted,timestampPausedare no longer ininitialState;timerStateis{ periods, types }batch()src/lib/timer-simple.test.jsandsrc/lib/schedule.test.jsboth passpnpm testandpnpm run buildboth passBlocked by