mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
feat(coach): surface plan proposals for confirmation and add the plans page
The Coach has extracted goal / if-then plan proposals since v1.21.3 — written as status "proposed", never activated without the user — but no surface ever showed them, so nothing could be confirmed and the active-plan memory block stayed permanently empty. This lands the missing user half: - Chat thread: proposal confirm cards at the tail of the open conversation (proposals land asynchronously via the post-turn memory-refresh worker, so the block slow-polls the proposed list while the thread is mounted and only shows proposals born in that conversation). Accept activates the plan — it enters the Coach's snapshot memory from the next turn on; decline soft-deletes the proposal so it never activates and stops counting against the per-user cap. A settled card collapses to a one-line confirmation. - /coach/plans: the management ledger, a sibling of /coach/conversations reachable from the composer's + menu. Groups proposals (confirm / decline), standing plans (goal met / end), and the settled history (remove). No prose editor by design — the extractor is the only writer of plan text and the PATCH contract only moves the lifecycle. - Shared use-coach-plans hook + centralised coach-plans query keys, so the thread cards and the page invalidate each other's reads. - Both coach-gate invariants (operator master flag, per-user opt-out) register the new page; i18n keys land in all six locales. SSR tests pin the card contract: only same-conversation proposals render, undecryptable rows are skipped, both actions are real buttons.
This commit is contained in:
1 parent
acd2f29da2
commit
f5b0ec431e
15 files changed
+870
No files matched your search
@@ -288,6 +288,9 @@ describe("Coach disable cascade invariant", () => {
|
||||
// `flags.coach` like the main Coach route and renders unavailable
|
||||
// when the operator master flag is off.
|
||||
"src/app/coach/conversations/page.tsx",
|
||||
// The plans management page mirrors the conversation-history page's
|
||||
// gate: operator master flag off redirects back to `/insights`.
|
||||
"src/app/coach/plans/page.tsx",
|
||||
// v1.15.20 — the proactive Coach-nudge cron short-circuits on
|
||||
// `flags.coach` (gate 1) so an operator kill-switch also silences
|
||||
// the nudges. Server-side cron, not a render path — the cascade
|
||||
|
||||
@@ -302,6 +302,9 @@ describe("Coach per-user disableCoach invariant", () => {
|
||||
// Coach route gate: operator master flag OR per-user opt-out marks
|
||||
// the page unavailable instead of painting a dead history shell.
|
||||
"src/app/coach/conversations/page.tsx",
|
||||
// The plans management page mirrors the same gate: operator master
|
||||
// flag OR per-user opt-out redirects instead of a dead plans shell.
|
||||
"src/app/coach/plans/page.tsx",
|
||||
// The hook itself + its `useAuth`-backed reader.
|
||||
"src/hooks/use-disable-coach.ts",
|
||||
// Cross-cut gates owned by sibling invariants / route tests.
|
||||
|
||||
@@ -42,4 +42,14 @@ export const coachKeys = {
|
||||
["coach-reminders", status ?? "all"] as const,
|
||||
/** Prefix key — invalidates every `coachReminders(status)` slot at once. */
|
||||
coachRemindersAll: () => ["coach-reminders"] as const,
|
||||
/**
|
||||
* v1.27.x — the user's Coach goal / if-then plans (`GET /api/coach/plans`).
|
||||
* The `filter` arg keys the chat thread's proposal read (`status:proposed`)
|
||||
* separately from the management page's ledger read (`scope:all`) so the
|
||||
* two never share a cache slot.
|
||||
*/
|
||||
coachPlans: (filter?: string) =>
|
||||
["coach-plans", filter ?? "default"] as const,
|
||||
/** Prefix key — invalidates every `coachPlans(filter)` slot at once. */
|
||||
coachPlansAll: () => ["coach-plans"] as const,
|
||||
};
|
||||
Reference in new issue
Block a user