mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
feat(coach): evidence-based cadence suggestions with one-tap in-chat reminder
The Coach can append a ---SUGGEST-REMINDER--- sentinel to propose a measurement cadence (weight daily, the ESH/AHA 7-2-2 home-BP protocol, structured glucose). The server resolves the cadence from a closed catalog and emits an additive 'suggestion' SSE frame the chat renders as a one-tap action card; accepting it creates a MeasurementReminder with origin COACH through the same engine the Vorsorge surface uses (server-authoritative schedule, finite course window self-expires via endsOn). Non-naggy by construction: a frequency-cap cooldown, dismissal memory, a master opt-out under Coach settings, and an explicit 'I measure enough' stop path, all in the coach-prefs blob. Triple dedup at suggest, render, and create so a cadence is never double-suggested or double-created, and suggestions for a disabled module never surface. RHR/HRV stay passive -- the Coach surfaces the baseline, it never nudges to 'go measure' them. The reminder DTO now echoes origin and endsOn for the iOS client.
This commit is contained in:
1 parent
b6796eee96
commit
12f4bc24e8
29 files changed
+1538
-9
No files matched your search
@@ -171,4 +171,35 @@ describe("parseCoachPrefs", () => {
|
||||
"mood",
|
||||
]);
|
||||
});
|
||||
|
||||
// v1.18.1 (Workstream C) — reminder-suggestion sub-shape.
|
||||
it("a legacy blob (no reminderSuggestions) parses with the key absent", () => {
|
||||
const out = parseCoachPrefs({ tone: "warm" });
|
||||
expect(out.reminderSuggestions).toBeUndefined();
|
||||
});
|
||||
|
||||
it("fills the reminderSuggestions defaults when the key is an empty object", () => {
|
||||
const out = coachPrefsSchema.parse({ reminderSuggestions: {} });
|
||||
expect(out.reminderSuggestions).toEqual({
|
||||
enabled: true,
|
||||
stopped: false,
|
||||
dismissedCadences: [],
|
||||
lastSuggestedAt: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("round-trips a populated reminderSuggestions block", () => {
|
||||
const out = coachPrefsSchema.parse({
|
||||
reminderSuggestions: {
|
||||
enabled: true,
|
||||
stopped: false,
|
||||
dismissedCadences: ["bp_7_2_2"],
|
||||
lastSuggestedAt: "2026-06-16T12:00:00.000Z",
|
||||
},
|
||||
});
|
||||
expect(out.reminderSuggestions?.dismissedCadences).toEqual(["bp_7_2_2"]);
|
||||
expect(out.reminderSuggestions?.lastSuggestedAt).toBe(
|
||||
"2026-06-16T12:00:00.000Z",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user