fix(client): correct recentChecks ordering on the dashboard
recentChecks is oldest-first, not newest-first. The server appends each snapshot with `$push … $slice: -N` (monitor.repository.mongo.ts:218) and returns it unreversed, and every existing consumer reads recentChecks[length - 1] as the latest. I had it backwards, which broke three things: - downSince() walked from index 0 and broke on the first element. For any monitor that was up before it failed — the normal case — the very first check is an "up", so the loop exited immediately and the downtime duration never rendered at all. - The sparkline reversed already-ascending data, drawing every trend line mirrored: climbing latency appeared to be improving. - The status code read index 0, the oldest retained check, so a monitor that served 200s before failing showed a green 200 beside a red dot. Also from review: - Drop `initializing` from the "Currently down" ranking. On a fresh install every new monitor starts there, so the card opened red claiming a fleet-wide outage. It means "not checked yet", not "broken". - Add the maintenance count to Monitor status. The summary reports it and the server counts it; omitting it left the tiles summing to less than totalMonitors with nothing explaining the gap. - Link the status tiles to plain /uptime. The monitors list never reads query params, so ?status= was silently dropped and the link lied. - Render the status code as plain text instead of StatusCodeLabel, whose Tooltip put a focusable element inside the row's link where no keyboard user could reach it. - Stop sending `limit`: findByTeamIdWithStats derives its page size from rowsPerPage alone and never reads it, so it only implied a truncation that was not in effect. - Persist a deliberately emptied dashboard instead of resetting it to the defaults on reload. - Pass isStale on every card. The prop and its dimming were implemented but never wired, so background refetches gave no feedback. Claude-Session: https://claude.ai/code/session_01AbYLvwpEaZFXktHVcqrFRd
This commit is contained in:
1 parent
c58087c787
commit
23b00401ca
9 files changed
+69
-31
No files matched your search
@@ -13,12 +13,14 @@ import { useMonitors } from "../../useDashboardData";
|
||||
|
||||
import type { MonitorStatus, MonitorsSummary } from "@/Types/Monitor";
|
||||
|
||||
// The five counts, in the order they read: healthy first, then what is wrong,
|
||||
// then what is not being checked.
|
||||
// Every state the summary reports, in the order they read: healthy first, then
|
||||
// what is wrong, then what is not being checked. All six are listed so the
|
||||
// tiles always sum to totalMonitors — omitting one leaves an unexplained gap.
|
||||
const COUNTS: { key: string; status: MonitorStatus; field: keyof MonitorsSummary }[] = [
|
||||
{ key: "up", status: "up", field: "upMonitors" },
|
||||
{ key: "down", status: "down", field: "downMonitors" },
|
||||
{ key: "breached", status: "breached", field: "breachedMonitors" },
|
||||
{ key: "maintenance", status: "maintenance", field: "maintenanceMonitors" },
|
||||
{ key: "paused", status: "paused", field: "pausedMonitors" },
|
||||
{ key: "initializing", status: "initializing", field: "initializingMonitors" },
|
||||
];
|
||||
@@ -26,7 +28,7 @@ const COUNTS: { key: string; status: MonitorStatus; field: keyof MonitorsSummary
|
||||
export const MonitorStatusCard = () => {
|
||||
const theme = useTheme();
|
||||
const { t } = useTranslation();
|
||||
const { data, isLoading, error } = useMonitors();
|
||||
const { data, isLoading, isValidating, error } = useMonitors();
|
||||
const summary = data?.summary ?? null;
|
||||
|
||||
return (
|
||||
@@ -35,6 +37,7 @@ export const MonitorStatusCard = () => {
|
||||
to="/uptime"
|
||||
isLoading={isLoading && !summary}
|
||||
error={error}
|
||||
isStale={isValidating && Boolean(data)}
|
||||
>
|
||||
{!summary || summary.totalMonitors === 0 ? (
|
||||
<CardMessage text={t("pages.dashboard.cards.monitorStatus.empty")} />
|
||||
@@ -48,7 +51,10 @@ export const MonitorStatusCard = () => {
|
||||
<Stack
|
||||
key={key}
|
||||
component={RouterLink}
|
||||
to={`/uptime?status=${key}`}
|
||||
// Plain /uptime: the monitors list does not read query
|
||||
// params, so a ?status= filter would be silently dropped and
|
||||
// the link would lie about where it goes.
|
||||
to="/uptime"
|
||||
gap={theme.spacing(LAYOUT.XXS)}
|
||||
flex="1 1 0"
|
||||
minWidth={96}
|
||||
|
||||
Reference in new issue
Block a user