From 347143c4b702f4b2a90d1e107ec6e2a117f5a617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 15 Jun 2026 00:21:42 +0200 Subject: [PATCH] fix(personal-records): map the new derived metric types to a null PR direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ANS charge, cardio load, the sleep score, and the body-temperature deviation reached the MeasurementType enum without a branch in getPRDirection, which left the exhaustive switch non-total — typecheck fell through to an implicit undefined return and the drift guard failed. These are derived / homeostatic composites with no goal axis, so they join the other scores and temperature metrics on the null PR direction. --- src/lib/personal-records/pr-direction.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/personal-records/pr-direction.ts b/src/lib/personal-records/pr-direction.ts index 91d2f82fa..517d6b687 100644 --- a/src/lib/personal-records/pr-direction.ts +++ b/src/lib/personal-records/pr-direction.ts @@ -176,6 +176,16 @@ export function getPRDirection( // WALKING_HEART_RATE_AVERAGE case above. Defer to a null PR direction. case "AVERAGE_HEART_RATE": case "MAX_HEART_RATE": + // Derived / homeostatic device composites with no goal axis. ANS + // charge, cardio load, and the sleep score are recomputed daily from + // their own underlying signals (a PR on them would double-count the + // inputs' PRs), and the body-temperature deviation is a baseline- + // relative reading where neither direction is an achievement — they + // stay null like the other derived scores + temperature metrics above. + case "ANS_CHARGE": + case "CARDIO_LOAD": + case "SLEEP_SCORE": + case "BODY_TEMPERATURE_DEVIATION": return null; } }