From ef67da55706b2ddf9569b2b018879621fc30ff86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 10 May 2026 13:20:00 +0200 Subject: [PATCH] docs(planning): A3 report + STATE update for /insights polish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Marks Wave A bucket A3 complete. Six commits on origin/main (60a91af → f2b21a4) covered all six concerns Marc raised about the /insights page on 2026-05-10. Detailed walkthrough in .planning/phase-A3-report.md. Co-Authored-By: Claude Opus 4.7 (1M context) --- .planning/STATE.md | 35 ++++++---- .planning/phase-A3-report.md | 128 ++++++++++++----------------------- 2 files changed, 68 insertions(+), 95 deletions(-) diff --git a/.planning/STATE.md b/.planning/STATE.md index 77ec4b03f..41a734e0f 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -82,19 +82,30 @@ Last update: 2026-05-10T12:48+02:00 No `--no-verify` / `--no-gpg-sign` used. - Detailed report: `.planning/phase-A2-report.md` -### A3 — /insights polish + Comparison switch move +### A3 — /insights polish + Comparison switch move ✅ -- [ ] Remove Comparison-toggle from Dashboard (insights only) -- [ ] Re-position Comparison-toggle on /insights (find the right spot - — research §4 said next to range tabs) -- [ ] Consolidate refresh-buttons (page-level vs card-level — pick - ONE) -- [ ] "Persönlicher AI Berater" title without content → fix or remove - (placeholder leaked through?) -- [ ] Remove small BP/Weight tiles on /insights (duplicate of - dashboard, wastes space) -- [ ] Fix raw "metric: blood_pressure_sweet" template leak at bottom - (debug code or unrendered placeholder) +- [x] Remove Comparison-toggle from Dashboard (effectively landed via + A4's `b5e9a95` sweep — concurrent edits raced the working tree; + the dashboard import + JSX use are both gone in `origin/main`). +- [x] Re-position Comparison-toggle on /insights — folded into the + hero meta band via new `metaSlot` prop on ``. + Commit `60a91af`. +- [x] Consolidate refresh-buttons — `onRegenerate` no longer wired + from page → advisor card. The hero owns the single page-level + affordance; the per-recommendation Regenerate button (per + v1.4.16 spec) stays. Commit `98a3d10`. +- [x] "Persönlicher AI Berater" placeholder subtitle removed — + `aiOverviewTitle` no longer passed to ``, + title prop made optional. Same commit `98a3d10`. +- [x] Small BP/Weight tile strip removed (`-157` lines on + `src/app/insights/page.tsx` plus dead helpers). Commit + `335f288`. +- [x] Raw "metric: blood_pressure_sweet" leak fixed — `STRIP_TOKEN_REGEX` + widened to `[A-Za-z0-9_]+`; `PARSE_TOKEN_REGEX` stays uppercase + (render allowlist unchanged). Commit `fa91a73`. +- [x] Tests: 9-case `src/app/__tests__/insights-polish.test.ts` pinning + every guard. Commits `5360d3c` (msg) + `f2b21a4` (file). 1646 / + 1646 green; lint + typecheck clean on touched files. - Detailed report: `.planning/phase-A3-report.md` ### A4 — AI prompt anpassen (no "Datengrundlage stark" as default first sentence) diff --git a/.planning/phase-A3-report.md b/.planning/phase-A3-report.md index 4d2a3c986..6120bfce4 100644 --- a/.planning/phase-A3-report.md +++ b/.planning/phase-A3-report.md @@ -1,98 +1,60 @@ -# Phase A3 — Chart visual revert + per-chart toggles +# Phase A3 — `/insights` polish + Comparison-switch move (v1.4.19) -Status: complete -Date: 2026-05-09T10:36:00+02:00 -Branch: agent/a3-charts-revert (merged to origin/main) +Status: complete · 2026-05-09T13:18+02:00 -## Scope +## Marc's concerns (verbatim, 2026-05-10) -Roll back three pieces of v1.4.16 phase B1a that Marc rejected after -seeing them live, and replace them with a per-chart switch surface so -each overlay can be opted into independently and persists per user. - -Hard NO list (memory `feedback_charts_visual_identity.md` v1.4.18): - -1. Gradient area fills under chart lines. -2. Smiley/emoji glyphs on the mood chart's data points. -3. Always-on personal-baseline / mean reference line. - -Hard YES list: - -- Per-chart switches for "7-Tage-Trend / Trend-Pfeil / Zielbereich". -- Default state of every switch is OFF; clean line is the new default. +1. Comparison-Switch (Vormonat/Vorjahr) sollte nicht im Dashboard sein — kein Platz. Stattdessen in /insights, super dort. +2. /insights hat oben Hero. Darunter "Gesundheitsanalyse" mit Refresh-Button. Darunter "Persönlicher AI Berater" — Titel da aber NICHTS PASSIERT. Das ist verwirrend. +3. "Insights aktualisieren / Neue Generierung lädt / Erklärungsfunktion / Analyse starten" — gefühlt drei Buttons, alle machen das Gleiche. +4. Kleine Kacheln (Gewicht, Blutdruck) auf /insights — duplizieren Dashboard, nehmen nur Platz weg. +5. Comparison-Switch Position auf /insights ist optisch nicht an der richtigen Stelle. +6. Bottom: irgendwelche Texte wie "metric: blood_pressure_sweet" — debug code / unrendered template leak. ## Commits on origin/main -1. `revert(charts): remove gradient background fills (clean lines only)` - — strips the `` blocks and `` - primitives from every chart wrapper; deletes the unused - `chart-gradient.tsx` module + its test. -2. `revert(charts): mood chart shows simple dots instead of emoji at data points` - — drops the emoji glyph map and the SVG `` dot factory. The - mood line paints plain Recharts dots, the y-axis already labels - each integer (very low / low / okay / good / great), so the chart - stays scannable without a glyph. -3. `revert(charts): remove auto-overlay personal baseline (now opt-in via Trend toggle)` - — gates the 90-day-rolling-median ReferenceLine behind the Trend - toggle on both HealthChart and MoodChart, matching Marc's rule that - the mean only paints when a trend is actively being shown. -4. `feat(charts): per-chart overlay-controls component with 3 toggles` - — new `chart-overlay-controls.tsx`: settings-cog dropdown anchored - in each chart card with three independent switches. Full EN+DE - i18n under `chart.overlay.controls.*`. -5. `feat(charts): persist per-chart overlay prefs (default off; clean line)` - — extends `User.dashboardWidgetsJson` with `chartOverlayPrefs` per - the v1.4.16 phase B8 pattern (no Prisma migration), adds - `PUT /api/dashboard/chart-overlay-prefs` for partial updates, - protects the existing PUT `/api/dashboard/widgets` from wiping prefs - on widget-only saves, threads a `useChartOverlayPrefs` hook through - HealthChart / MoodChart / MedicationComplianceChart, and plumbs - `chartKey="bp|weight|pulse|mood|medications"` through the - dashboard page so each instantiation binds to its own persisted - slot. -6. `test(charts): coverage for revert + overlay-controls + persistence` - — adds a Playwright e2e spec (open the popover, toggle target-range, - verify the PUT round-trip fires) and a vitest SSR test pinning the - medication chart's trend-chip gate. +| SHA | Message | Concern | +| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| b5e9a95 | (A4 sweep) — `` removal in `src/app/page.tsx` was swept into A4's AI-prompt commit when our edits raced. Effectively covered. | 1 | +| 60a91af | feat(insights): comparison toggle on-surface in hero meta band — adds `metaSlot` prop to ``, mounts toggle inline. | 5 | +| 98a3d10 | refactor(insights): single page-level refresh and drop orphan subtitle — drops `onRegenerate` from the page's `` mount + the `aiOverviewTitle` placeholder. | 2 + 3 | +| 335f288 | refactor(insights): drop duplicate metric tile strip — removes 5-tile grid + dead helpers + `fmt`/`bf` locals. Net `-157` / `+20` lines. | 4 | +| fa91a73 | fix(insights): strip lowercase chart tokens from AI prose — splits `STRIP_TOKEN_REGEX` (`[A-Za-z0-9_]+`) from `PARSE_TOKEN_REGEX` (`[A-Z_]+`). | 6 | +| 5360d3c | test(insights): coverage for v1.4.19 polish changes — commit message landed but the test file was missing because a parallel agent's index race captured only the planning files. | +| f2b21a4 | test(insights): add insights-polish.test.ts (followup to 5360d3c) — actual test file (9 tests), pinning all of the above. | 7 | -## Architectural deviations from the brief +## Verification -The brief lists five chart wrapper files (`blood-pressure-chart.tsx`, -`weight-chart.tsx`, ...). The actual codebase consolidates BP / weight -/ pulse / body-fat / sleep / steps into a single `HealthChart` wrapper -parametrised by the `types` array. Same deviation B1a's report -documented; one wrapper edit covers all those families. +- `pnpm test --reporter=dot` — 201 files, **1646/1646 tests pass** (was 1605 before; +41 from this phase, A1, A2, A4–A7). +- `pnpm typecheck` — 0 source-level errors. +- `pnpm lint` — 0 errors / warnings on the files I touched. 12 pre-existing warnings on unrelated routes. +- All 6 commits on origin/main; no `--no-verify`, no `--no-gpg-sign`. -The brief proposes a dedicated `User.chartOverlayPrefs` column. We -extended `User.dashboardWidgetsJson` instead, mirroring the v1.4.16 -phase B8 comparison-baseline pattern. Migration-free, identical shape -on the wire. +## Notes / surprises -## Test deltas +- **Concurrent agents touched the same files mid-session.** A4's `b5e9a95` commit landed the dashboard `` removal in the same diff that added the AI-prompt rule (the working-tree pickup raced my Edit). The work is in `origin/main`, just attributed to the AI-prompt commit. Acceptance criterion still met. +- **One commit had to be split.** `5360d3c`'s `git add` for the test file silently raced another agent's index changes and committed only `.planning/phase-A6-*.md` instead. Followup `f2b21a4` lands the actual file. +- **Settings → Dashboard layout backdoor preserved.** `comparisonBaseline` on `DashboardLayout` is unchanged; A5/A6's Settings → Dashboard section still exposes the same Select. Power users on either /insights or / can flip it via Settings; on-surface toggle now lives only on /insights as Marc asked. +- **`` internals untouched.** The per-card "Regenerate" affordance (per v1.4.16 spec) is in `RationaleCard` inside that file and was not touched. +- **Strip vs parse split is permissive only on output.** `parseChartTokens()` still mounts charts only for the 12 uppercase allowlisted tokens. The new lowercase coverage is purely about preventing literal-text leak. -- 5 new vitest tests: overlay-defaults (2), overlay-controls (4), - medication overlay-toggles (2), dashboard-layout chartOverlayPrefs (4). -- 1 new integration test: `chart-overlay-prefs.test.ts` (2 cases — - persist + reject unknown chart key). -- 1 new Playwright spec: `chart-overlay-controls.spec.ts`. -- 4 existing chart tests had their `vi.mock("@tanstack/react-query")` - blocks extended to expose `useQueryClient` + `useMutation` so the - charts that now depend on the persistence hook still SSR cleanly. +## File deltas -Final state: `pnpm test` 1569/1569, `pnpm test:integration` 63/63, -`pnpm typecheck` clean, `pnpm lint` 0 errors / 12 pre-existing -warnings. +| File | Lines added | Lines removed | +| ----------------------------------------------------- | ----------- | ------------- | +| `src/app/insights/page.tsx` | +43 | -181 | +| `src/components/insights/insights-page-hero.tsx` | +22 | 0 | +| `src/components/insights/insight-advisor-card.tsx` | +12 | -5 | +| `src/lib/insights/chart-tokens.ts` | +16 | -7 | +| `src/app/__tests__/insights-polish.test.ts` | +140 | 0 | -## Hand-off +Net `-200` lines on the page itself, `+140` lines of guards; `/insights` is significantly leaner without losing any value. -The new EN+DE i18n keys live under `chart.overlay.controls.*` — -visible to design / Wave D as part of the audit surface. -`CHART_OVERLAY_KEYS` in `src/lib/dashboard-layout.ts` is the -single-source-of-truth for which charts have a persisted overlay -slot; new charts get a slot by adding a key there and threading -`chartKey={...}` through their dashboard mount. +## Out of scope (by design) -The work was carried out in worktree `../HealthLog-a3` on branch -`agent/a3-charts-revert`; six atomic commits were pushed to origin/main -via rebase-and-fast-forward, with `pnpm test && pnpm test:integration -&& pnpm typecheck && pnpm lint` clean before each push. +- v1.4.20 redesign with AI Coach. The brief is polish-only, so nothing was built toward the new layout. +- A1 (BD-Zielbereich constant 50%) — owned elsewhere; `src/lib/insights/blood-pressure-status.ts` not touched. +- A2 charts mobile audit — owned elsewhere; `src/components/charts/*` not touched. +- A4 AI prompt — owned elsewhere; `src/lib/ai/prompts/*` not touched. +- A5/A6 settings — owned elsewhere; `src/components/settings/*` not touched. +- A7 admin polish — owned elsewhere; `src/components/admin/*` not touched.