From 7cceb9d3d9380f4a60e4e83d46e8111da16b2993 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 4 Dec 2026 09:19:16 +0000 Subject: [PATCH 1/2] fix(layout): stop screens jumping as data arrives and after taps Content that depends on late data now waits for it instead of drawing early and being pushed, and changing states keep their size (reserved lines, fixed slots, tabular numbers), so nothing moves under the reader or their finger. --- src/alerts/acknowledgement.tsx | 3 +- src/alerts/activity-card.tsx | 26 +-- src/alerts/history.tsx | 10 +- src/alerts/threshold-chart.tsx | 2 +- src/app/(app)/(tabs)/(home)/index.tsx | 22 +- src/app/(app)/(tabs)/alerts/[id].tsx | 258 +++++++++++++----------- src/app/(app)/(tabs)/monitors/[id].tsx | 213 ++++++++++--------- src/app/(app)/(tabs)/projects/[id].tsx | 77 ++++--- src/app/(app)/(tabs)/projects/index.tsx | 8 +- src/app/(app)/escalations/[id].tsx | 10 +- src/app/(app)/escalations/assign.tsx | 24 ++- src/app/(app)/escalations/index.tsx | 12 +- src/app/(app)/organizations.tsx | 6 +- src/app/(app)/settings/index.tsx | 217 ++++++++++---------- src/app/(app)/snooze.tsx | 51 +++-- src/app/(app)/threshold.tsx | 28 +-- src/app/mfa.tsx | 50 ++--- src/components/filter-bar.tsx | 32 ++- src/components/segments.tsx | 15 ++ src/escalations/alert-escalation.tsx | 3 +- src/escalations/step-sheet.tsx | 3 +- src/escalations/use-escalations.ts | 12 +- src/projects/project-row.tsx | 3 +- src/setup/watch.tsx | 12 +- 24 files changed, 612 insertions(+), 485 deletions(-) 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..26edef8 100644 --- a/src/app/(app)/(tabs)/alerts/[id].tsx +++ b/src/app/(app)/(tabs)/alerts/[id].tsx @@ -113,6 +113,11 @@ 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 the steps and what + // acknowledging does, so the screen under the title waits for both rather than growing as each one lands. + const settled = + (monitors.data !== undefined || monitors.isError) && + (!alert.escalationId || escalations.data !== undefined || escalations.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 +181,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 !== '' && ( -