feat(coach): medications + anthropometrics exclusion toggles

Extend the coach exclude-metrics enum with two optional-context tokens
and surface them in the settings sheet under a separate "Include
context" group. The snapshot gates the GLP-1 weeklyContext block on
the medications toggle (skipping the Prisma lookup entirely when
excluded) and gates the new anthropometrics block on the
anthropometrics toggle plus at least one non-null profile field.
Empty blocks are never emitted.
This commit is contained in:
Marc-André Bombeck committed 2026-05-17 12:25:30 +02:00
1 parent 83f0b5ae86
commit 1e9a03bee5
12 files changed
+225 -22

No files matched your search

@@ -56,7 +56,9 @@ describe("coachPrefsSchema", () => {
expect(result.success).toBe(false);
});
it("caps excludeMetrics at 9 entries", () => {
it("caps excludeMetrics at 11 entries", () => {
// v1.4.36 W3 T2 — cap raised from 9 to 11 to admit the two new
// optional-context toggles (medications, anthropometrics).
const result = coachPrefsSchema.safeParse({
excludeMetrics: [
"bp",
@@ -68,11 +70,20 @@ describe("coachPrefsSchema", () => {
"sleep",
"resting_hr",
"steps",
"medications",
"anthropometrics",
"bp",
],
});
expect(result.success).toBe(false);
});
it("accepts the new medications + anthropometrics tokens", () => {
const out = coachPrefsSchema.parse({
excludeMetrics: ["medications", "anthropometrics"],
});
expect(out.excludeMetrics).toEqual(["medications", "anthropometrics"]);
});
});
describe("parseCoachPrefs", () => {
+9 -1
View File
@@ -55,6 +55,14 @@ export const coachExcludeMetricEnum = z.enum([
"sleep",
"resting_hr",
"steps",
// v1.4.36 W3 T2 — optional context blocks the user can opt out of.
// `medications` covers the snapshot's compliance + GLP-1 weeklyContext;
// `anthropometrics` covers height / age / gender on `context`. Each
// gates a single labelled block at the snapshot/feature layer, so an
// excluded block never lands in the prompt at all (not even as a
// labelled-empty key).
"medications",
"anthropometrics",
]);
export type CoachExcludeMetric = z.infer<typeof coachExcludeMetricEnum>;
@@ -83,7 +91,7 @@ export type CoachDefaultWindow = z.infer<typeof coachDefaultWindowEnum>;
export const coachPrefsSchema = z.object({
tone: coachToneEnum.default("warm"),
verbosity: coachVerbosityEnum.default("default"),
excludeMetrics: z.array(coachExcludeMetricEnum).max(9).default([]),
excludeMetrics: z.array(coachExcludeMetricEnum).max(11).default([]),
showEvidenceByDefault: z.boolean().default(false),
defaultWindow: coachDefaultWindowEnum.default("allTime"),
});