From 221d8b2384fbbe52cd1f96ea2e18603e6e3eee52 Mon Sep 17 00:00:00 2001 From: "molecule-ai[bot]" <276602405+molecule-ai[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 03:22:17 +0000 Subject: [PATCH] fix(canvas): guard undefined lastErrorRate and period dates in metrics (PR #1250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DetailsTab: use `(data.lastErrorRate ?? 0)` instead of bare multiply to prevent NaN% when the field is absent on pre-provisioning workspaces. - WorkspaceUsage: make formatPeriod accept optional start/end strings; return "—" for undefined so the usage period shows blank rather than "Invalid Date" for provisioning/partial workspaces. Refs: #1139 Co-authored-by: Molecule AI Fullstack (floater) --- canvas/src/components/WorkspaceUsage.tsx | 3 ++- canvas/src/components/tabs/DetailsTab.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/canvas/src/components/WorkspaceUsage.tsx b/canvas/src/components/WorkspaceUsage.tsx index 5e51dbc0..9fb1b101 100644 --- a/canvas/src/components/WorkspaceUsage.tsx +++ b/canvas/src/components/WorkspaceUsage.tsx @@ -98,7 +98,8 @@ export function WorkspaceUsage({ workspaceId }: WorkspaceUsageProps) { ); } -function formatPeriod(start: string, end: string): string { +function formatPeriod(start: string | undefined, end: string | undefined): string { + if (!start || !end) return "—"; const fmt = (s: string) => new Date(s).toLocaleDateString(undefined, { month: "short", diff --git a/canvas/src/components/tabs/DetailsTab.tsx b/canvas/src/components/tabs/DetailsTab.tsx index 9766fc18..5d877cf9 100644 --- a/canvas/src/components/tabs/DetailsTab.tsx +++ b/canvas/src/components/tabs/DetailsTab.tsx @@ -189,7 +189,7 @@ export function DetailsTab({ workspaceId, data }: Props) { {data.status === "degraded" && ( - + )} {isRestartable && (