[PULSE-47] Add uptime monitoring dashboard #15

Merged
uz1mani merged 6 commits from staging into main 2026-02-07 22:38:13 +00:00
3 changed files with 1194 additions and 0 deletions
Showing only changes of commit 0887e24546 - Show all commits

View File

@@ -252,7 +252,10 @@ function UptimeStatusBar({
}
return (
<div className="relative">
<div
className="relative"
onMouseLeave={() => setHoveredDay(null)}
>
<div className="flex items-center gap-[2px] w-full">
{dateRange.map((date) => {
const stat = statsMap.get(date)
@@ -704,7 +707,7 @@ export default function UptimePage() {
if (loading) return <LoadingOverlay logoSrc="/pulse_icon_no_margins.png" title="Uptime" />
if (!site) return <div className="p-8 text-neutral-500">Site not found</div>
greptile-apps[bot] commented 2026-02-07 22:07:38 +00:00 (Migrated from github.com)
Review

monitors can be null

UptimeStatusResponse.monitors is typed as MonitorStatus[] | null (lib/api/uptime.ts), but this page still does const monitors = uptimeData?.monitors ?? []. If the API returns monitors: null, this expression evaluates to null (because the optional chain returns null, which ?? does not replace), and the subsequent monitors.length / monitors.map(...) will throw during render. Use an explicit array guard (e.g., Array.isArray(uptimeData?.monitors) ? uptimeData.monitors : []) before reading .length / .map.

Prompt To Fix With AI
This is a comment left during a code review.
Path: app/sites/[id]/uptime/page.tsx
Line: 707:709

Comment:
**`monitors` can be `null`**

`UptimeStatusResponse.monitors` is typed as `MonitorStatus[] | null` (`lib/api/uptime.ts`), but this page still does `const monitors = uptimeData?.monitors ?? []`. If the API returns `monitors: null`, this expression evaluates to `null` (because the optional chain returns `null`, which `??` does not replace), and the subsequent `monitors.length` / `monitors.map(...)` will throw during render. Use an explicit array guard (e.g., `Array.isArray(uptimeData?.monitors) ? uptimeData.monitors : []`) before reading `.length` / `.map`.


How can I resolve this? If you propose a fix, please make it concise.
**`monitors` can be `null`** `UptimeStatusResponse.monitors` is typed as `MonitorStatus[] | null` (`lib/api/uptime.ts`), but this page still does `const monitors = uptimeData?.monitors ?? []`. If the API returns `monitors: null`, this expression evaluates to `null` (because the optional chain returns `null`, which `??` does not replace), and the subsequent `monitors.length` / `monitors.map(...)` will throw during render. Use an explicit array guard (e.g., `Array.isArray(uptimeData?.monitors) ? uptimeData.monitors : []`) before reading `.length` / `.map`. <details><summary>Prompt To Fix With AI</summary> `````markdown This is a comment left during a code review. Path: app/sites/[id]/uptime/page.tsx Line: 707:709 Comment: **`monitors` can be `null`** `UptimeStatusResponse.monitors` is typed as `MonitorStatus[] | null` (`lib/api/uptime.ts`), but this page still does `const monitors = uptimeData?.monitors ?? []`. If the API returns `monitors: null`, this expression evaluates to `null` (because the optional chain returns `null`, which `??` does not replace), and the subsequent `monitors.length` / `monitors.map(...)` will throw during render. Use an explicit array guard (e.g., `Array.isArray(uptimeData?.monitors) ? uptimeData.monitors : []`) before reading `.length` / `.map`. How can I resolve this? If you propose a fix, please make it concise. ````` </details>
uz1mani commented 2026-02-07 22:09:52 +00:00 (Migrated from github.com)
Review

alreayd fixed

alreayd fixed
const monitors = uptimeData?.monitors ?? []
const monitors = Array.isArray(uptimeData?.monitors) ? uptimeData.monitors : []
const overallUptime = uptimeData?.overall_uptime ?? 100
const overallStatus = uptimeData?.status ?? 'operational'