mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
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.
56 lines
2.6 KiB
TypeScript
56 lines
2.6 KiB
TypeScript
/**
|
|
* Query keys — Coach preferences, facts, about-me, and nudge state.
|
|
* Part of the centralized factory; aggregated in `./index.ts`.
|
|
*/
|
|
export const coachKeys = {
|
|
coachPrefs: () => ["coach-prefs"] as const,
|
|
coachFacts: () => ["coach-facts"] as const,
|
|
/** v1.15.20 — Settings → AI "about me" self-description. */
|
|
coachAboutMe: () => ["coach-about-me"] as const,
|
|
/** v1.16.0 — pending clarifying questions (Coach composer chips). */
|
|
coachAboutMeQuestions: () => ["coach-about-me", "questions"] as const,
|
|
/** v1.16.1 — unseen proactive-nudge state for the floating Coach bubble. */
|
|
coachNudgeStatus: () => ["coach-nudge-status"] as const,
|
|
/** v1.18.6 (CCH-03) — mark-Coach-seen mutation (clears the FAB unread dot). */
|
|
coachMarkSeen: () => ["coach-mark-seen"] as const,
|
|
/**
|
|
* v1.18.7 — the Coach conversation rail list (`GET /api/insights/chat`).
|
|
* Previously a hook-local bare `["coachConversations"]`; centralised so
|
|
* the optimistic delete and the streaming hook's post-turn invalidation
|
|
* share one factory-routed key.
|
|
*/
|
|
coachConversations: () => ["coachConversations"] as const,
|
|
/**
|
|
* v1.18.7 — one decrypted Coach conversation (`GET /api/insights/chat/[id]`).
|
|
* Keyed on the conversation id so two open threads never share a cache slot;
|
|
* the streaming hook invalidates this slot once the persisted twin lands.
|
|
*/
|
|
coachConversation: (id: string | null) => ["coachConversation", id] as const,
|
|
/**
|
|
* v1.21.2 (A3) — today's most notable derived signal, resolved into the
|
|
* Coach hero's pre-seeded relevance opener
|
|
* (`GET /api/insights/coach/seeded-question`).
|
|
*/
|
|
coachSeededQuestion: () => ["coach-seeded-question"] as const,
|
|
/**
|
|
* v1.22 (B2/B6) — the user's Coach episodic reminders (`GET /api/coach/
|
|
* reminders`). The optional `status` arg keys the in-app tile read
|
|
* (`due,surfaced`) separately from the full ledger list so the two never
|
|
* share a cache slot.
|
|
*/
|
|
coachReminders: (status?: string) =>
|
|
["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,
|
|
};
|