mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
/targets carries two Coach affordances — the per-card 'Ask Coach' CTA on every TargetCard and the page-level CoachDrawer mount. The CTAs were gated through `aiEnabled` (provider chain status), but the drawer mount always rendered regardless of the operator's global Coach flag. When the operator turned Coach off in Settings the drawer still loaded its SSE machinery + Sheet portal subtree even though no on-page CTA could open it. Read flags.coach via useFeatureFlags and fold it into the existing `aiEnabled` gate so the per-card CTAs vanish when either layer is off. Wrap the page-level <CoachDrawer> mount in the same gate as defence-in-depth, since the CTAs already hide when the flag is off. Tests: add two new cases to targets-coach-mount.test.tsx covering the Coach-flag-off branch (CTAs hide + drawer mount disappears). The sibling targets-* test files mock @tanstack/react-query without exposing QueryClientContext; add a use-feature-flags mock that short-circuits to the all-on default so the existing assertions keep running against the visible page shape.