fix(recovery): publish why the recovery page is empty from the server

The page worked out its empty note on the client from the integrations
status, so every client had to repeat the rule. The analytics summaries
slice now carries `recoveryEmpty` (general, oura_permission or
oura_no_resilience, null when any recovery type has a reading), decided
once in resolveRecoveryEmpty from the gated summaries and the stored
Oura grant. The page renders that value only, and its block list is
typed to the server's recovery types so the two cannot drift.

Each reason now reads as one sentence in every locale, and every reason
offers the same way on, the integrations settings.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 05:01:18 +02:00
1 parent 0ea8880923
commit 862361a224
20 files changed
+243 -171

No files matched your search

+3 -1
View File
@@ -18,6 +18,7 @@
* to the derived contract cannot leave this document behind.
*/
import { z } from "zod/v4";
import { recoveryEmptySchema } from "./recovery-empty";
import type { ZodOpenApiObject } from "zod-openapi";
import { SCORE_PILLAR_IDS } from "@/lib/analytics/score/types";
@@ -140,11 +141,12 @@ const analyticsSummariesSlice = z
),
lastSeenByType,
sleepSourceDiscrepancy,
recoveryEmpty: recoveryEmptySchema,
})
.meta({
id: "AnalyticsSummariesSlice",
description:
"What `?slice=summaries` answers: the per-type summaries and their freshness, and nothing thick. Four keys, and the caller gets them from two SQL passes rather than the default slice's chain.",
"What `?slice=summaries` answers: the per-type summaries and their freshness, the recovery page's empty reason, and nothing thick. Five keys, and the caller gets them from two SQL passes rather than the default slice's chain.",
});
// ── Correlations ─────────────────────────────────────────────────────
@@ -5,6 +5,7 @@
* Schemas come from `src/lib/validations/*` where shared with the
* runtime request parsing, so the wire contract stays single-source.
*/
import { recoveryEmptySchema } from "../recovery-empty";
import { trendSentiment, trendVerdict } from "../trend-verdict";
import { z } from "zod/v4";
import { measurementSourceEnum, measurementTypeEnum } from "../shared";
@@ -2032,6 +2033,7 @@ export const analyticsSummariesSliceResponse = z
),
lastSeenByType: z.record(z.string(), lastSeenSlot),
sleepSourceDiscrepancy,
recoveryEmpty: recoveryEmptySchema,
})
.meta({
id: "AnalyticsSummariesSlice",
+10
View File
@@ -0,0 +1,10 @@
import { z } from "zod/v4";
import { RECOVERY_EMPTY_REASONS } from "@/lib/insights/recovery-empty";
/** Why the recovery page is empty; shared by both slim-slice schemas. */
export const recoveryEmptySchema = z
.enum(RECOVERY_EMPTY_REASONS)
.nullable()
.describe(
"Why the recovery page has nothing to chart, resolved on the server; null when any recovery type (ANS_CHARGE, DAY_STRAIN, WORKOUT_STRAIN, CARDIO_LOAD, AVERAGE_HEART_RATE, MAX_HEART_RATE, ENERGY_EXPENDITURE_KJ, RESILIENCE) has a reading. `oura_permission`: Oura is connected and its grant leaves out the scope the resilience level needs, one reconnect fixes it. `oura_no_resilience`: Oura is connected and no level has arrived yet. `general`: anyone else. Clients render the empty note from this value and never work it out from the connection status.",
);