merge: QA fix polish into release/v1.25.0

This commit is contained in:
Marc-André Bombeck committed 2026-06-28 18:36:56 +02:00
commit 3d304acf1e
19 files changed
+566 -180

No files matched your search

@@ -27,6 +27,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { NativeSelect } from "@/components/ui/native-select";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import { apiDelete, apiFetch, apiPatch, apiPost } from "@/lib/api/api-fetch";
import { useTranslations } from "@/lib/i18n/context";
import { invalidateKeys, queryKeys } from "@/lib/query-keys";
@@ -136,6 +137,7 @@ export function InboundDocumentsView() {
type="file"
accept="image/jpeg,image/png,image/webp,application/pdf"
className="max-w-xs"
aria-label={t("documents.upload.fileLabel")}
disabled={upload.isPending}
/>
<Button
@@ -163,12 +165,13 @@ export function InboundDocumentsView() {
{/* Document list */}
<section className="flex flex-col gap-2">
{list.isLoading ? (
<div className="flex h-24 items-center justify-center">
<Loader2
className="text-primary h-6 w-6 animate-spin motion-reduce:animate-none"
aria-hidden
/>
</div>
// Skeleton rows (not a centered spinner) so the resolved list lands
// in place without a layout jump — the app's loading convention.
<>
{[0, 1, 2].map((i) => (
<Skeleton key={i} className="h-10 w-full rounded-md" />
))}
</>
) : !list.data || list.data.documents.length === 0 ? (
<p className="text-muted-foreground text-sm">
{t("documents.list.empty")}
@@ -178,10 +181,11 @@ export function InboundDocumentsView() {
<button
key={doc.id}
type="button"
aria-expanded={selectedId === doc.id}
onClick={() =>
setSelectedId(selectedId === doc.id ? null : doc.id)
}
className="hover:bg-accent flex items-center justify-between rounded-md border px-3 py-2 text-left text-sm"
className="hover:bg-accent flex min-h-11 items-center justify-between rounded-md border px-3 py-2 text-left text-sm"
>
<span className="truncate">
{doc.filename ?? t(`documents.kind.${doc.kind}`)}
@@ -256,12 +260,16 @@ function DocumentReview({
if (detail.isLoading) {
return (
<div className="flex h-24 items-center justify-center">
<Loader2
className="text-primary h-6 w-6 animate-spin motion-reduce:animate-none"
aria-hidden
/>
</div>
<Card>
<CardHeader className="flex-row items-center justify-between space-y-0">
<Skeleton className="h-5 w-40" />
<Skeleton className="h-8 w-20" />
</CardHeader>
<CardContent className="flex flex-col gap-3">
<Skeleton className="h-20 w-full rounded-md" />
<Skeleton className="h-20 w-full rounded-md" />
</CardContent>
</Card>
);
}
if (!detail.data) return null;
@@ -365,7 +373,12 @@ function FactCard({
{t(`documents.factType.${fact.factType}`)}
</Badge>
{fact.needsReview ? (
<Badge variant="destructive">
// Calm warning (amber), not an alarming destructive red — a
// low-confidence fact is a "please check", not an error.
<Badge
variant="outline"
className="border-amber-400 text-amber-700 dark:border-amber-900/60 dark:text-amber-400"
>
{t("documents.review.needsReview")}
</Badge>
) : null}
@@ -384,6 +397,7 @@ function FactCard({
<Button
variant={decision === "approve" ? "default" : "outline"}
size="sm"
className="min-h-11 sm:min-h-9"
disabled={fact.needsReview}
onClick={() =>
onDecision(decision === "approve" ? null : "approve")
@@ -394,6 +408,7 @@ function FactCard({
<Button
variant={decision === "reject" ? "destructive" : "outline"}
size="sm"
className="min-h-11 sm:min-h-9"
onClick={() => onDecision(decision === "reject" ? null : "reject")}
>
{t("documents.review.reject")}
@@ -402,7 +417,12 @@ function FactCard({
</div>
<div className="mt-2">
<Button variant="ghost" size="xs" onClick={() => setEditing((v) => !v)}>
<Button
variant="ghost"
size="xs"
className="min-h-11 sm:min-h-8"
onClick={() => setEditing((v) => !v)}
>
{editing ? t("documents.review.cancel") : t("documents.review.edit")}
</Button>
</div>
@@ -549,6 +569,7 @@ function EditFields({
</div>
<Button
size="sm"
className="min-h-11 sm:min-h-9"
disabled={pending}
onClick={() => onSubmit(vals, date.trim() === "" ? null : date)}
>
+5 -1
View File
@@ -146,7 +146,11 @@ export function AskCoachIconButton({
aria-label={accessibleLabel}
onClick={() => launch.askCoach(question, scope, autoSend)}
className={cn(
"text-muted-foreground hover:text-foreground size-8",
// Keep the quiet 32px visual on pointer surfaces, but grow the
// tap target to the WCAG 2.5.5 44px floor on touch (the ghost has
// no fill, so the larger hit box is invisible). Matches the
// header-action convention on the biomarker detail page.
"text-muted-foreground hover:text-foreground min-h-11 min-w-11 sm:size-8",
className,
)}
>
@@ -9,6 +9,7 @@ import { formatUpdatedLabel } from "@/lib/i18n/relative-time";
import { queryKeys } from "@/lib/query-keys";
import { useAuth } from "@/hooks/use-auth";
import { cn } from "@/lib/utils";
import { Skeleton } from "@/components/ui/skeleton";
import { SectionHeading } from "@/components/insights/section-heading";
import { AskCoachAction } from "@/components/insights/ask-coach-action";
import { ProseBlocks } from "@/components/insights/prose-blocks";
@@ -108,9 +109,9 @@ export function PeriodNarrativeCard({
aria-hidden="true"
className={SKELETON_SHELL}
>
<div className="bg-muted/40 h-4 w-full rounded" />
<div className="bg-muted/40 h-4 w-5/6 rounded" />
<div className="bg-muted/40 h-4 w-2/3 rounded" />
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-5/6" />
<Skeleton className="h-4 w-2/3" />
</div>
</section>
);
@@ -70,6 +70,13 @@ export function SleepDebtCard({ debt }: { debt: SleepDebtDto }) {
<CardTitle className="text-base font-semibold">
{t("insights.sleep.debt.title")}
</CardTitle>
{/* v1.25.0 — the resolved full-debt card is the common case and the
place the figure most needs context: explain the COMPUTED engine
and that it differs from a wearable's native number here too, not
only in the still-learning `partial` state above. */}
{debt.source === "COMPUTED" ? (
<InfoHint label={t("insights.sleep.debt.computedInfo")} />
) : null}
</div>
</CardHeader>
<CardContent>
@@ -87,17 +87,14 @@ function renderWithCache() {
defaultOptions: { queries: { retry: false } },
});
queryClient.setQueryData(queryKeys.biomarkerDetail(BIOMARKER_ID), MARKER);
// The reading feed is an offset-paginated `useInfiniteQuery` (v1.25) — seed
// the accumulated-pages cache shape under its key.
queryClient.setQueryData(
queryKeys.labResultsList({
queryKeys.labResultsInfinite({
biomarkerId: BIOMARKER_ID,
analyte: undefined,
panel: undefined,
from: undefined,
to: undefined,
page: 0,
sortDir: "desc",
}),
LIST,
{ pages: [LIST], pageParams: [0] },
);
queryClient.setQueryData(
queryKeys.insightsBiomarkerAssessment(BIOMARKER_ID, "en"),
+51 -17
View File
@@ -2,7 +2,12 @@
import { useMemo, useState } from "react";
import { useRouter } from "next/navigation";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
useInfiniteQuery,
useMutation,
useQuery,
useQueryClient,
} from "@tanstack/react-query";
import { FlaskConical, Pencil, Plus, SlidersHorizontal } from "lucide-react";
import { toast } from "sonner";
@@ -63,6 +68,11 @@ function LabBiomarkerChart(
);
}
// Page size for the offset-paginated reading feed. The server caps a single
// read at 500 (`listLabResultsSchema`); this stays well under that and keeps
// the first paint light, with "Load more" pulling subsequent pages.
const READINGS_PAGE_SIZE = 200;
/**
* v1.18.1 — per-biomarker detail: heading + current-value badge, the proper
* dashboard-style chart with the reference band, and the editable reading
@@ -102,30 +112,40 @@ export function LabBiomarkerDetail({ biomarkerId }: { biomarkerId: string }) {
queryFn: () => apiGet<BiomarkerDto>(`/api/biomarkers/${biomarkerId}`),
});
// v1.25 — offset-paginated reading feed. The page no longer fetches a single
// `limit=500` window (which silently truncated a marker once it crossed 500
// readings); it loads a page at a time and a "Load more" control reveals the
// rest. The chart + stat strip render the accumulated set, so loading more
// also extends the trend rather than re-fetching the whole history.
const {
data: list,
isLoading,
isError: listError,
} = useQuery({
queryKey: queryKeys.labResultsList({
biomarkerId,
analyte: undefined,
panel: undefined,
from: undefined,
to: undefined,
page: 0,
sortDir: "desc",
}),
queryFn: () =>
fetchNextPage,
hasNextPage,
isFetchingNextPage,
} = useInfiniteQuery({
queryKey: queryKeys.labResultsInfinite({ biomarkerId, sortDir: "desc" }),
initialPageParam: 0,
queryFn: ({ pageParam }) =>
apiGet<LabResultListResponse>(
`/api/labs?biomarkerId=${encodeURIComponent(biomarkerId)}&limit=500&sortDir=desc`,
`/api/labs?biomarkerId=${encodeURIComponent(
biomarkerId,
)}&limit=${READINGS_PAGE_SIZE}&offset=${pageParam}&sortDir=desc`,
),
getNextPageParam: (lastPage) => {
const next = lastPage.meta.offset + lastPage.meta.limit;
return next < lastPage.meta.total ? next : undefined;
},
});
const readings: LabResultDto[] = useMemo(() => list?.results ?? [], [list]);
// The reading feed caps at 500 server-side; surface a hint when truncated.
const total = list?.meta?.total ?? 0;
const truncated = total > readings.length;
const readings: LabResultDto[] = useMemo(
() => list?.pages.flatMap((p) => p.results) ?? [],
[list],
);
const total = list?.pages[0]?.meta.total ?? 0;
// More rows exist on the server than are currently loaded.
const truncated = hasNextPage ?? false;
const latest =
readings.length > 0
? [...readings].sort(
@@ -378,6 +398,20 @@ export function LabBiomarkerDetail({ biomarkerId }: { biomarkerId: string }) {
<LabHistoryList readings={readings} />
</CardContent>
</Card>
{hasNextPage ? (
<div className="flex justify-center">
<Button
variant="outline"
className="min-h-11 sm:min-h-9"
disabled={isFetchingNextPage}
onClick={() => fetchNextPage()}
>
{isFetchingNextPage
? t("common.loading")
: t("labs.loadMoreReadings")}
</Button>
</div>
) : null}
</div>
) : null}
+62 -13
View File
@@ -88,8 +88,12 @@ export function EnvironmentSection() {
// ── geocoding search (shared by home + travel pickers) ──────────────────
const [homeQuery, setHomeQuery] = useState("");
const [homeResults, setHomeResults] = useState<GeocodeResult[]>([]);
// Tracks whether a geocode has completed for the current query so a
// zero-result search can surface a "no matches" line instead of silence.
const [homeSearched, setHomeSearched] = useState(false);
const [travelQuery, setTravelQuery] = useState("");
const [travelResults, setTravelResults] = useState<GeocodeResult[]>([]);
const [travelSearched, setTravelSearched] = useState(false);
const [travelLoc, setTravelLoc] = useState<GeocodeResult | null>(null);
const [travelStart, setTravelStart] = useState(todayKey());
const [travelEnd, setTravelEnd] = useState(todayKey());
@@ -104,14 +108,20 @@ export function EnvironmentSection() {
const searchHome = useMutation({
mutationKey: queryKeys.environmentGeocode("home"),
mutationFn: () => geocode(homeQuery),
onSuccess: (data) => setHomeResults(data.results),
onSuccess: (data) => {
setHomeResults(data.results);
setHomeSearched(true);
},
onError: () => toast.error(t("settings.sections.environment.searchError")),
});
const searchTravel = useMutation({
mutationKey: queryKeys.environmentGeocode("travel"),
mutationFn: () => geocode(travelQuery),
onSuccess: (data) => setTravelResults(data.results),
onSuccess: (data) => {
setTravelResults(data.results);
setTravelSearched(true);
},
onError: () => toast.error(t("settings.sections.environment.searchError")),
});
@@ -127,6 +137,7 @@ export function EnvironmentSection() {
onSuccess: () => {
setHomeResults([]);
setHomeQuery("");
setHomeSearched(false);
invalidate();
toast.success(t("settings.sections.environment.homeSaved"));
},
@@ -147,6 +158,7 @@ export function EnvironmentSection() {
setTravelLoc(null);
setTravelResults([]);
setTravelQuery("");
setTravelSearched(false);
invalidate();
toast.success(t("settings.sections.environment.travelAdded"));
},
@@ -234,22 +246,39 @@ export function EnvironmentSection() {
{t("settings.sections.environment.home.none")}
</p>
)}
<div className="flex gap-2">
<form
className="flex gap-2"
onSubmit={(e) => {
e.preventDefault();
if (homeQuery.trim().length > 0 && !searchHome.isPending) {
searchHome.mutate();
}
}}
>
<Input
value={homeQuery}
onChange={(e) => setHomeQuery(e.target.value)}
onChange={(e) => {
setHomeQuery(e.target.value);
setHomeSearched(false);
}}
placeholder={t("settings.sections.environment.searchPlaceholder")}
aria-label={t("settings.sections.environment.searchPlaceholder")}
/>
<Button
type="button"
type="submit"
variant="secondary"
disabled={homeQuery.trim().length === 0 || searchHome.isPending}
onClick={() => searchHome.mutate()}
>
{t("settings.sections.environment.search")}
</Button>
</div>
</form>
{homeSearched &&
!searchHome.isPending &&
homeResults.length === 0 && (
<p className="text-muted-foreground text-sm">
{t("settings.sections.environment.noResults")}
</p>
)}
{homeResults.length > 0 && (
<ul className="divide-border divide-y rounded-md border">
{homeResults.map((r) => (
@@ -261,6 +290,7 @@ export function EnvironmentSection() {
<Button
type="button"
size="sm"
className="min-h-11 sm:min-h-9"
disabled={setHome.isPending}
onClick={() => setHome.mutate(r)}
>
@@ -296,8 +326,9 @@ export function EnvironmentSection() {
</span>
<Button
type="button"
size="sm"
size="icon"
variant="ghost"
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
aria-label={t(
"settings.sections.environment.travel.remove",
)}
@@ -315,24 +346,41 @@ export function EnvironmentSection() {
</p>
)}
<div className="flex gap-2">
<form
className="flex gap-2"
onSubmit={(e) => {
e.preventDefault();
if (travelQuery.trim().length > 0 && !searchTravel.isPending) {
searchTravel.mutate();
}
}}
>
<Input
value={travelQuery}
onChange={(e) => setTravelQuery(e.target.value)}
onChange={(e) => {
setTravelQuery(e.target.value);
setTravelSearched(false);
}}
placeholder={t("settings.sections.environment.searchPlaceholder")}
aria-label={t("settings.sections.environment.searchPlaceholder")}
/>
<Button
type="button"
type="submit"
variant="secondary"
disabled={
travelQuery.trim().length === 0 || searchTravel.isPending
}
onClick={() => searchTravel.mutate()}
>
{t("settings.sections.environment.search")}
</Button>
</div>
</form>
{travelSearched &&
!searchTravel.isPending &&
travelResults.length === 0 && (
<p className="text-muted-foreground text-sm">
{t("settings.sections.environment.noResults")}
</p>
)}
{travelResults.length > 0 && (
<ul className="divide-border divide-y rounded-md border">
{travelResults.map((r) => (
@@ -344,6 +392,7 @@ export function EnvironmentSection() {
<Button
type="button"
size="sm"
className="min-h-11 sm:min-h-9"
variant={
travelLoc?.label === r.label ? "default" : "secondary"
}
+5 -1
View File
@@ -36,7 +36,11 @@ export function InfoHint({
data-slot="info-hint"
aria-label={t("common.moreInfo")}
className={cn(
"text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 -m-1 inline-flex min-h-6 min-w-6 shrink-0 items-center justify-center rounded-full p-1 transition-colors focus-visible:ring-2 focus-visible:outline-none",
// A 44px (WCAG 2.5.5) tap target whose visible footprint stays at
// the 24px the icon needs: the 44px box is offset by an equal
// negative margin (`p-2.5` + `-m-2.5`), so surrounding inline
// layout is unchanged while the touchable area meets the floor.
"text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 -m-2.5 inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center rounded-full p-2.5 transition-colors focus-visible:ring-2 focus-visible:outline-none",
className,
)}
>