feat(sleep): surface sleep debt and chronotype

Assemble a sleep-rhythm read on the canonical per-night reconstruction — the
same midpoints and asleep totals the sleep score uses — that reports a rolling
sleep debt against the age-based need and an MCTQ chronotype with its mid-sleep,
social jetlag and band. A shared assembler caps the chronotype window so the
dashboard and the dedicated read return identical values, and both withhold a
confident reading behind a learning state until enough nights accrue. The sleep
page gains a debt headline and a chronotype card with the deeper detail behind
an advanced disclosure; the sleep score is left untouched so debt reframes the
sufficiency gap without double-counting it.
This commit is contained in:
Marc-André Bombeck committed 2026-06-14 19:12:01 +02:00
commit a970ba8ab0
22 files changed
+1529 -2

No files matched your search

+2
View File
@@ -67,6 +67,8 @@ export const measurementDependentKeys = [
["trend-series"] as const,
// v1.11.5 — refresh the last-night hypnogram when sleep rows change.
["sleep-night"] as const,
// v1.17.0 — refresh the sleep-debt + chronotype read when sleep rows change.
["sleep-rhythm"] as const,
];
/**
+8
View File
@@ -45,6 +45,14 @@ export const measurementKeys = {
*/
sleepNight: (date?: string) => ["sleep-night", date ?? "latest"] as const,
/**
* v1.17.0 — sleep-rhythm read (`GET /api/sleep/rhythm`): the
* server-authoritative sleep-debt + chronotype DTO. Reads the same raw
* SLEEP_DURATION rows the night view does, so a sleep write invalidates
* it through the shared measurement-dependent set.
*/
sleepRhythm: () => ["sleep-rhythm"] as const,
/**
* v1.4.40 W-RSC — per-chart daily-aggregate fetch from the dashboard
* + insights chart row. Pre-fix the key was bare `["chart-data", …]`