refactor(insights): remove duplicate InsightStatusCard mount — superseded by InsightAdvisorCard since v1.4.16

The /insights page rendered both <InsightAdvisorCard> (the polished
severity-ordered recommendations grid + per-rec rationale + confidence
meter + medical-citation footnotes shipped in v1.4.16 phase D
reconcile) AND <InsightStatusCard title={t("insights.generalStatusTitle")}>
(the v1.4.15 text-only summary). The page comment at the advisor
wiring acknowledged the status card "was intended to be replaced"
during D-reconcile but the status mount was never removed, so users
saw two cards saying the same thing — one labelled
"KI-Gesundheitsanalyse" and one labelled "Allgemeiner
Gesundheitszustand".

Removed:
  - The <section id="section-general"> block + its <InsightStatusCard>.
  - The `generalStatus` useQuery + the unused `GeneralStatusData`
    interface.
  - The `generalStatus?.updatedAt` entry from freshestUpdatedAt(); the
    other six per-section caches still feed the hero's "Generated …"
    caption.
  - The "section-general" entry from the sticky pill nav (it had
    nothing left to scroll to).

Kept:
  - The /api/insights/general-status route + the underlying
    generateGeneralStatusForUser lib — the reminder worker still
    pre-warms the daily general-status cache for users opted in to the
    briefing notification. Added a JSDoc @deprecated note on the route
    pointing new callers at <InsightAdvisorCard> /
    useInsightsAdvisorQuery().
  - The insights.generalStatusTitle + insights.generalStatusBadge.*
    translation keys — they're still referenced by the per-section
    badge labels (insights.generalStatusBadge.good / .watch /
    .critical map traffic-light states on every metric section, not
    just the dropped general one).
This commit is contained in:
Marc-André Bombeck committed 2026-05-14 11:50:49 +02:00
1 parent 7a27390936
commit 3e9881f3fd
2 files changed
+22 -45

No files matched your search

@@ -10,6 +10,23 @@ import { resolveServerLocale } from "@/lib/i18n/server-locale";
export const dynamic = "force-dynamic";
/**
* @deprecated since v1.4.25 — the `/insights` page no longer mounts the
* `<InsightStatusCard>` that drove this endpoint; the polished
* `<InsightAdvisorCard>` block above the per-metric sections covers
* the same surface with severity-ordered recommendations + rationale.
*
* The route + underlying `generateGeneralStatusForUser` lib remain
* live because the reminder worker (`src/lib/jobs/reminder-worker.ts`)
* still pre-warms the daily general-status cache for users opted in to
* the briefing notification. Removing the route would break the
* warm-cache job's HTTP-style coverage tests; removing the lib would
* break the worker. Both stay; this comment is for new callers.
*
* New surfaces should consume `<InsightAdvisorCard>` via
* `useInsightsAdvisorQuery()` (`@/components/insights/use-insights-advisor`)
* instead of fetching this endpoint directly.
*/
export const GET = apiHandler(async (request: NextRequest) => {
const { user } = await requireAuth();
+5 -45
View File
@@ -189,13 +189,6 @@ interface AnalyticsData {
} | null;
}
interface GeneralStatusData {
hasProvider: boolean;
text: string | null;
cached: boolean;
updatedAt: string | null;
}
interface BloodPressureStatusData {
hasProvider: boolean;
text: string | null;
@@ -594,18 +587,6 @@ export default function InsightsPage() {
enabled: isAuthenticated,
});
const { data: generalStatus, isLoading: isGeneralStatusLoading } = useQuery({
queryKey: ["insights", "general-status", locale],
queryFn: async () => {
const res = await fetch(`/api/insights/general-status?locale=${locale}`);
if (!res.ok) throw new Error("Failed");
const json = await res.json();
return json.data as GeneralStatusData;
},
enabled: isAuthenticated,
staleTime: 60 * 1000,
});
const { data: bloodPressureStatus, isLoading: isBloodPressureStatusLoading } =
useQuery({
queryKey: ["insights", "blood-pressure-status", locale],
@@ -882,7 +863,6 @@ export default function InsightsPage() {
// expand every card. Falls back to null when no section has shipped a
// payload yet (the hero just hides the caption).
const heroUpdatedAt = freshestUpdatedAt([
generalStatus?.updatedAt,
bloodPressureStatus?.updatedAt,
weightStatus?.updatedAt,
pulseStatus?.updatedAt,
@@ -1018,29 +998,6 @@ export default function InsightsPage() {
legacyPayload={advisor.payload?.legacyPayload ?? false}
/>
<section id="section-general" className="scroll-mt-16 space-y-2">
<div className="flex items-center gap-2">
<h2 className="text-lg font-semibold">
{t("insights.generalStatusTitle")}
</h2>
<Badge
className={`border text-xs ${overallStatus.className}`}
variant="outline"
>
{t(`insights.generalStatusBadge.${overallStatus.level}`)}
</Badge>
</div>
<InsightStatusCard
title={t("insights.generalStatusTitle")}
icon={<Activity className="h-5 w-5" />}
text={generalStatus?.text ?? null}
hasProvider={generalStatus?.hasProvider ?? false}
cached={generalStatus?.cached ?? false}
updatedAt={generalStatus?.updatedAt ?? null}
loading={isGeneralStatusLoading}
/>
</section>
{/* Section 3: Blood pressure */}
<section id="section-bp" className="scroll-mt-16 space-y-4">
<div className="flex items-center gap-2">
@@ -1703,8 +1660,12 @@ function MedicationComplianceCalendar({
// ── Section Navigation ───────────────────────────────────────────────────────
// v1.4.25 W3 — "section-general" pill dropped alongside the
// `<InsightStatusCard>` it scrolled to. The general status was
// superseded by the always-on `<InsightAdvisorCard>` block above the
// per-metric sections, so the pill had nothing to scroll to once the
// status mount was removed.
const SECTION_IDS = [
"section-general",
"section-bp",
"section-weight",
"section-pulse",
@@ -1714,7 +1675,6 @@ const SECTION_IDS = [
] as const;
const SECTION_LABEL_KEYS: Record<(typeof SECTION_IDS)[number], string> = {
"section-general": "insights.navGeneral",
"section-bp": "insights.navBloodPressure",
"section-weight": "insights.navWeight",
"section-pulse": "insights.navPulse",