From 97b8f5e87fb296f978cffd070931def104abdc58 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Mon, 21 Sep 2026 19:38:19 +0200 Subject: [PATCH] fix: byte formatting + exactOptionalPropertyTypes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fmtBytes used 1<<40 — a 32-bit shift in JS evaluates to 1<<8=256, so every value >=256 bytes rendered as TB. Also drop undefined-valued props that exactOptionalPropertyTypes rejects in incident/status-page bodies. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .gitignore | 1 + apps/frontend/src/pages/IncidentsPage.tsx | 9 +++++++-- apps/frontend/src/pages/StatusPagesPage.tsx | 2 +- apps/frontend/src/pages/SystemsPage.tsx | 10 +++++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6ce78f1..aaa04fb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ coverage/ # local tooling artifacts .playwright-mcp/ +.playwright-cli/ diff --git a/apps/frontend/src/pages/IncidentsPage.tsx b/apps/frontend/src/pages/IncidentsPage.tsx index 3c9e788..7633214 100644 --- a/apps/frontend/src/pages/IncidentsPage.tsx +++ b/apps/frontend/src/pages/IncidentsPage.tsx @@ -54,7 +54,9 @@ export function IncidentsPage() { // The select only offers the three severities, but its value is a // plain string — narrow at the boundary instead of asserting. const severity = sev === "critical" || sev === "minor" ? sev : "major"; - await api.POST("/api/incidents", { body: { title: title.trim(), severity, message: msg || undefined } }); + await api.POST("/api/incidents", { + body: { title: title.trim(), severity, ...(msg.trim() ? { message: msg.trim() } : {}) }, + }); setBusy(false); setDlgOpen(false); setTitle(""); setMsg(""); @@ -63,7 +65,10 @@ export function IncidentsPage() { async function transition(id: string | undefined, to: Status, message?: string) { if (!id) return; - await api.PATCH("/api/incidents/{id}", { params: { path: { id } }, body: { status: to, message } }); + await api.PATCH("/api/incidents/{id}", { + params: { path: { id } }, + body: { status: to, ...(message?.trim() ? { message } : {}) }, + }); await load(); } diff --git a/apps/frontend/src/pages/StatusPagesPage.tsx b/apps/frontend/src/pages/StatusPagesPage.tsx index 2afea4b..db09178 100644 --- a/apps/frontend/src/pages/StatusPagesPage.tsx +++ b/apps/frontend/src/pages/StatusPagesPage.tsx @@ -57,7 +57,7 @@ export function StatusPagesPage() { const { error } = await api.POST("/api/status-pages", { body: { title: pTitle.trim(), - slug: pSlug.trim() || undefined, + ...(pSlug.trim() ? { slug: pSlug.trim() } : {}), description: pDesc.trim(), monitorIds: pMonitors, }, diff --git a/apps/frontend/src/pages/SystemsPage.tsx b/apps/frontend/src/pages/SystemsPage.tsx index 0362dc5..4f1af6e 100644 --- a/apps/frontend/src/pages/SystemsPage.tsx +++ b/apps/frontend/src/pages/SystemsPage.tsx @@ -11,10 +11,14 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { cn } from "@/lib/utils"; +const TB = 2 ** 40; +const GB = 2 ** 30; +const MB = 2 ** 20; + export function fmtBytes(b: number) { - if (b >= 1 << 40) return `${(b / (1 << 40)).toFixed(1)} TB`; - if (b >= 1 << 30) return `${(b / (1 << 30)).toFixed(1)} GB`; - return `${(b / (1 << 20)).toFixed(0)} MB`; + if (b >= TB) return `${(b / TB).toFixed(1)} TB`; + if (b >= GB) return `${(b / GB).toFixed(1)} GB`; + return `${(b / MB).toFixed(0)} MB`; } export function fmtUptime(s: number) {