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:
Marc-André Bombeck authored and GitHub committed 2026-05-22 09:18:52 +02:00
1 parent ac319c6160
commit 66a7f8b6fa
68 files changed
+3959 -715

No files matched your search

+23 -1
View File
@@ -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() {
+36
View File
@@ -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;
}