From 8ff3b51ba396c17dd7b1d87a00bbebf85c428a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 18 Jun 2026 22:42:27 +0200 Subject: [PATCH] refactor: remove dead exports and an unused prop Drop the health-score card's inert onAskCoach prop and its now-dead pass-through from the hero strip, the buildDashboardBands re-export that no caller reached through the snapshot module, an unused tour-progress status type, and an orphan service-worker cache helper. --- .../__tests__/health-score-card.test.tsx | 21 +++++-------------- src/components/insights/health-score-card.tsx | 11 ++-------- src/components/insights/hero-strip.tsx | 10 --------- src/lib/dashboard/snapshot.ts | 3 +-- src/lib/onboarding/tour-progress.ts | 2 -- src/lib/pwa/query-persister.ts | 21 ------------------- 6 files changed, 8 insertions(+), 60 deletions(-) diff --git a/src/components/insights/__tests__/health-score-card.test.tsx b/src/components/insights/__tests__/health-score-card.test.tsx index 0ed0a1eb0..af2a04019 100644 --- a/src/components/insights/__tests__/health-score-card.test.tsx +++ b/src/components/insights/__tests__/health-score-card.test.tsx @@ -194,10 +194,10 @@ describe("", () => { it("v1.4.27 B1 — no longer mounts an inline Ask-the-Coach button (hero strip carries the CTA)", () => { // The hero strip's existing "Ask the coach" action covers this - // surface; the card-internal duplicate button retired. The - // onAskCoach prop stays on the type signature so callers don't - // break, but the card no longer renders it. - const omitted = ssr( + // surface; the card-internal duplicate button retired. v1.18.6 (L13) + // dropped the now-dead `onAskCoach` prop too — the card renders no + // Coach affordance at all. + const html = ssr( ", () => { delta={null} />, ); - const supplied = ssr( - {}} - />, - ); - expect(omitted).not.toContain('data-slot="health-score-card-ask-coach"'); - expect(supplied).not.toContain('data-slot="health-score-card-ask-coach"'); + expect(html).not.toContain('data-slot="health-score-card-ask-coach"'); }); @@ -226,7 +216,6 @@ describe("", () => { band="green" components={baseComponents} delta={5} - onAskCoach={() => {}} />, "de", ); diff --git a/src/components/insights/health-score-card.tsx b/src/components/insights/health-score-card.tsx index 2782b5871..3e058eed6 100644 --- a/src/components/insights/health-score-card.tsx +++ b/src/components/insights/health-score-card.tsx @@ -26,8 +26,8 @@ import { HealthScoreDeltaExplainer } from "./health-score-delta-explainer"; * at least one component blends entries from more than one source. * * Pure presentational — the parent owns the analytics query + the - * drawer state. The same `onAskCoach` handler is shared with the hero - * strip's main "Ask the coach" button (different prefill string). + * drawer state. The card mounts no inline Coach affordance; the hero + * strip carries the single "Ask the coach" entry point. */ export type HealthScoreBand = "green" | "yellow" | "red"; @@ -70,7 +70,6 @@ export interface HealthScoreCardProps { compliance: HealthScoreCardComponent; }; delta: number | null; - onAskCoach?: (prefill: string) => void; /** * v1.4.25 W8e — opens the provenance accordion on first render. * The SSR tests use it to exercise the expanded markup without a @@ -175,12 +174,6 @@ export function HealthScoreCard({ band, components, delta, - // v1.4.27 B1 — onAskCoach stays on the prop signature so the hero - // strip's existing wire-up doesn't break, but the card no longer - // mounts an inline button (the hero strip already carries the same - // action). Destructure-and-ignore is intentional. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - onAskCoach: _onAskCoach, initiallyExpanded = false, moodEnabled = true, restModeActive = false, diff --git a/src/components/insights/hero-strip.tsx b/src/components/insights/hero-strip.tsx index f7fdedfac..025c01545 100644 --- a/src/components/insights/hero-strip.tsx +++ b/src/components/insights/hero-strip.tsx @@ -353,16 +353,6 @@ export function HeroStrip({ delta={healthScore.delta} moodEnabled={moodEnabled} restModeActive={healthScore.restMode?.active ?? false} - onAskCoach={ - // v1.4.37 W5 — short-circuit the prop drilling even - // though `HealthScoreCard` retired its inline button in - // v1.4.27. A future re-addition can't accidentally - // surface a Coach affordance from this card while the - // operator has the flag off. - coachEnabled && onAskCoach - ? (prefill: string) => onAskCoach(prefill) - : undefined - } /> )} diff --git a/src/lib/dashboard/snapshot.ts b/src/lib/dashboard/snapshot.ts index 668e38944..228c42814 100644 --- a/src/lib/dashboard/snapshot.ts +++ b/src/lib/dashboard/snapshot.ts @@ -78,7 +78,6 @@ import { } from "@/lib/dashboard/meds-today"; import { computeUserHealthScoreFastPath } from "@/lib/analytics/health-score-fast-path"; import { - buildDashboardBands, buildTargetBands, type DashboardTargetBands, } from "@/lib/dashboard/bands"; @@ -217,7 +216,7 @@ export interface DashboardSnapshotUser { * personalisation, no height → weight band), matching the client's * previous null-guards exactly. */ -export { buildDashboardBands, buildTargetBands }; +export { buildTargetBands }; export type { DashboardTargetBands }; export interface DashboardSnapshotMoodEntry { diff --git a/src/lib/onboarding/tour-progress.ts b/src/lib/onboarding/tour-progress.ts index b186ce7d3..c14c3a7f1 100644 --- a/src/lib/onboarding/tour-progress.ts +++ b/src/lib/onboarding/tour-progress.ts @@ -20,8 +20,6 @@ export const TOUR_PROGRESS_STATUSES = [ "skipped", ] as const; -export type TourProgressStatus = (typeof TOUR_PROGRESS_STATUSES)[number]; - /** * The persisted progress shape. `lastStopId` seeds the resume index; * `completedStopIds` is informational (analytics + future per-module diff --git a/src/lib/pwa/query-persister.ts b/src/lib/pwa/query-persister.ts index 2701f6431..302926f17 100644 --- a/src/lib/pwa/query-persister.ts +++ b/src/lib/pwa/query-persister.ts @@ -301,27 +301,6 @@ export async function clearPersistedQueryCache(): Promise { } } -/** - * Drop the service-worker offline read-data cache (`healthlog-data-*`). It - * holds the last-synced dashboard JSON and must never survive a session end on - * a shared device. Scoped to the data cache only — the static cache (hashed - * chunks, icons) carries no PII and dropping it would force a needless - * re-download. Best-effort; never throws. - */ -export async function clearServiceWorkerDataCache(): Promise { - if (typeof caches === "undefined") return; - try { - const keys = await caches.keys(); - await Promise.all( - keys - .filter((k) => k.startsWith("healthlog-data-")) - .map((k) => caches.delete(k)), - ); - } catch { - /* best effort */ - } -} - /** * Wipe every client-side cache that can hold one account's health data: the * IndexedDB query snapshot, the SW offline read-data cache, and the SW page