diff --git a/src/alerts/acknowledgement.tsx b/src/alerts/acknowledgement.tsx index 35482f1..104a37c 100644 --- a/src/alerts/acknowledgement.tsx +++ b/src/alerts/acknowledgement.tsx @@ -132,7 +132,8 @@ const styles = StyleSheet.create({ alignItems: 'center', justifyContent: 'space-between', gap: space.m, - minHeight: 44, + // The Acknowledge button's height, so taking it on or undoing it doesn't move what's under it. + minHeight: 50, paddingHorizontal: space.xxs, }, text: { diff --git a/src/alerts/activity-card.tsx b/src/alerts/activity-card.tsx index 8f08052..ac61c86 100644 --- a/src/alerts/activity-card.tsx +++ b/src/alerts/activity-card.tsx @@ -93,18 +93,17 @@ export function ActivityCard({ organizationId, monitors, onSetUp }: Props) { ))} Today - {firedLevels.length > 0 && ( - - {firedLevels.map((level) => ( - - - - {severityLabels[level]} {levels[level]} - - - ))} - - )} + {/* Always there, a line tall while the days load, so the card doesn't grow under what follows it. */} + + {firedLevels.map((level) => ( + + + + {severityLabels[level]} {levels[level]} + + + ))} + ); } @@ -132,8 +131,11 @@ const styles = StyleSheet.create({ }, date: { fontSize: 12, + lineHeight: 16, + fontVariant: ['tabular-nums'], }, legend: { + minHeight: 16, flexDirection: 'row', flexWrap: 'wrap', columnGap: space.l, diff --git a/src/alerts/history.tsx b/src/alerts/history.tsx index 24a37b2..30ad90c 100644 --- a/src/alerts/history.tsx +++ b/src/alerts/history.tsx @@ -37,10 +37,13 @@ export function AlertHistory({ staleTime: 5 * 60_000, }); - if (!alert.metric || history.isError || projects.isError || (projects.data !== undefined && project === undefined)) { + if (!alert.metric) { return null; } - const points = history.data ?? []; + // The card stays, at the chart's height, when the readings can't load: it said it was loading them, and taking it + // away would pull everything under it up. + const failed = history.isError || projects.isError || (projects.data !== undefined && project === undefined); + const points = failed ? [] : (history.data ?? []); return ( @@ -54,7 +57,8 @@ export function AlertHistory({ points={points} format={(value) => formatValue(alert, value)} onSelect={setSelected} - loading={history.data === undefined} + loading={!failed && history.data === undefined} + empty={failed ? 'Couldn’t load the readings around this alert.' : undefined} /> ); diff --git a/src/alerts/threshold-chart.tsx b/src/alerts/threshold-chart.tsx index 8a4bbc1..27be70d 100644 --- a/src/alerts/threshold-chart.tsx +++ b/src/alerts/threshold-chart.tsx @@ -23,7 +23,7 @@ import { usePalette } from '@/theme/use-palette'; const axisFont = require('@/assets/fonts/Inter-Regular.ttf'); const labelFont = require('@/assets/fonts/Inter-Medium.ttf'); -const height = 170; +export const height = 170; /** Room above the top gridline for its value, and below the plot for the dates. */ const top = 10; const bottom = 24; diff --git a/src/app/(app)/(tabs)/(home)/index.tsx b/src/app/(app)/(tabs)/(home)/index.tsx index 604bfec..213b4be 100644 --- a/src/app/(app)/(tabs)/(home)/index.tsx +++ b/src/app/(app)/(tabs)/(home)/index.tsx @@ -23,6 +23,7 @@ import { OrganizationPicker, ScreenToolbar } from '@/organizations/header'; import { projectsQuery } from '@/projects/api'; import { ProjectCard, ProjectLine, ProjectRow } from '@/projects/project-row'; import { SnoozeCard } from '@/settings/snooze-card'; +import { prefsQuery } from '@/settings/use-prefs'; import { SetupCard } from '@/setup/setup-card'; import { statusLabel, statusQuery } from '@/status/api'; import { fonts, space } from '@/theme/tokens'; @@ -48,6 +49,7 @@ export default function Home() { const status = useQuery(statusQuery); const projects = useQuery(projectsQuery(organizationId)); const updates = useQuery(updatesQuery); + const prefs = useQuery(prefsQuery); const { isUnread } = useUnread(); const session = useSession(); @@ -82,6 +84,9 @@ export default function Home() { const failed = 'Couldn’t load alerts. Pull to retry.'; const note = alerts.isError ? failed : 'Loading alerts…'; const incident = status.data?.incidents[0]; + // The snooze card shows from the alerts and prefs, above everything else, so what's under it waits for both rather + // than drawing and then being pushed down when the card turns up. + const decided = (alerts.data !== undefined || alerts.isError) && (prefs.data !== undefined || prefs.isError); const firingIn = (projectId: string) => firing.filter((alert) => projectOf(alert) === projectId).length; // Firing projects first, then the Projects tab's own order, so Home and the tab agree. @@ -171,12 +176,11 @@ export default function Home() { : `${firing.length} firing`} - {/* Under the count rather than beside it, so it has the card's width; past that it wraps rather than hiding a level. */} - {(pending || detail !== '') && ( - - {pending ? note : detail} - - )} + {/* Under the count rather than beside it, so it has the card's width; past that it wraps rather than hiding a level. + Kept a line tall when there's nothing to add, as "Loading alerts…" was, so the card keeps its height. */} + + {pending ? note : detail === '' ? ' ' : detail} + - - + {decided && } + {decided && } - {layout.wide ? ( + {!decided ? null : layout.wide ? ( // Two columns that each flow on their own, so a long list on one side leaves no gap on the other. diff --git a/src/app/(app)/(tabs)/alerts/[id].tsx b/src/app/(app)/(tabs)/alerts/[id].tsx index 1ce0193..320e1b3 100644 --- a/src/app/(app)/(tabs)/alerts/[id].tsx +++ b/src/app/(app)/(tabs)/alerts/[id].tsx @@ -29,7 +29,7 @@ import { consoleUrl, isTrusted } from '@/appwrite/urls'; import { Button } from '@/components/button'; import { AlertEscalationSection } from '@/escalations/alert-escalation'; import { escalationOf, formatEffect } from '@/escalations/model'; -import { escalationsQuery } from '@/escalations/queries'; +import { escalationsQuery, membersQuery } from '@/escalations/queries'; import { Row, Section } from '@/components/section'; import { StatusPill } from '@/components/status-pill'; import { fonts, radius, space } from '@/theme/tokens'; @@ -86,6 +86,11 @@ export default function AlertDetail() { ...escalationsQuery(organizationId || null), enabled: organizationId !== '' && !!read.data?.escalationId, }); + // Its steps name the people they notified. + const members = useQuery({ + ...membersQuery(organizationId || null), + enabled: organizationId !== '' && !!read.data?.escalationId, + }); if (alert === null) { return ( @@ -113,6 +118,12 @@ export default function AlertDetail() { escalation === null ? null : formatEffect(escalation, escalations.data?.find((entry) => entry.$id === escalation.escalationId)?.steps); + // The monitor decides the probe's check and the note under the threshold, and the escalation and its members the + // steps and what acknowledging does, so the screen under the title waits for them rather than growing as each lands. + const settled = + (monitors.data !== undefined || monitors.isError) && + (!alert.escalationId || + ((escalations.data !== undefined || escalations.isError) && (members.data !== undefined || members.isError))); // The list shows the same alert, so it changes with this screen. A read already on its way would undo the change // when it lands, so it's dropped; the acknowledgement asks for a fresh one once the server has answered. @@ -176,137 +187,148 @@ export default function AlertDetail() { {location} - {probe ? ( - // A probe compares no metric with a threshold: the reading is what its check found, and the latency. - - {firing ? 'Failing' : 'Failed'} - - {resultLabel(alert.result)} - - - {[ - ...(firing ? [code, formatLatency(alert.value)] : ['Passing again']), - // When the probe last ran, which the monitor keeps: the alert itself only knows when it opened. - monitor?.evaluatedAt ? `checked ${formatAgo(monitor.evaluatedAt)}` : '', - ] - .filter(Boolean) - .join(' · ')} - - - ) : ( - - - {firing ? 'Now' : 'Latest'} · {metricLabel(alert)} - - - {formatValue(alert, alert.value)} - - - peak {formatValue(alert, alert.peak)} - - + {settled && ( + <> + {probe ? ( + // A probe compares no metric with a threshold: the reading is what its check found, and the latency. - - - - - )} + style={[styles.reading, { backgroundColor: palette.surface.card, borderColor: palette.surface.edge }]}> + + {firing ? 'Failing' : 'Failed'} + + + {resultLabel(alert.result)} + + + {[ + ...(firing ? [code, formatLatency(alert.value)] : ['Passing again']), + // When the probe last ran, which the monitor keeps: the alert itself only knows when it opened. + monitor?.evaluatedAt ? `checked ${formatAgo(monitor.evaluatedAt)}` : '', + ] + .filter(Boolean) + .join(' · ')} + + + ) : ( + + + {firing ? 'Now' : 'Latest'} · {metricLabel(alert)} + + + {formatValue(alert, alert.value)} + + + peak {formatValue(alert, alert.peak)} + + + + + + + + )} - {probe && monitor !== undefined && } + {probe && monitor !== undefined && } - {/* What fired comes first; then taking it on, and who else hears about it. */} - + {/* What fired comes first; then taking it on, and who else hears about it. */} + - + - {project !== '' && !probe && } + {project !== '' && !probe && } -
- - {!budget && project !== '' && } - - {!firing && alert.acknowledgedAt && ( - - )} - {firing && } - {alert.resolvedAt != null && } - {alert.resolvedAt != null && ( - - )} - -
+
+ + {!budget && project !== '' && } + + {!firing && alert.acknowledgedAt && ( + + )} + {firing && } + {alert.resolvedAt != null && } + {alert.resolvedAt != null && ( + + )} + +
- - {project !== '' && ( -