Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: max status banner updates (#1775)
Maximilian Kaske9dccd46ede5f
diff --git a/apps/status-page/src/app/(public)/client.tsx b/apps/status-page/src/app/(public)/client.tsxindex eb305fee7..c31d2d913 100644--- a/apps/status-page/src/app/(public)/client.tsx+++ b/apps/status-page/src/app/(public)/client.tsx@@ -352,7 +352,10 @@ function ThemePlaygroundEvents({))}</StatusEventAffected>) : null}- <StatusEventTimelineReport updates={report.statusReportUpdates} />+ <StatusEventTimelineReport+ updates={report.statusReportUpdates}+ reportId={report.id}+ /></StatusEventContent></StatusEvent></Status>diff --git a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsxindex 04a7fb97f..89900e219 100644--- a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx@@ -88,6 +88,7 @@ export default function Page() {) : null}<StatusEventTimelineReportupdates={report.statusReportUpdates}+ reportId={report.id}/></StatusEventContent></Link>diff --git a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(view)/report/[id]/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(view)/report/[id]/page.tsxindex 8557d45cc..bdd8db626 100644--- a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(view)/report/[id]/page.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(view)/report/[id]/page.tsx@@ -68,7 +68,10 @@ export default function ReportPage() {))}</StatusEventAffected>) : null}- <StatusEventTimelineReport updates={report.statusReportUpdates} />+ <StatusEventTimelineReport+ updates={report.statusReportUpdates}+ reportId={report.id}+ /></StatusEventContent></StatusEvent></div>diff --git a/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsxindex 601a52e1d..b617d2e88 100644--- a/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx@@ -144,8 +144,10 @@ export default function Page() {<StatusBannerContainer status={e.status}><StatusBannerContent><StatusEventTimelineReport+ reportId={report.id}updates={report.statusReportUpdates}withDot={false}+ maxUpdates={3}/></StatusBannerContent></StatusBannerContainer>diff --git a/apps/status-page/src/components/status-page/status-events.tsx b/apps/status-page/src/components/status-page/status-events.tsxindex cbc7a2163..03cd2f8a2 100644--- a/apps/status-page/src/components/status-page/status-events.tsx+++ b/apps/status-page/src/components/status-page/status-events.tsx@@ -8,10 +8,12 @@ import {TooltipProvider,TooltipTrigger,} from "@/components/ui/tooltip";+import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";import { formatDate, formatDateRange, formatDateTime } from "@/lib/formatter";import { cn } from "@/lib/utils";import { formatDistanceStrict } from "date-fns";-import { Check } from "lucide-react";+import { Check, ChevronRight } from "lucide-react";+import Link from "next/link";import { status } from "./messages";export function StatusEventGroup({@@ -171,52 +173,70 @@ export function StatusEventTimelineReport({className,updates,withDot = true,+ maxUpdates,+ reportId,...props}: React.ComponentProps<"div"> & {// TODO: remove unused props+ reportId: number;updates: {date: Date;message: string;status: "investigating" | "identified" | "monitoring" | "resolved";}[];withDot?: boolean;+ maxUpdates?: number;}) {+ const prefix = usePathnamePrefix();+ const sortedUpdates = [...updates].sort(+ (a, b) => b.date.getTime() - a.date.getTime(),+ );+ const hasMoreUpdates = maxUpdates && sortedUpdates.length > maxUpdates;+ const displayedUpdates = maxUpdates+ ? sortedUpdates.slice(0, maxUpdates)+ : sortedUpdates;+return (<div className={cn("text-muted-foreground text-sm", className)} {...props}>{/* NOTE: make sure they are sorted by date */}- {updates- .sort((a, b) => b.date.getTime() - a.date.getTime())- .map((update, index) => {- const updateDate = new Date(update.date);- let durationText: string | undefined;+ {displayedUpdates.map((update, index) => {+ const updateDate = new Date(update.date);+ let durationText: string | undefined;- if (index === 0) {- const startedAt = new Date(updates[updates.length - 1].date);- const duration = formatDistanceStrict(startedAt, updateDate);+ if (index === 0) {+ const startedAt = new Date(+ sortedUpdates[sortedUpdates.length - 1].date,+ );+ const duration = formatDistanceStrict(startedAt, updateDate);- if (duration !== "0 seconds" && update.status === "resolved") {- durationText = `(in ${duration})`;- }- } else {- const lastUpdateDate = new Date(updates[index - 1].date);- const timeFromLast = formatDistanceStrict(- updateDate,- lastUpdateDate,- );- durationText = `(${timeFromLast} earlier)`;+ if (duration !== "0 seconds" && update.status === "resolved") {+ durationText = `(in ${duration})`;}+ } else {+ const lastUpdateDate = new Date(displayedUpdates[index - 1].date);+ const timeFromLast = formatDistanceStrict(updateDate, lastUpdateDate);+ durationText = `(${timeFromLast} earlier)`;+ }- return (- <StatusEventTimelineReportUpdate- key={index}- report={update}- duration={durationText}- withSeparator={index !== updates.length - 1}- withDot={withDot}- isLast={index === updates.length - 1}- />- );- })}+ return (+ <StatusEventTimelineReportUpdate+ key={index}+ report={update}+ duration={durationText}+ withSeparator={+ index !== displayedUpdates.length - 1 && !hasMoreUpdates+ }+ withDot={withDot}+ isLast={index === displayedUpdates.length - 1 && !hasMoreUpdates}+ />+ );+ })}+ {hasMoreUpdates && (+ <StatusEventTimelineReadMore+ href={`${prefix ? `/${prefix}` : ""}/events/report/${reportId}`}+ withDot={withDot}+ />+ )}</div>);}@@ -278,6 +298,37 @@ function StatusEventTimelineReportUpdate({);}+function StatusEventTimelineReadMore({+ href,+ withDot = true,+}: {+ href: string;+ withDot?: boolean;+}) {+ return (+ <div className="group">+ <div className="flex flex-row items-center justify-between gap-2">+ <div className="flex flex-row gap-4">+ {withDot ? (+ <div className="flex flex-col">+ <div className="flex h-5 flex-col items-center justify-center">+ <div className="size-2.5 shrink-0 rounded-full bg-muted" />+ </div>+ </div>+ ) : null}+ <Link+ href={href}+ className="flex items-center gap-1 font-medium text-muted-foreground text-sm hover:text-foreground hover:underline"+ >+ View full report+ <ChevronRight className="size-4" />+ </Link>+ </div>+ </div>+ </div>+ );+}+export function StatusEventTimelineMaintenance({maintenance,withDot = true,diff --git a/apps/status-page/src/components/status-page/status-feed.tsx b/apps/status-page/src/components/status-page/status-feed.tsxindex 0955b3b24..77058abf8 100644--- a/apps/status-page/src/components/status-page/status-feed.tsx+++ b/apps/status-page/src/components/status-page/status-feed.tsx@@ -126,7 +126,10 @@ export function StatusFeed({))}</StatusEventAffected>)}- <StatusEventTimelineReport updates={report.updates} />+ <StatusEventTimelineReport+ updates={report.updates}+ reportId={report.id}+ /></StatusEventContent></Link></StatusEvent>diff --git a/apps/workflows/src/incident/index.ts b/apps/workflows/src/incident/index.tsindex c31d6d378..251c21e95 100644--- a/apps/workflows/src/incident/index.ts+++ b/apps/workflows/src/incident/index.ts@@ -1,5 +1,5 @@import { schema } from "@openstatus/db";-import { and, eq, inArray, isNotNull, isNull, ne } from "drizzle-orm";+import { and, eq, inArray, isNull, ne } from "drizzle-orm";import { Hono } from "hono";import { env } from "../env";import { db } from "../lib/db";@@ -19,11 +19,7 @@ incidentRoute.get("/cleanup", async (c) => {const unresolvedIncidentMonitorIds = db.select({ monitorId: schema.incidentTable.monitorId }).from(schema.incidentTable)- .where(- and(- isNull(schema.incidentTable.resolvedAt),- ),- );+ .where(and(isNull(schema.incidentTable.resolvedAt)));const activeMonitorsWithUnresolvedIncidents = await db.select({ id: schema.monitor.id })