mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
chore(release): v1.4.47 — audit-backlog closure + drag-to-reorder + Coach disable + OAuth nonce ledger
Eight changes: W0 idempotency test pin, W1 legacy column drop, W2 Textarea primitive, W3 Coach disable toggle, W4 dnd-kit drag-to-reorder, W5 onboarding 24h gate, W6 Withings OAuth nonce ledger, W7+W8 legacy_form_total drop + Coach onLine pre-check. 6-axis QA reconciled. Migrations 0076/0077/0078 required pre-image. Tests 5093 → ~5170.
This commit is contained in:
1 parent
ac319c6160
commit
66a7f8b6fa
68 files changed
+3959
-715
No files matched your search
+23
-1
@@ -23,13 +23,35 @@ export interface AuthUser {
|
||||
onboardingTourCompleted: boolean;
|
||||
gravatarUrl: string | null;
|
||||
glucoseUnit: string | null;
|
||||
/**
|
||||
* v1.4.47 W3 — per-user Coach opt-out. When `true`, every Coach
|
||||
* mount point (`<LayoutCoachFab>`, `<LayoutCoachMount>`, the
|
||||
* inline `<CoachLaunchButton>` pill, the `/targets` page CTA)
|
||||
* renders nothing. The gate sits BELOW the operator-level
|
||||
* `flags.coach` short-circuit — both must agree to render the
|
||||
* affordance. Defaults to `false` when the field is absent (e.g.
|
||||
* stale /me payload from a partial-deploy rollback).
|
||||
*/
|
||||
disableCoach: boolean;
|
||||
}
|
||||
|
||||
async function fetchMe(): Promise<AuthUser> {
|
||||
const res = await fetch("/api/auth/me");
|
||||
if (!res.ok) throw new Error("Not authenticated");
|
||||
const json = await res.json();
|
||||
return json.data;
|
||||
// v1.4.47 W3 — coerce `disableCoach` against `undefined` so a stale
|
||||
// /me payload from a partial-deploy rollback (older server image
|
||||
// without the field) keeps the Coach surface visible by default.
|
||||
const data = json.data as Partial<AuthUser> & {
|
||||
id: string;
|
||||
username: string;
|
||||
role: string;
|
||||
timezone: string;
|
||||
};
|
||||
return {
|
||||
...(data as AuthUser),
|
||||
disableCoach: data.disableCoach ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
export function useAuth() {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { useContext } from "react";
|
||||
import { QueryClientContext } from "@tanstack/react-query";
|
||||
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
|
||||
/**
|
||||
* v1.4.47 W3 — SSR-safe accessor for the per-user "Hide Coach" toggle.
|
||||
*
|
||||
* `useAuth()` calls `useQuery` directly and crashes when the caller
|
||||
* SSR-renders without a `<QueryClientProvider>` (the legacy
|
||||
* Coach-surface unit tests do exactly this). The cascade-test fixture
|
||||
* + the dedicated disable-cascade fixture both seed a client, but the
|
||||
* long-tail SSR snapshot tests (`<SuggestedPrompts>`, `<LayoutCoachFab>`,
|
||||
* `<HeroStrip>` …) render the component in isolation and don't.
|
||||
*
|
||||
* Mirrors the defensive pattern in `useFeatureFlags()`: when no
|
||||
* `QueryClientContext` is mounted we short-circuit to the "no opt-out"
|
||||
* default so the legacy tests keep rendering the surface, and the gate
|
||||
* stays correct for the production app where the provider is always
|
||||
* mounted.
|
||||
*/
|
||||
export function useDisableCoach(): boolean {
|
||||
const hasClient = useContext(
|
||||
QueryClientContext as unknown as React.Context<unknown>,
|
||||
);
|
||||
if (!hasClient) return false;
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
return useDisableCoachInner();
|
||||
}
|
||||
|
||||
function useDisableCoachInner(): boolean {
|
||||
const { user } = useAuth();
|
||||
return user?.disableCoach ?? false;
|
||||
}
|
||||
Reference in new issue
Block a user