fix(ux): honest deletes, stable hydration and tidy numbers after release review

Server and first client render now agree everywhere query state used to
leak into the chrome, checkboxes no longer nest inside buttons, delete
confirmations admit the undo they offer, raw step counts drop their
decimals, the truncated unit label wraps instead, streaks know their
singular, the medication header speaks the user's date format, a failed
coach turn keeps the user's message and says what went wrong, settings
status notes follow a language switch, the locale only flips once its
bundle actually loaded, and the last raw api fetches in hooks move onto
the shared client.
This commit is contained in:
Marc-André Bombeck committed 2026-06-11 03:30:18 +02:00
1 parent 25f41f88fe
commit a8149e0bdf
35 files changed
+347 -191

No files matched your search

@@ -459,15 +459,21 @@ function ChatBubble({
a classic typing indicator (three pulsing dots) instead
of the old whole-bubble pulse + "Thinking…" prose. The
prose stays as the screen-reader announcement. */}
{/* v1.16.4 — a failed turn with no streamed prose renders the
error copy INSIDE the bubble instead of an empty bubble
with a caption below it. With partial prose the prose
keeps the bubble and the error stays a caption. */}
{content ? (
stripChartTokens(content)
) : inProgress ? (
<TypingDots label={t("insights.coach.thinking")} />
) : safeError ? (
<span className="text-warning/90">{safeError}</span>
) : (
""
)}
</div>
{safeError && (
{safeError && content && (
<p className="text-warning/90 text-xs">{safeError}</p>
)}
{/* v1.12.0 — collapse the whole provenance block ("what was
@@ -400,10 +400,11 @@ export function useSendCoachMessage(opts: UseSendCoachMessageOptions = {}) {
messageId: null,
errorCode: structured ?? `coach.http.${response.status}`,
});
// Drop the optimistic user bubble on the error path too so
// the next refetch — which still has the persisted user
// message — doesn't render the same bubble twice.
setOptimisticUser(null);
// v1.16.4 — KEEP the optimistic user bubble: a rejected turn
// (budget gate, 4xx) has no persisted twin coming, and dropping
// the bubble left the error standing next to an empty thread.
// The content-equality dedupe in <MessageThread> still
// suppresses the optimistic copy if a persisted twin lands.
return;
}
@@ -484,10 +485,16 @@ export function useSendCoachMessage(opts: UseSendCoachMessageOptions = {}) {
optsRef.current.onDone?.(resolvedConversationId);
}
// v1.4.25 W5 — drop the optimistic user bubble; the persisted
// twin is on its way via the invalidate-refetch above. Drop on
// error too so the user message isn't doubled when the next
// refetch sees the server-persisted row.
setOptimisticUser(null);
// twin is on its way via the invalidate-refetch above.
// v1.16.4 — but only when a twin IS coming (the turn resolved a
// conversation) or the turn succeeded outright. An errored turn
// without a conversation id persisted nothing; dropping the
// bubble then erased the user's message next to the error bubble.
// The content-equality dedupe in <MessageThread> still suppresses
// the optimistic copy if a persisted twin does land later.
if (resolvedConversationId || !lastError) {
setOptimisticUser(null);
}
},
[queryClient],
);
@@ -151,7 +151,7 @@ export function SparklineDeltaTile({
</div>
<div
className="mt-2 flex items-baseline gap-x-1.5"
className="mt-2 flex flex-wrap items-baseline gap-x-1.5"
data-slot="sparkline-delta-tile-value-row"
>
<span
@@ -160,7 +160,10 @@ export function SparklineDeltaTile({
>
{value !== null ? fmt.number(value, precision) : "—"}
</span>
<span className="text-muted-foreground min-w-0 truncate text-sm tabular-nums">
{/* v1.16.4 — the unit is short, load-bearing metadata ("mmHg",
"kg") and must never ellipsis ("m…"); on a too-narrow tile
the row wraps instead (hence `flex-wrap` above). */}
<span className="text-muted-foreground shrink-0 text-sm whitespace-nowrap tabular-nums">
{unit}
</span>
<span
@@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query";
import { useTranslations } from "@/lib/i18n/context";
import { useAuth } from "@/hooks/use-auth";
import { useMounted } from "@/hooks/use-mounted";
import { useFeatureFlags } from "@/hooks/use-feature-flags";
import { useWorkouts } from "@/hooks/use-workouts";
import { InsightsTabStrip } from "@/components/insights/insights-tab-strip";
@@ -58,8 +59,13 @@ export function InsightsLayoutShell({ children }: { children: ReactNode }) {
// hiccup still renders the advisor — the gate only takes effect when
// the operator has explicitly turned the surface off.
const flags = useFeatureFlags();
// v1.16.4 — `mounted` keeps the hydration render in lockstep with the
// SSR HTML: a late-hydrating boundary can see resolved query state on
// its first render (auth + flags settled), which used to flip the
// regenerate affordance on at hydration time and trip React #418.
const mounted = useMounted();
const advisorEnabled =
isAuthenticated && flags.enabled && flags.briefing;
mounted && isAuthenticated && flags.enabled && flags.briefing;
// v1.12.6 — the Coach segment is excluded from the generic disclaimer
// footer (v1.16.1 dropped the in-chat disclaimer line entirely; the