Skip to content

Weekly routine that generates future time blocks - #51

Merged
ReinaldoAssis merged 1 commit into
mainfrom
feat/weekly-routine
Oct 22, 2026
Merged

ReinaldoAssis merged 1 commit into
mainfrom
feat/weekly-routine

Conversation

@ReinaldoAssis

Copy link
Copy Markdown
Owner

Why

The Time module only had one-off blocks. This adds a default week that keeps the planner filled: paint the routine once and the app creates the concrete blocks for the next 8 weeks, updating them when the routine changes.

Model

  • RoutineState = { revision, blocks[] } in the snapshot; a block is { weekday, startMinutes, durationMinutes, categoryId, title } (no dates).
  • Stored as a shared_settings singleton (routine), so it syncs LWW with lifeForce, finance and dailyGoal.
  • Generated blocks carry routineId + routineRevision and use deterministic ids (routine-<id>-<date>), so two devices do not duplicate them.

Rules

  • Horizon: 8 weeks, refilled on boot and after sync.
  • Today only gets slots that have not started yet; past/in-progress blocks are untouched.
  • Manual blocks win: the routine skips any date/time already occupied.
  • Editing or deleting a generated block is a one-off exception; the routine only changes through the editor.
  • Saving a new routine bumps the revision, removes future generated blocks (cancelled exceptions stay as tombstones) and recreates the horizon. Historical blocks stay.
  • Free for everyone on mobile (decision of 22/10/2026).

UI

  • Rotina button in the Time module (top actions on desktop, category row on mobile) opens a mini-planner.
  • Paint 30-minute cells for the default week, pick category or eraser; Clear affects only the visible hour window.
  • Blocks outside the configured hour window are preserved on save.
  • docs/ROUTINE.md documents the model and rules.

Verification

  • npm run check
  • npm test (40 files / 284 tests)
  • npm run build
  • npm run csp:check (23/23)

Pending manual check on device: paint/save a routine, confirm future blocks appear, manual conflicts are skipped, and editing/deleting a generated block stays one-off after reopening the app.

- Add `RoutineState`/`RoutineBlock` to the snapshot as a dateless default week
  (weekday, start, duration, category), persisted in `shared_settings` so it
  syncs LWW like the other singletons.
- Materialize the next 8 weeks on boot and after sync: today only future
  slots, manual blocks win conflicts, and past/in-progress blocks are never
  touched.
- Generated blocks carry `routineId`/`routineRevision`. Editing or deleting one
  is a one-off exception (deterministic ids prevent recreation); changing the
  routine bumps the revision and regenerates only the future.
- Add the `RoutineSheet` editor: paint the default week on a 30-minute grid,
  choose a category/eraser, clear the window or save. Available from the Time
  module on desktop and mobile, free for everyone.
- Document the model and rules in `docs/ROUTINE.md`.
@ReinaldoAssis
ReinaldoAssis merged commit c277b98 into main Oct 22, 2026
4 checks passed
@ReinaldoAssis
ReinaldoAssis deleted the feat/weekly-routine branch October 22, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant