feat: add the timeline page, its readiness inventory and life-event entry

The opt-in timeline module gets its page (#613). At 768 px and up the
record's lanes (life, conditions, allergies, medications, vaccinations,
doctor and procedures, labs, documents) are drawn in one SVG on a shared
time axis, with a year, month or week grid, open periods ending in an
arrow, a dashed lead-in where a start is unknown, dose marks and pauses on
the medication they belong to, a Today line and a selection line. Up to
three neutral value lines run below as monthly means, chosen in a menu.
Recharts stays for every value chart; this surface is plain SVG like the
heatmaps.

All geometry is pure (timeline-geometry.ts): window, scale, row packing
and label placement through one occupancy map, so no label overlaps
another label or a bar, none runs past the card edge, and labels that do
not fit are left out rather than squeezed. The width comes from a
ResizeObserver, so a docked day panel re-runs the layout.

The bar under the chart names the selected month's entries as chips, the
month's means and "Open 3 Jan.", which puts ?day= in the URL for the day
layer. The chart is one tab stop: arrows move the selection by a day, a
month or a year with the zoom, Home and End jump to the ends, Enter opens
the day. A visually hidden table lists every entry for screen readers.
The legend says once that stacked means at the same time, not cause and
effect.

Below 768 px the timeline is a chronicle, newest first by month or year,
with an Ongoing block for what has no meaningful start, rails beside the
rows an episode or course spans, and empty stretches named as such.

Switching the module on in Settings opens the readiness inventory: each
lane carries, is thin or is empty, with one link per gap and the verdict
as a count. The same inventory sits as a dismissible card on the timeline
while a gap is open, and under Layers as "Data coverage".

Life events are entered in a sheet (title, kind, a date to the day, month
or year, an optional end, an optional note) from the timeline, the
capture picker and the dashboard's add menu; one surface line maps the
capture kind to the timeline module, and it is offered in one's own
record only. Deleting asks first.

Server routes are built in parallel; the e2e journey answers them with the
contract's shapes. Copy in all seven locales; the timeline and lifeEvents
release-pending prefixes are gone.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 14:27:02 +02:00
1 parent b8f6372963
commit 32258bc5ab
50 files changed
+8277 -54

No files matched your search

@@ -155,6 +155,8 @@ describe("<DashboardHeader> — every entry follows its module, as the capture p
{ workouts: false },
{ illness: false },
{ mood: false, medications: false, workouts: false, illness: false },
{ timeline: false },
{ timeline: true },
];
for (const modules of cases) {
modulesRef.value = modules;
@@ -173,6 +175,7 @@ describe("<DashboardHeader> — every entry follows its module, as the capture p
mood: "Log mood",
symptom: "Log symptom",
workout: "Log workout",
lifeEvent: "Log life event",
} as const;
for (const kind of CAPTURE_KIND_ORDER) {
expect(
@@ -14,6 +14,7 @@ import { useMemo } from "react";
import Link from "next/link";
import {
Activity,
Flag,
Footprints,
Pill,
Plus,
@@ -72,6 +73,7 @@ export function DashboardHeader({
const canAddMood = offered.includes("mood");
const canAddSymptom = offered.includes("symptom");
const canAddWorkout = offered.includes("workout");
const canAddLifeEvent = offered.includes("lifeEvent");
const canAddAnything = offered.length > 0;
// The pre-hero greeting derivation, kept hydration-safe: `user` comes
@@ -219,6 +221,12 @@ export function DashboardHeader({
{t("dashboard.quickAddWorkout")}
</DropdownMenuItem>
)}
{canAddLifeEvent && (
<DropdownMenuItem onClick={() => onQuickEntry("lifeEvent")}>
<Flag className="mr-2 h-4 w-4" aria-hidden="true" />
{t("dashboard.quickAddLifeEvent")}
</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
)}
@@ -18,6 +18,7 @@ import {
MoodForm,
SymptomEntryForm,
} from "@/components/dashboard/quick-entry-forms.lazy";
import { LifeEventForm } from "@/components/timeline/life-event-form.lazy";
import {
AlertDialog,
AlertDialogAction,
@@ -36,7 +37,13 @@ import {
import type { ShareDomain } from "@/lib/sharing/scope";
export type QuickEntryDialog =
"measurement" | "mood" | "medicationIntake" | "symptom" | "workout" | null;
| "measurement"
| "mood"
| "medicationIntake"
| "symptom"
| "workout"
| "lifeEvent"
| null;
/**
* The section each sheet writes to; see the capture picker. `null` marks a
@@ -51,6 +58,8 @@ const QUICK_ENTRY_DOMAIN: Readonly<
mood: "mind",
symptom: "illness",
workout: null,
// v1.42 — life events are written in one's own record only.
lifeEvent: null,
};
/**
@@ -170,6 +179,8 @@ export function QuickEntrySheets({
const [symptomFooterEl, setSymptomFooterEl] = useState<HTMLDivElement | null>(
null,
);
const [lifeEventFooterEl, setLifeEventFooterEl] =
useState<HTMLDivElement | null>(null);
// v1.11.3 F3 — when an open quick-entry sheet is dismissed with
// unsaved input, hold the close in this flag and surface a confirm
// instead of nulling the dialog outright. Cleared once the user
@@ -269,6 +280,24 @@ export function QuickEntrySheets({
)}
</ResponsiveSheet>
{/* v1.42 — a life event (the opt-in timeline module). Mounted only
while open, so every opening starts from an empty draft. */}
<ResponsiveSheet
open={openSheet === "lifeEvent"}
onOpenChange={handleQuickEntryOpenChange}
title={t("lifeEvents.title")}
description={t("lifeEvents.subtitle")}
footer={<div ref={setLifeEventFooterEl} className="flex w-full" />}
>
{openSheet === "lifeEvent" && (
<LifeEventForm
onSuccess={onClose}
onCancel={onClose}
footerSlot={lifeEventFooterEl}
/>
)}
</ResponsiveSheet>
{/* v1.11.3 F3 — confirm before discarding a partly-filled
quick-entry form when the sheet is dismissed by an overlay
tap, Escape, or a mobile swipe-down. Keeps the sheet open