diff --git a/apps/web/src/components/reui-kit/uptime-chart.test.ts b/apps/web/src/components/reui-kit/uptime-chart.test.ts index b7e9155..f204ac5 100644 --- a/apps/web/src/components/reui-kit/uptime-chart.test.ts +++ b/apps/web/src/components/reui-kit/uptime-chart.test.ts @@ -45,6 +45,28 @@ describe('toAlignedSeries', () => { expect(keys).toEqual(['local', 'cloudflare', 'globalping']) }) + it('keeps live latency when another IP in the same bucket is down', () => { + const { points } = toAlignedSeries([ + probe({ + id: 1, + latency_ms: 18, + checked_at: '2026-01-01T00:00:10.000Z', + }), + probe({ + id: 2, + status: 'down', + ok: false, + latency_ms: null, + checked_at: '2026-01-01T00:00:12.000Z', + }), + ]) + + expect(points).toHaveLength(1) + expect(points[0]?.local).toBe(18) + expect(points[0]?.localOk).toBe(true) + expect(points[0]?.ok).toBe(true) + }) + it('does not plot down probes as latency 0', () => { const { points } = toAlignedSeries([ probe({ diff --git a/apps/web/src/components/reui-kit/uptime-chart.tsx b/apps/web/src/components/reui-kit/uptime-chart.tsx index 293b4cd..126a76e 100644 --- a/apps/web/src/components/reui-kit/uptime-chart.tsx +++ b/apps/web/src/components/reui-kit/uptime-chart.tsx @@ -124,8 +124,13 @@ export function toAlignedSeries(items: UptimeProbe[]): { } const ok = probeOk(item) - row[`${key}Ok`] = ok - row[key] = ok ? item.latency_ms : null + const prevOk = row[`${key}Ok`] + row[`${key}Ok`] = prevOk === true || ok + if (ok && item.latency_ms != null) { + row[key] = item.latency_ms + } else if (row[key] === undefined) { + row[key] = null + } } const points = [...buckets.entries()]