fix(canvas): guard undefined lastErrorRate and period dates in metrics (PR #1250)
- 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) <fullstack-floater@agents.moleculesai.app>
This commit is contained in:
parent
732f65e8e1
commit
221d8b2384
@ -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",
|
||||
|
||||
@ -189,7 +189,7 @@ export function DetailsTab({ workspaceId, data }: Props) {
|
||||
<Row label="Parent" value={data.parentId || "root"} mono />
|
||||
<Row label="Active Tasks" value={String(data.activeTasks)} />
|
||||
{data.status === "degraded" && (
|
||||
<Row label="Error Rate" value={`${(data.lastErrorRate * 100).toFixed(0)}%`} />
|
||||
<Row label="Error Rate" value={`${((data.lastErrorRate ?? 0) * 100).toFixed(0)}%`} />
|
||||
)}
|
||||
{isRestartable && (
|
||||
<div className="pt-2">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user