mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
feat(coach): per-source + window scope picker on sources rail
Previously the Sources rail listed BP / Weight / Pulse / Mood /
Compliance as a static legend. Marc asked for a real "what I can
see" surface — per-source checkboxes (include/exclude) plus a
window selector (last 7d / 30d / 90d / all-time) that flow through
the Coach request body.
Wire the controls all the way down:
- <SourcesRail> grows scope + onScopeChange props. Each row
becomes a 36px tall flex row with a real checkbox; the row
fades to 60% opacity when its source is excluded.
- A Select trigger above the list drives the window. Both control
surfaces share the existing insights.coach.window.* i18n keys;
add a new windowLabel key so the dropdown has an EN+DE label.
- <CoachDrawer> owns the scope state (resets on each mount per
the v1.4.20.1 plan — no conversation-level persistence yet) and
forwards the picked scope through useSendCoachMessage to the
chat request body. The payload only ships when the user has
narrowed away from the all-source last30days default so the
server can tell "no opinion" from "intentionally narrow".
- buildCoachSnapshot already accepts the optional CoachScope from
the previous commit; it now flows end-to-end.
No new dependencies — checkboxes are plain inputs styled with
Tailwind + Dracula tokens.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ddb2914b65
commit
08fd411ff1
7 files changed
+288
-43
No files matched your search
@@ -135,4 +135,24 @@ describe("buildCoachSnapshot", () => {
|
||||
]);
|
||||
expect(parsed.scope.window).toBe("last30days");
|
||||
});
|
||||
|
||||
it("scope-only-mood pulls just mood data, no measurements query", async () => {
|
||||
featuresMock.mockResolvedValue({
|
||||
mood: { avg30: 4.2, coverage: { count: 12 } },
|
||||
});
|
||||
prismaMock.moodEntry.findMany.mockResolvedValue([
|
||||
{
|
||||
moodLoggedAt: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
|
||||
score: 4,
|
||||
},
|
||||
]);
|
||||
|
||||
const out = await buildCoachSnapshot("user-1", {
|
||||
sources: ["mood"],
|
||||
});
|
||||
expect(prismaMock.measurement.findMany).not.toHaveBeenCalled();
|
||||
expect(out.provenance.metrics).toContain("mood");
|
||||
const parsed = JSON.parse(out.snapshotJson);
|
||||
expect(parsed.mood.timeline.recent.length).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user