fix(insights): keep every data-having pill in the default nav and reconcile review findings

The default insights layout shipped a curated visible subset (v1.15.11),
authored for the overview Vitals/Mobility grid. Once the tab strip began
gating its nav pills on the same layout, that subset dropped ~20 nav pills
for a fresh account with data in Sleep, Steps, Active-Energy, body
composition, Walking/mobility, Audio, Daylight, etc. — pills that show
today — and caused a flash-then-vanish on first paint.

The grid renders a fixed mapped subset regardless of tile visibility, so
defaulting every tile visible does not bloat it; what it restores is the
nav's everything-with-data default. The user hides what they don't want.

Also:
- mood distribution + weekday charts: switch axis tick fill from the raw
  --dracula-fg (white-on-white on the light-mode card) to the shared
  --muted-foreground axis-text token; dark mode unchanged.
- drop the orphaned insights.editMode.manageTiles key from all six locales
  (replaced by manageSubPages) and add a manageSubPagesHint noting that
  hiding a detail page also removes its top-nav pill.
- pin the all-visible default with a layout test and a tab-strip
  default-nav regression test.
This commit is contained in:
Marc-André Bombeck committed 2026-06-07 21:01:26 +02:00
1 parent e7e123be01
commit 6164a0c5c2
12 files changed
+147 -59

No files matched your search

@@ -16,6 +16,7 @@ vi.mock("sonner", () => ({ toast: { success: vi.fn() } }));
import { InsightsTabStrip } from "../insights-tab-strip";
import type { InsightInputs } from "@/lib/insights/metric-availability";
import type { DataSummary } from "@/lib/analytics/trends";
import { DEFAULT_INSIGHTS_LAYOUT } from "@/lib/insights-layout";
function render(node: React.ReactNode, locale: "en" | "de" = "en") {
return renderToStaticMarkup(
@@ -339,4 +340,51 @@ describe("<InsightsTabStrip> — saved-layout visibility gate (v1.15.14 W2)", ()
expect(html).toContain('data-group="activity"');
expect(html).toContain(">Activity<");
});
// v1.15.14 — regression guard: the DEFAULT layout's visible set must equal
// the data-only nav set. The v1.15.11 curated default dropped ~20 pills once
// the strip began gating on the layout; making the default all-visible
// restores everything-with-data. Derive `visibleTileIds` straight from
// `DEFAULT_INSIGHTS_LAYOUT` (what a fresh / never-customized account
// resolves to) and assert the long-tail pills + group parents still show
// when their data is present.
it("default layout shows every data-having pill (nav-pill regression guard)", () => {
const visibleTileIds = new Set(
DEFAULT_INSIGHTS_LAYOUT.tiles
.filter((t) => t.visible)
.map((t) => t.id),
);
const availability: InsightInputs = {
summaries: {
SLEEP_DURATION: fakeSummary(20),
ACTIVITY_STEPS: fakeSummary(4200),
ACTIVE_ENERGY_BURNED: fakeSummary(30),
FAT_MASS: fakeSummary(12),
MUSCLE_MASS: fakeSummary(12),
AUDIO_EXPOSURE_ENV: fakeSummary(40),
TIME_IN_DAYLIGHT: fakeSummary(15),
},
hasMood: false,
hasMedication: false,
};
const html = render(
<InsightsTabStrip
availability={availability}
visibleTileIds={visibleTileIds}
/>,
);
// Flat pill that previously regressed out of the default nav.
expect(html).toContain(">Sleep<");
// Group parents that the curated default suppressed: Activity (steps /
// active-energy), Body (fat-mass / muscle-mass), Hearing (audio),
// Environment (daylight).
expect(html).toContain('data-group="activity"');
expect(html).toContain(">Activity<");
expect(html).toContain('data-group="body"');
expect(html).toContain(">Body<");
expect(html).toContain('data-group="hearing"');
expect(html).toContain(">Hearing<");
expect(html).toContain('data-group="environment"');
expect(html).toContain(">Environment<");
});
});
@@ -400,6 +400,15 @@ export function InsightsEditMode({
/>
{t("insights.editMode.manageSubPages")}
</button>
{/* v1.15.14 — flag that hiding a detail page also drops
its top-nav pill, so a user isn't surprised a metric
vanished from the navigation. */}
<p
data-slot="insights-edit-tiles-nav-hint"
className="text-muted-foreground mt-1 text-xs"
>
{t("insights.editMode.manageSubPagesHint")}
</p>
{tilesOpen && (
// v1.15.14 W2 — the manager now lists EVERY sub-page
// slug grouped by category, the same `tiles` layout the
@@ -61,13 +61,25 @@ export function MoodDistributionChart({
<BarChart data={data} margin={{ top: 8, right: 12, bottom: 8, left: 0 }}>
<XAxis
dataKey="label"
tick={{ fontSize: 11, fill: "var(--dracula-fg)" }}
// v1.15.14 — theme-aware axis text. `--dracula-fg` (near-white) is
// not overridden in `:root.light` (Alucard white card) → white-on-
// white. `--muted-foreground` is the token every other in-app chart
// uses for axis ticks and is legible in both themes; dark mode is
// unchanged. The mood-hue bar Cells stay on `--dracula-*` — only the
// axis text legibility changes here.
tick={{ fontSize: 11, fill: "var(--muted-foreground)" }}
stroke="var(--dracula-comment)"
interval={0}
/>
<YAxis
allowDecimals={false}
tick={{ fontSize: 11, fill: "var(--dracula-fg)" }}
// v1.15.14 — theme-aware axis text. `--dracula-fg` (near-white) is
// not overridden in `:root.light` (Alucard white card) → white-on-
// white. `--muted-foreground` is the token every other in-app chart
// uses for axis ticks and is legible in both themes; dark mode is
// unchanged. The mood-hue bar Cells stay on `--dracula-*` — only the
// axis text legibility changes here.
tick={{ fontSize: 11, fill: "var(--muted-foreground)" }}
stroke="var(--dracula-comment)"
width={28}
/>
@@ -85,14 +85,22 @@ export function MoodWeekdayChart({ weekday }: { weekday: MoodWeekdayRow[] }) {
>
<XAxis
dataKey="label"
tick={{ fontSize: 11, fill: "var(--dracula-fg)" }}
// v1.15.14 — theme-aware axis text (see mood-distribution-chart).
// `--dracula-fg` was white-on-white on the light-mode card; switch
// to the shared `--muted-foreground` axis-tick token. Bar mood
// hues stay `--dracula-*`; dark mode is unchanged.
tick={{ fontSize: 11, fill: "var(--muted-foreground)" }}
stroke="var(--dracula-comment)"
interval={0}
/>
<YAxis
domain={[1, 5]}
ticks={[1, 2, 3, 4, 5]}
tick={{ fontSize: 11, fill: "var(--dracula-fg)" }}
// v1.15.14 — theme-aware axis text (see mood-distribution-chart).
// `--dracula-fg` was white-on-white on the light-mode card; switch
// to the shared `--muted-foreground` axis-tick token. Bar mood
// hues stay `--dracula-*`; dark mode is unchanged.
tick={{ fontSize: 11, fill: "var(--muted-foreground)" }}
stroke="var(--dracula-comment)"
width={24}
/>