fix(ui): draw no empty frame and say when a read failed

"Since the last visit" was wrapped in a card by the visits section, so
the card stayed on screen empty while the window loaded, when it held
nothing and when the read failed. The component now owns its card and
draws it only with a row; a failed read shows a compact error row.

The same shapes elsewhere: the caffeine card and the mood forecast no
longer open a loading card that most often collapses, and a failed read
on them, the mood tag catalogue, the usual-range strip, the cycle ring
and the measurement drill-down now says so with a retry instead of
passing for no data. The scores strip keeps the ring's cell on a failed
calendar read. The mental-health card no longer draws an empty action
slot for a viewer without the right to start.

The frame guard now also flags a frame whose only content sits behind a
condition.

Refs #1241
This commit is contained in:
Marc-André Bombeck committed 2026-10-19 16:43:52 +02:00
1 parent d00281f35a
commit 38c106e358
23 files changed
+816 -193

No files matched your search

+15 -2
View File
@@ -3,6 +3,7 @@
import { useQuery } from "@tanstack/react-query";
import { Plus } from "lucide-react";
import { QueryErrorRow } from "@/components/ui/query-error-row";
import { Skeleton } from "@/components/ui/skeleton";
import { useAuth } from "@/hooks/use-auth";
import { queryKeys } from "@/lib/query-keys";
@@ -21,7 +22,10 @@ import { selectQuickTagKeys } from "./recent-tags";
*
* Reads the same `/api/mood/tags` catalogue as `MoodTagPicker` (shared query
* key → one network round-trip). Renders nothing while the catalogue is
* empty so a cleared taxonomy degrades gracefully.
* empty so a cleared taxonomy degrades gracefully. The loading placeholder
* stays because the catalogue ships seeded and the row nearly always fills
* it; a failed read says so with a retry rather than leaving the sheet
* without its tags and without a word.
*/
interface CatalogTag {
@@ -59,7 +63,7 @@ export function MoodQuickTags({
const { isAuthenticated } = useAuth();
const { t } = useTranslations();
const { data, isLoading } = useQuery({
const { data, isLoading, isError, refetch } = useQuery({
queryKey: queryKeys.moodTagCatalog(),
queryFn: async () => apiGet<CatalogResponse>("/api/mood/tags"),
enabled: isAuthenticated,
@@ -69,6 +73,15 @@ export function MoodQuickTags({
if (isLoading) {
return <Skeleton className="h-11 w-full rounded-lg" />;
}
if (isError && !data) {
return (
<QueryErrorRow
slot="mood-quick-tags-error"
message={t("mood.tagCatalogLoadError")}
onRetry={() => void refetch()}
/>
);
}
if (!data || data.categories.length === 0) return null;
// Flatten the catalogue to binary tags only; the Quick row never carries
+15 -1
View File
@@ -4,6 +4,7 @@ import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { Plus, Tag } from "lucide-react";
import { QueryErrorRow } from "@/components/ui/query-error-row";
import { Skeleton } from "@/components/ui/skeleton";
import { useAuth } from "@/hooks/use-auth";
import { queryKeys } from "@/lib/query-keys";
@@ -104,7 +105,7 @@ export function MoodTagPicker({
// tile belongs to, or null when closed.
const [createGroupKey, setCreateGroupKey] = useState<string | null>(null);
const { data, isLoading } = useQuery({
const { data, isLoading, isError, refetch } = useQuery({
queryKey: queryKeys.moodTagCatalog(),
queryFn: async () => {
return apiGet<CatalogResponse>("/api/mood/tags");
@@ -114,10 +115,23 @@ export function MoodTagPicker({
staleTime: 60 * 60 * 1000,
});
// The placeholder stays: the catalogue ships seeded, so the picker nearly
// always fills it. A failed read says so with a retry; it used to leave the
// field without its tags and without a word.
if (isLoading) {
return <Skeleton className="h-24 w-full rounded-lg" />;
}
if (isError && !data) {
return (
<QueryErrorRow
slot="mood-tag-picker-error"
message={t("mood.tagCatalogLoadError")}
onRetry={() => void refetch()}
/>
);
}
if (!data || data.categories.length === 0) {
return null;
}