Merge release/v1.42.0 with the day view into v142/t3-timeline

The timeline now opens a day through the shell's day layer (openDay) and reads ?day= with its parser instead of a copy of both; the capture picker's life-event form starts on the picker's defaultDate like the other forms.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 14:29:25 +02:00
commit 2b89e627ab
68 files changed
+4733 -272

No files matched your search

-11
View File
@@ -10,8 +10,6 @@
* Formatting reads the same UTC instant back with `timeZone: "UTC"`, so a
* date never moves by a day for a reader east or west of Greenwich.
*/
import { isCalendarDateKey } from "@/lib/tz/date-only";
const MS_PER_DAY = 86_400_000;
/** Days since 1970-01-01 for a `YYYY-MM-DD` key. */
@@ -87,15 +85,6 @@ export function todayKeyIn(timeZone: string | undefined, now = new Date()) {
}
}
/** A `?day=` value the timeline accepts: a real date, not in the future. */
export function acceptableDayParam(
raw: string | null | undefined,
today: string,
): string | null {
if (!raw || !isCalendarDateKey(raw)) return null;
return raw <= today ? raw : null;
}
function utcDate(key: string): Date {
return new Date(dayNumber(key) * MS_PER_DAY);
}
+7 -18
View File
@@ -21,6 +21,8 @@ import { useMemo, useState } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import { Plus } from "lucide-react";
import { openDay as openDayLayer } from "@/components/day/day-layer-controller";
import { parseDayParam } from "@/components/day/day-url";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { EmptyState } from "@/components/ui/empty-state";
@@ -53,7 +55,7 @@ import { Segmented } from "./segmented";
import { SelectionBar } from "./selection-bar";
import { TimelineChart } from "./timeline-chart";
import { TimelineChronicle } from "./timeline-chronicle";
import { acceptableDayParam, todayKeyIn } from "./timeline-dates";
import { todayKeyIn } from "./timeline-dates";
import { LANE_ORDER, windowFor } from "./timeline-geometry";
import {
LayersMenu,
@@ -104,17 +106,6 @@ export const DEFAULT_VALUES = [
const VALUES_KEY = "healthlog.timeline.values";
const HIDDEN_LANES_KEY = "healthlog.timeline.hiddenLanes";
/** The `?day=` URL for the current page, other parameters kept. */
export function dayHref(
pathname: string,
search: string,
date: string,
): string {
const next = new URLSearchParams(search);
next.set(DAY_QUERY_PARAM, date);
return `${pathname}?${next.toString()}`;
}
/** The latest dated entry on or before today, to select on arrival. */
function latestEntryDate(
lanes: ReadonlyArray<{
@@ -140,7 +131,7 @@ export function TimelineView() {
const pathname = usePathname();
const searchParams = useSearchParams();
const today = todayKeyIn(user?.timezone);
const dayParam = acceptableDayParam(searchParams.get(DAY_QUERY_PARAM), today);
const dayParam = parseDayParam(searchParams.get(DAY_QUERY_PARAM), today);
// Life events are written in one's own record only (owner-only routes).
const canAddLifeEvent = !caps.inSharedRecord;
@@ -235,14 +226,12 @@ export function TimelineView() {
const effectiveSelected =
selected ?? (data ? latestEntryDate(data.lanes, today) : null) ?? today;
// The shell's day layer owns `?day=` and its history entries; this only
// asks it to open the day, and keeps the selection on it.
function openDay(date: string) {
if (date > today) return;
setPicked({ date, param: date });
window.history.pushState(
{ __healthlogTimelineDay: date },
"",
dayHref(pathname, searchParams.toString(), date),
);
openDayLayer(date);
}
function editLifeEvent(id: string) {