From 4d88764e4f7f80ef39b69065a53bda1f8ffb2940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 15 May 2026 16:45:55 +0200 Subject: [PATCH] fix(coach): collapse the evidence disclosure to closed-by-default The assistant bubble's evidence `
` mounted open whenever the user had `coachPrefs.showEvidenceByDefault = true`, which surfaced the raw measurement values (e.g. "Blutdruck letzte 30 Tage: 226") under every reply. The disclosure is now always collapsed; the user expands by click. The persisted pref stays in the schema for backward compatibility but no UI reads or writes it, so the value is dead-code- tolerated for one release and can be dropped in the next migration. Drops the `evidenceDefaultOpen` prop wiring from `` and the corresponding `` in the Coach settings sheet. Adjusts the sheet test that previously asserted the toggle was rendered. --- .../__tests__/coach-settings-sheet.test.tsx | 3 +- .../coach-panel/coach-settings-sheet.tsx | 32 ++++--------------- .../insights/coach-panel/message-thread.tsx | 30 +++++++---------- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/components/insights/coach-panel/__tests__/coach-settings-sheet.test.tsx b/src/components/insights/coach-panel/__tests__/coach-settings-sheet.test.tsx index db6c8c2b8..d5167d631 100644 --- a/src/components/insights/coach-panel/__tests__/coach-settings-sheet.test.tsx +++ b/src/components/insights/coach-panel/__tests__/coach-settings-sheet.test.tsx @@ -91,7 +91,8 @@ describe("", () => { ); expect(html).not.toContain('data-slot="coach-prefs-skeleton"'); expect(html).toContain('data-slot="coach-prefs-tone"'); - expect(html).toContain('data-slot="coach-prefs-evidence"'); + // v1.4.27 F14 — the `showEvidenceByDefault` switch is retired. + expect(html).not.toContain('data-slot="coach-prefs-evidence"'); }); it("fires a sonner toast on save success (Design-H4)", () => { diff --git a/src/components/insights/coach-panel/coach-settings-sheet.tsx b/src/components/insights/coach-panel/coach-settings-sheet.tsx index 1b4156e9d..b07be2e0f 100644 --- a/src/components/insights/coach-panel/coach-settings-sheet.tsx +++ b/src/components/insights/coach-panel/coach-settings-sheet.tsx @@ -323,31 +323,13 @@ export function CoachSettingsSheet({ - {/* Show evidence by default */} -
-
- -

- {t("insights.coach.settingsEvidenceHint")} -

-
- - setDraft((prev) => ({ - ...prev, - showEvidenceByDefault: next, - })) - } - /> -
+ {/* v1.4.27 F14 — the `showEvidenceByDefault` switch was + retired. The evidence disclosure is now always closed + by default and the user expands by click; surfacing + raw values automatically created an UX trap. The + persisted `coachPrefs.showEvidenceByDefault` field + stays in the schema for backward compatibility, but no + UI reads or writes it. */} )} diff --git a/src/components/insights/coach-panel/message-thread.tsx b/src/components/insights/coach-panel/message-thread.tsx index 9660d1ba0..915ebf061 100644 --- a/src/components/insights/coach-panel/message-thread.tsx +++ b/src/components/insights/coach-panel/message-thread.tsx @@ -15,7 +15,6 @@ import { cn } from "@/lib/utils"; import { useTranslations } from "@/lib/i18n/context"; import { stripChartTokens } from "@/lib/insights/chart-tokens"; import { useAuth } from "@/hooks/use-auth"; -import { useCoachPrefs } from "@/hooks/use-coach-prefs"; import { SourceChips } from "./source-chips"; import type { @@ -105,13 +104,13 @@ export function MessageThread({ const scrollerRef = useRef(null); const wasPinnedRef = useRef(true); - // v1.4.23 H4 — read the user's Coach prefs so the evidence - // disclosure honours `showEvidenceByDefault`. Cached at the - // queryClient level via the shared `useCoachPrefs` hook; the - // settings sheet writes the same key after a successful save so the - // new default takes effect on the next reply without a page reload. - const { data: coachPrefs } = useCoachPrefs(); - const evidenceDefaultOpen = coachPrefs?.showEvidenceByDefault ?? false; + // v1.4.27 F14 — the evidence disclosure used to honour an opt-in + // `coachPrefs.showEvidenceByDefault` flag that surfaced the raw + // measurement values unconditionally. The flag created an UX trap + // (Marc 2026-05-15: "literal metric values exposed under every + // bubble") so the disclosure is now collapsed by default for every + // reply. The user expands by click; the pref is retired in the + // settings sheet so nothing flips it back on. const messages: CoachMessageDTO[] = useMemo( () => conversation?.messages ?? [], @@ -239,7 +238,6 @@ export function MessageThread({ content={m.content} metricSource={m.metricSource} providerType={m.providerType} - evidenceDefaultOpen={evidenceDefaultOpen} messageId={m.id} /> ); @@ -269,7 +267,6 @@ export function MessageThread({ providerType={streaming.inProgress ? "streaming" : null} inProgress={streaming.inProgress} errorCode={streaming.errorCode} - evidenceDefaultOpen={evidenceDefaultOpen} /> )} @@ -299,8 +296,6 @@ interface ChatBubbleProps { providerType?: string | null; inProgress?: boolean; errorCode?: string | null; - /** v1.4.23 H4 — when true the evidence `
` mounts open. */ - evidenceDefaultOpen?: boolean; /** * v1.4.23 H7 — present only on persisted assistant messages. * Streaming bubbles (no message id yet) skip the thumbs row so the @@ -316,7 +311,6 @@ function ChatBubble({ providerType, inProgress, errorCode, - evidenceDefaultOpen, messageId, }: ChatBubbleProps) { const { t } = useTranslations(); @@ -428,11 +422,11 @@ function ChatBubble({ {keyValues.length > 0 && (