Skip to content

Night duty: analysis and mockups (#66) - #70

Merged
kimipsen merged 10 commits into
masterfrom
worktree-night-duty
Nov 9, 2026
Merged

kimipsen merged 10 commits into
masterfrom
worktree-night-duty

Conversation

@kimipsen

@kimipsen kimipsen commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Analysis, mockups and implementation of #66 (nighttime responsible schedule).

Implementation status

  • Backend (Features/NightDuty): a per-child NightSchedule with versioned fixed schedules, per-night overrides and notes. Five routes, a NightDuty print row kind, a nightDuty feature flag, GDPR export/erasure, inline snapshot and golden files.
  • Frontend: /guardian/night-duty (nights from tonight; change, switch and undo; fixed-schedule editor), the child's "Tonight" card, the Night print row, en/da strings, help, and a demo co-guardian ("Dad") for the screenshots.
  • Tests: backend 2,153 passed and frontend 3,406 passed; lint and contract checks are clean.
  • e2e: e2e/night-duty.spec.ts passes, and so do pickup-assignment and print-week-plan (A4 and A3 still print as one landscape page).
  • Screenshots: regenerated. The new page is guardian-night-duty; the child home shows the Tonight card and the print sheet a Night row.
  • Changes from the design are listed under "Implementation notes" in docs/backend/analysis/night-duty.md.

Doc: docs/backend/analysis/night-duty.md

Mockups

These are static HTML mockups with demo data, not built code.

Guardian page: resolved week + fixed-schedule editor Edit one night / switch two nights
guardian dialogs
Child "Tonight" card (iPhone) Printed week plan with a Night row
child print

Where the doc differs from the issue sketch

  • Per-date override events (NightOverridden / NightOverrideCleared, the work-locations precedent) instead of batch NightOverridesSet / NightOverridesCleared. Atomicity comes from one append. A NightScheduleStarted event is added for lazy stream creation, and events carry ModifiedBy because any guardian can write.
  • Saving a schedule from date X replaces every version from X on. This also replaces an upcoming version, so there's never a hidden future schedule.
  • Switching nights swaps only the responsible persons. Each night keeps its note, so screen night stays on Friday. It's a frontend action that sends one SetNightOverrides.
  • SetNightOverrides takes a list of (date, override) pairs (max 31) rather than one value over a range, so a switch is a single request.
  • ListNights also returns the scheduled entry for overridden nights, so the week view can show "Changed · Schedule: Dad".
  • Two small refactors: a shared WeekCycle helper (taken out of WorkPattern), and BabysitterNames generalised and moved to Features/Babysitters (4 call sites).
  • The page lives at /guardian/night-duty, behind a nightDuty feature flag, with links to and from the pickup page.

Open questions (settled)

  1. Demo data: seed a second demo guardian, Jonas Holm ("Dad").
  2. "Tonight" after midnight: the card follows the child's date.
  3. "Changed by" history and group visibility: both are left out of v1. ModifiedBy is still stored on every event.

Estimate: High complexity, 8–12 developer-days, or 5–8 h of agent time plus about 2 h of review.

Refs #66

🤖 Generated with Claude Code

…schedule

Design analysis for issue #66: a per-child NightSchedule aggregate with
versioned 1-4 week fixed schedules (EffectiveFrom, past nights frozen),
per-night overrides and switches, free-text notes, a NightDuty print row
and a child "Tonight" card. Includes mockups of the guardian page, the
edit/switch dialogs, the child card and the printed week plan.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe91e46d-3fe8-4b67-83be-535fb8c650ad
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kimipsen
kimipsen marked this pull request as draft November 8, 2026 20:50
kimipsen and others added 5 commits November 8, 2026 20:50
Seed a second demo guardian ("Dad"), let the Tonight card follow the
child's date, store but don't show "changed by", and keep group
visibility out of v1. The doc now has no open questions for v1.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds Features/NightDuty: a per-child NightSchedule aggregate (id == the
child's UserId) with fixed-schedule versions (1-4 week cycle from an
anchor Monday, EffectiveFrom never in the past, a save replaces every
version from its date on), sparse per-night overrides (planned or
cleared) and short notes. Five slices: ReplaceNightPattern,
SetNightOverrides (a switch is two nights in one append),
ClearNightOverrides, GetNightSchedule and ListNights, with the Pickups
authorization tiers (guardians manage, the child views nights).

Also: PrintRowKind.NightDuty, a nightDuty feature flag, GDPR eraser and
exporter, inline snapshot, golden files, the nightduty Marten schema,
and two small extractions the analysis called for (WeekCycle shared
with WorkPattern, BabysitterNames moved to Babysitters and keyed by
owner) plus UserLocalDate (the child's today) shared with Medicines.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… planned [skip-docs]

From the branch review:
- SetNightOverrides rejects nights more than 31 days apart (the
  response resolves every night in between, so two far-apart dates
  could expand millions of nights).
- A babysitter archived (or a guardian removed) since a night was
  planned no longer blocks re-saving that version or switching that
  night; only people new to the replaced version or the nights being
  set are checked.
- Re-saving the version in effect with the same content from a later
  date is a no-op instead of appending a duplicate version.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frontend for the nighttime responsible schedule (issue #66):
- NightDutyService and /guardian/night-duty: the seven nights from
  tonight with changed nights marked ("Schedule: Dad"), an edit dialog
  (guardian, babysitter, sleepover, note only, nothing planned; the
  scheduled note is kept), an inline two-night switch that keeps each
  night's note, undo, and the fixed-schedule editor (1-4 week cycle,
  "this week is", applies-from date, versions list)
- the child's "Tonight" card on the day dashboard
- PrintRowKind NightDuty in the template editor, loader and sheet (who
  in their template colour, "Overnight: host", the note on a second
  line, empty nights blank)
- nav entry, help topic, a link from the pickup page, nightDuty flag
- en/da strings, specs, a Playwright journey, and the demo family's
  second guardian (Jonas, "Dad") with a night schedule for screenshots
- docs: analysis status and implementation notes, flow, glossary,
  aggregate map, frontend README

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Frontend coverage

Lines Branches
97.5% (19504/19999) 92.2% (8142/8826)

Full report: the coverage artifact of this run.

@kimipsen
kimipsen marked this pull request as ready for review November 9, 2026 09:31
kimipsen and others added 2 commits November 9, 2026 09:32
…he feature

Adds guardian-night-duty (desktop, mobile, tablet) and refreshes every
page for the demo family's second guardian and night schedule: the
child home shows the Tonight card, the print sheet a Night row.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ath.Combine' may silently drop its earlier arguments'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Backend coverage

Lines Branches
93.7% (23909/25503) 77.2% (6354/8230)

Full report: the coverage artifact of this run.

kimipsen and others added 2 commits November 9, 2026 09:35
- Split the relationship check (cognitive complexity, nested ternary),
  the pattern status and the night-week switch/label logic into plain
  statements; Where before OrderBy; constants for the persisted
  NightResponsible property names; drop the redundant
  ResponsibleChoice alias.
- Remove the duplicated code Sonar counted: a shared keepTabInside
  focus trap (rule editor and night edit dialog) and weekdayName in
  work-pattern.ts (both pattern editors).
- .sonarcloud.properties excludes the generated API types and the
  en/da translation dictionaries from duplication detection only.

The union-syntax findings (S3903, S1186, S3060, S2094), S8970 and S107
on handlers are known false positives (sonar-known-issues.md) and are
left for marking in SonarCloud.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kimipsen
kimipsen merged commit 3d7df9f into master Nov 9, 2026
@kimipsen
kimipsen deleted the worktree-night-duty branch November 9, 2026 09:57
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

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.

2 participants