Skip to content

Commit 6d34620

Browse files
authored
fix(ui): cut noise from the overview alerts and the plan page (#1480)
* fix(ui): cut noise from the overview alerts and the plan page Group alerts that share a cause, wrap their messages, word short heartbeat gaps as pauses and state the out-of-date counts plainly. On the plan page, drop the narration sentence, word the --changed rule and what a preview can't know, collapse unchanged nodes, show the forward-only warning under its model, and limit the alert banner to problems that affect the plan. * fix(ui): plain replay warning, clearer stale counts, quieter demo overview WIP: review fixes on the noise pass. * fix(ui): say held-back jobs wait for a stopped scheduler WIP: held-back rows drop the countdown while no server runs the scheduler. * fix(ui): drop explanatory plan text, centre alert icons, one out-of-date build button (WIP) The plan page shows facts and status only: the forward-only replay warning, the --changed rule sentence and the synced-preview box are gone. Alert icons sit centred in their square again with room before the title. The out-of-date alert offers one build: what changed when anything changed, else a rebuild of the nodes behind. Acknowledged unresponsive runs no longer hide queued runs, consequence rows are keyed by position, and a plan warning attaches to one entry only.
1 parent ce85fd2 commit 6d34620

11 files changed

Lines changed: 392 additions & 235 deletions

File tree

‎ui/src/lib/api/mock/build-fixtures.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ export const DEPLOYS: DeploySpec[] = [
365365
gitAuthor: ALEX.displayName,
366366
minutesAgo: 6,
367367
publishedBy: CI_ACCOUNT,
368-
nodes: [node('fact_orders', 'changed', 'SQL changed: refunded payments now net out of order revenue', { columns: [{ name: 'net_revenue', op: 'changed', detail: 'expression changed' }] })],
368+
nodes: [
369+
node('fact_orders', 'changed', 'SQL changed: refunded payments now net out of order revenue', { columns: [{ name: 'net_revenue', op: 'changed', detail: 'expression changed' }] }),
370+
node('customer_status', 'changed', 'SQL changed: lapsed customers now need 120 days without an order', { columns: [{ name: 'status', op: 'changed', detail: 'expression changed' }] })
371+
],
369372
orchestration: [],
370373
roles: [],
371374
environment: null
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { describe, expect, it } from 'vitest';
2+
import type { AttentionItem, AttentionRun, PlatformEvent } from '$lib/api';
3+
import { attentionViews } from './attention';
4+
import { CHANGED_PLAN_HREF, planHref } from '$lib/run/command';
5+
6+
const now = Date.parse('2026-01-01T12:00:00Z');
7+
const ago = (minutes: number) => new Date(now - minutes * 60_000).toISOString();
8+
const event = (id: string, kind: PlatformEvent['kind'], locationId: string | null, over: Partial<PlatformEvent> = {}): AttentionItem => ({
9+
kind: 'platform_event',
10+
event: { id, kind, severity: 'warning', occurredAt: ago(5), active: true, locationId, subject: null, message: `${kind} message`, ...over }
11+
});
12+
const run = (id: string, jobKey: string | null): AttentionRun => ({ id, jobKey, kind: 'job', status: 'unresponsive', statusReason: null, nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, running: 1, pending: 0 }, startedAt: ago(30), endedAt: null });
13+
const unresponsive = (id: string, jobKey: string | null, heardMinutesAgo: number): AttentionItem => ({ kind: 'run_unresponsive', run: run(id, jobKey), lastHeartbeatAt: ago(heardMinutesAgo), acknowledged: null });
14+
const queued = (runId: string, jobKey: string | null, waits: Extract<AttentionItem, { kind: 'queue_blocked' }>['waits']): AttentionItem => ({ kind: 'queue_blocked', runId, jobKey, queuedAt: ago(20), waits });
15+
16+
describe('overview alerts', () => {
17+
it("lists an overdue schedule under its own location's outage, else under the stopped scheduler", () => {
18+
const views = attentionViews(
19+
[
20+
event('broken', 'location_broken', 'shop'),
21+
event('late-shop', 'tick_overdue', 'shop', { message: 'hourly is late' }),
22+
event('late-other', 'tick_overdue', 'marketing', { message: 'daily is late' }),
23+
event('stopped', 'scheduler_no_leader', null, { severity: 'critical' })
24+
],
25+
now
26+
);
27+
expect(views.map(({ view }) => [view.key, view.consequences.map((c) => c.text)])).toEqual([
28+
['event:stopped', ['daily is late']],
29+
['event:broken', ['hourly is late']]
30+
]);
31+
});
32+
33+
it('keeps an overdue schedule as its own alert when nothing explains it', () => {
34+
const views = attentionViews([event('late', 'tick_overdue', 'shop'), event('broken', 'location_broken', 'marketing')], now);
35+
expect(views.map(({ view }) => view.key)).toEqual(['event:late', 'event:broken']);
36+
});
37+
38+
it('lists a queued run under the unresponsive run of its job or the one it waits for, and the cause takes the more urgent tone', () => {
39+
const views = attentionViews(
40+
[
41+
unresponsive('r1', 'nightly', 1),
42+
queued('q1', 'nightly', []),
43+
unresponsive('r2', null, 1),
44+
queued('q2', 'exports', [{ kind: 'write_claim', runId: 'r2', nodeKey: 'model:orders', otherNodes: 0 }]),
45+
queued('q3', 'other', [])
46+
],
47+
now
48+
);
49+
expect(views.map(({ view }) => [view.key, view.tone, view.consequences.length])).toEqual([
50+
['unresponsive:r1', 'warning', 1],
51+
['unresponsive:r2', 'warning', 1],
52+
['queue:q3', 'warning', 0]
53+
]);
54+
});
55+
56+
it('keeps a queued run as its own alert when the unresponsive run that holds it up is acknowledged', () => {
57+
const handled: AttentionItem = { ...unresponsive('r1', 'nightly', 1), acknowledged: { by: 'sam', at: ago(1) } } as AttentionItem;
58+
const views = attentionViews([handled, queued('q1', 'nightly', [])], now);
59+
expect(views.map(({ view }) => [view.key, view.consequences.length])).toEqual([
60+
['queue:q1', 0],
61+
['unresponsive:r1', 0]
62+
]);
63+
});
64+
65+
it('words a short heartbeat gap as a pause and a long one as an outage', () => {
66+
const [outage, pause] = attentionViews([unresponsive('short', 'a', 1), unresponsive('long', 'b', 6)], now).sort((x, y) => x.view.key.localeCompare(y.view.key));
67+
expect([outage.view.title, outage.view.tone]).toEqual(['b is unresponsive', 'warning']);
68+
expect([pause.view.title, pause.view.tone]).toEqual(['a missed a heartbeat', 'info']);
69+
});
70+
71+
it('offers one build: what changed when anything changed, else a rebuild of the nodes behind', () => {
72+
const build = (changed: string[], behind: string[]) => attentionViews([{ kind: 'stale_models', changed, behind }], now)[0].view.build;
73+
expect(build(['model:a'], ['model:a', 'model:b'])).toEqual({ label: 'Build what changed', href: CHANGED_PLAN_HREF });
74+
// `--changed` would build nothing when nodes are only behind, so the rebuild names them.
75+
expect(build([], ['model:b', 'model:c'])).toEqual({ label: 'Rebuild 2', href: planHref(['model:b', 'model:c']) });
76+
});
77+
78+
it('states how many nodes are out of date, counting a node both changed and behind once', () => {
79+
const detail = (changed: string[], behind: string[]) => attentionViews([{ kind: 'stale_models', changed, behind }], now)[0].view;
80+
expect(detail(['model:a', 'model:b'], ['model:b']).title).toBe('2 nodes out of date');
81+
expect(detail(['model:a', 'model:b'], ['model:b']).detail).toBe('2 changed since their last build, 1 of them also behind an upstream rebuild: a, b');
82+
expect(detail(['model:a', 'model:b'], ['model:b', 'model:c']).detail).toBe('2 changed since their last build, 1 of them also behind an upstream rebuild, and 1 more behind an upstream rebuild: a, b, c');
83+
expect(detail(['model:a'], ['model:c']).detail).toBe('1 changed since its last build and 1 behind an upstream rebuild: a, c');
84+
expect(detail(['model:a'], ['model:a']).detail).toBe('1 changed since its last build, also behind an upstream rebuild: a');
85+
expect(detail([], ['model:c', 'model:d']).detail).toBe('2 behind an upstream rebuild: c, d');
86+
});
87+
});

‎ui/src/lib/build-area/attention.ts‎

Lines changed: 105 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
// Presentation of the overview's attention items. Pure; no side effects.
22

3-
import type { AttentionItem } from '$lib/api';
3+
import type { AttentionItem, QueueWait } from '$lib/api';
44
import { describeWait, outcomeCounts } from '$lib/operate/labels';
55
import { eventKindLabel, problemHref } from '$lib/platform/labels';
66
import { formatAgo } from '$lib/format/time';
77
import { runStatusLabel } from '$lib/status';
88
import { shortName } from '$lib/build-area/labels';
9+
import { CHANGED_PLAN_HREF, planHref } from '$lib/run/command';
910

1011
export type AttentionTone = 'error' | 'warning' | 'stale' | 'info';
1112

13+
/** Something an alert's cause also brought about, listed under it instead of as an alert of its own. */
14+
export type Consequence = { text: string; href: string };
15+
1216
export type AttentionView = {
1317
key: string;
1418
tone: AttentionTone;
1519
title: string;
1620
detail: string;
21+
/** When it started, as a time ago; empty when the alert has no start of its own. */
1722
since: string;
1823
href: string;
1924
action: string;
25+
consequences: Consequence[];
26+
/** The one build an out-of-date alert offers: `sqb build --changed` when anything changed, else a rebuild of the nodes behind. */
27+
build?: { label: string; href: string };
2028
};
2129

30+
/** A heartbeat gap shorter than this reads as a pause, not an outage: the run carries on when its worker reports again. */
31+
export const UNRESPONSIVE_OUTAGE_MS = 5 * 60_000;
32+
2233
const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
2334
const minutes = (seconds: number | null) => (seconds === null ? '—' : seconds % 3600 === 0 ? `${seconds / 3600}h` : `${Math.round(seconds / 60)}m`);
35+
const waitText = (waits: QueueWait[]) => waits.map((w) => describeWait(w).map((p) => p.text).join('')).join(' · ');
2436

2537
export function attentionView(item: AttentionItem, now: number): AttentionView {
2638
switch (item.kind) {
@@ -33,43 +45,62 @@ export function attentionView(item: AttentionItem, now: number): AttentionView {
3345
detail: outcomeCounts(item.run.nodeCounts) || item.run.statusReason || item.run.id,
3446
since: formatAgo(item.run.endedAt, now),
3547
href: `/runs/${item.run.id}`,
36-
action: 'View run'
48+
action: 'View run',
49+
consequences: []
3750
};
38-
case 'run_unresponsive':
51+
case 'run_unresponsive': {
52+
const heard = item.lastHeartbeatAt ?? item.run.startedAt;
53+
const gap = heard ? now - Date.parse(heard) : Infinity;
54+
const name = item.run.jobKey ?? item.run.id;
55+
const outage = gap >= UNRESPONSIVE_OUTAGE_MS;
3956
return {
4057
key: `unresponsive:${item.run.id}`,
41-
tone: 'warning',
42-
title: `${item.run.jobKey ?? item.run.id} is unresponsive`,
43-
detail: item.lastHeartbeatAt ? `Not heard from since ${formatAgo(item.lastHeartbeatAt, now)}` : (item.run.statusReason ?? 'Not heard from yet'),
44-
since: formatAgo(item.run.startedAt, now),
58+
tone: outage ? 'warning' : 'info',
59+
title: outage ? `${name} is unresponsive` : `${name} missed a heartbeat`,
60+
detail: item.lastHeartbeatAt
61+
? `Its worker last reported ${formatAgo(item.lastHeartbeatAt, now)}.`
62+
: (item.run.statusReason ?? 'Its worker hasn’t reported since the run started.'),
63+
since: formatAgo(item.lastHeartbeatAt ?? item.run.startedAt, now),
4564
href: `/runs/${item.run.id}`,
46-
action: 'View run'
65+
action: 'View run',
66+
consequences: []
4767
};
68+
}
4869
case 'stale_models': {
49-
const total = new Set([...item.changed, ...item.behind]).size;
50-
const parts = [item.changed.length && `${item.changed.length} changed`, item.behind.length && `${item.behind.length} behind`].filter(Boolean);
70+
const changed = new Set(item.changed);
71+
const both = item.behind.filter((key) => changed.has(key)).length;
72+
const all = [...new Set([...item.changed, ...item.behind])];
73+
const only = item.behind.length - both;
74+
const alsoBehind = both ? `, ${item.changed.length === 1 ? 'also' : `${both} of them also`} behind an upstream rebuild` : '';
75+
const onlyBehind = only ? `${both ? `, and ${only} more` : ` and ${only}`} behind an upstream rebuild` : '';
76+
const counts = item.changed.length
77+
? `${item.changed.length} changed since ${item.changed.length === 1 ? 'its' : 'their'} last build${alsoBehind}${onlyBehind}`
78+
: `${only} behind an upstream rebuild`;
5179
return {
5280
key: 'stale',
5381
tone: 'stale',
54-
title: `${plural(total, 'node')} ${total === 1 ? 'is' : 'are'} stale`,
55-
detail: `${parts.join(' · ')} · ${[...new Set([...item.changed, ...item.behind])].slice(0, 4).map(shortName).join(', ')}`,
56-
since: 'since the last build',
82+
title: `${plural(all.length, 'node')} out of date`,
83+
detail: `${counts}: ${all.slice(0, 4).map(shortName).join(', ')}${all.length > 4 ? ` and ${all.length - 4} more` : ''}`,
84+
since: '',
5785
href: '/catalog?stale=1',
58-
action: 'View in catalog'
86+
action: 'View in catalog',
87+
consequences: [],
88+
build: item.changed.length ? { label: 'Build what changed', href: CHANGED_PLAN_HREF } : { label: `Rebuild ${all.length}`, href: planHref(all) }
5989
};
6090
}
61-
case 'stale_sources': {
62-
const first = item.sources[0];
91+
case 'stale_sources':
6392
return {
6493
key: 'sources',
6594
tone: item.sources.some((s) => s.status === 'error') ? 'error' : 'warning',
6695
title: `${plural(item.sources.length, 'source')} past the freshness threshold`,
67-
detail: item.sources.map((s) => `${s.key} loaded ${formatAgo(s.loadedAt, now)}`).join(' · '),
68-
since: `${first.status} after ${minutes(first.status === 'error' ? first.errorAfterSeconds : first.warnAfterSeconds)}`,
96+
detail: item.sources
97+
.map((s) => `${s.key} loaded ${formatAgo(s.loadedAt, now)} (${s.status} after ${minutes(s.status === 'error' ? s.errorAfterSeconds : s.warnAfterSeconds)})`)
98+
.join(' · '),
99+
since: '',
69100
href: '/catalog?kind=source',
70-
action: 'View sources'
101+
action: 'View sources',
102+
consequences: []
71103
};
72-
}
73104
case 'platform_event':
74105
return {
75106
key: `event:${item.event.id}`,
@@ -78,17 +109,19 @@ export function attentionView(item: AttentionItem, now: number): AttentionView {
78109
detail: item.event.message,
79110
since: formatAgo(item.event.occurredAt, now),
80111
href: problemHref(item.event),
81-
action: item.event.locationId ? 'View location' : 'View server status'
112+
action: item.event.locationId ? 'View location' : 'View server status',
113+
consequences: []
82114
};
83115
case 'queue_blocked':
84116
return {
85117
key: `queue:${item.runId}`,
86118
tone: 'warning',
87119
title: `${item.jobKey ?? item.runId} is waiting in the queue`,
88-
detail: item.waits.map((w) => describeWait(w).map((p) => p.text).join('')).join(' · '),
89-
since: `queued ${formatAgo(item.queuedAt, now)}`,
120+
detail: waitText(item.waits),
121+
since: formatAgo(item.queuedAt, now),
90122
href: '/runs?view=queue',
91-
action: 'View queue'
123+
action: 'View queue',
124+
consequences: []
92125
};
93126
case 'calendar_low':
94127
return {
@@ -98,11 +131,58 @@ export function attentionView(item: AttentionItem, now: number): AttentionView {
98131
detail: item.detail,
99132
since: '',
100133
href: `/triggers/${item.triggerId}`,
101-
action: 'View trigger'
134+
action: 'View trigger',
135+
consequences: []
102136
};
103137
}
104138
}
105139

140+
/** The run a wait is held up by, when it names one. */
141+
const waitRun = (wait: QueueWait): string | null => ('runId' in wait ? wait.runId : null);
142+
143+
/**
144+
* The cause an item follows from, by the key of the alert that names that cause, or null when it stands alone:
145+
* a schedule is overdue because its location stopped checking in, or else because no server runs the scheduler;
146+
* a run waits in the queue because an unresponsive run of its job, or one it waits for, holds it up.
147+
* An acknowledged cause leaves the list, so nothing is grouped under it.
148+
*/
149+
function causeOf(item: AttentionItem, items: AttentionItem[]): string | null {
150+
if (item.kind === 'platform_event' && item.event.kind === 'tick_overdue') {
151+
const events = items.flatMap((i) => (i.kind === 'platform_event' ? [i.event] : []));
152+
const location = events.find((e) => e.kind === 'location_broken' && e.locationId === item.event.locationId);
153+
const scheduler = events.find((e) => e.kind === 'scheduler_no_leader');
154+
const cause = location ?? scheduler;
155+
return cause ? `event:${cause.id}` : null;
156+
}
157+
if (item.kind === 'queue_blocked') {
158+
const held = new Set(item.waits.map(waitRun));
159+
const stuck = items.find((i) => i.kind === 'run_unresponsive' && !i.acknowledged && ((item.jobKey !== null && i.run.jobKey === item.jobKey) || held.has(i.run.id)));
160+
return stuck && stuck.kind === 'run_unresponsive' ? `unresponsive:${stuck.run.id}` : null;
161+
}
162+
return null;
163+
}
164+
165+
function consequenceOf(item: AttentionItem, view: AttentionView): Consequence {
166+
if (item.kind === 'queue_blocked') return { text: `${view.title}, queued ${view.since}. ${view.detail}`, href: view.href };
167+
if (item.kind === 'platform_event') return { text: item.event.message, href: view.href };
168+
return { text: `${view.title}: ${view.detail}`, href: view.href };
169+
}
170+
171+
/** The items as alerts, errors first: an item that follows from another alert's cause is listed under it, not on its own. */
172+
export function attentionViews(items: AttentionItem[], now: number): { item: AttentionItem; view: AttentionView }[] {
173+
const viewed = items.map((item) => ({ item, view: attentionView(item, now) }));
174+
const byKey = new Map(viewed.map((v) => [v.view.key, v]));
175+
const shown = viewed.filter(({ item, view }) => {
176+
const cause = byKey.get(causeOf(item, items) ?? '');
177+
if (!cause) return true;
178+
cause.view.consequences.push(consequenceOf(item, view));
179+
// The cause is at least as urgent as anything it brings about.
180+
if (attentionRank(view.tone) < attentionRank(cause.view.tone)) cause.view.tone = view.tone;
181+
return false;
182+
});
183+
return shown.sort((a, b) => attentionRank(a.view.tone) - attentionRank(b.view.tone));
184+
}
185+
106186
/** Error first, then warnings, stale and info. */
107187
export function attentionRank(tone: AttentionTone): number {
108188
return { error: 0, warning: 1, stale: 2, info: 3 }[tone];

‎ui/src/lib/components/app-topbar.svelte‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
import SunIcon from '@lucide/svelte/icons/sun';
33
import MoonIcon from '@lucide/svelte/icons/moon';
44
import type { Snippet } from 'svelte';
5-
import type { ConnectionState } from '$lib/api';
5+
import type { ConnectionState, PlatformEvent } from '$lib/api';
66
import { theme, toggleTheme } from '$lib/theme.svelte';
77
import { formatAgo } from '$lib/format/time';
88
import { targetWords } from '$lib/platform/labels';
99
import { app } from '$lib/state/app.svelte';
1010
import PlatformEventBanner from './shell/platform-event-banner.svelte';
1111
import WarehouseSyncStatus from './shell/warehouse-sync-status.svelte';
1212
13-
type Props = { title: string; children?: Snippet };
14-
let { title, children }: Props = $props();
13+
/** `events` picks the platform problems the banner shows on this page; by default, all of them. */
14+
type Props = { title: string; children?: Snippet; events?: (event: PlatformEvent) => boolean };
15+
let { title, children, events }: Props = $props();
1516
1617
const connectionTone: Record<ConnectionState, string> = {
1718
live: 'var(--sb-success)',
@@ -73,7 +74,7 @@
7374
</button>
7475
</div>
7576
</div>
76-
<PlatformEventBanner />
77+
<PlatformEventBanner only={events} />
7778

7879
<style>
7980
.connection {

‎ui/src/lib/components/shell/platform-event-banner.svelte‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import { eventKindLabel, problemHref } from '$lib/platform/labels';
88
import { app } from '$lib/state/app.svelte';
99
10+
let { only = () => true }: { only?: (event: PlatformEvent) => boolean } = $props();
11+
1012
const rank = (e: PlatformEvent) => (e.severity === 'critical' ? 2 : e.severity === 'warning' ? 1 : 0);
1113
const events = $derived(
12-
app.platformEvents.filter((e) => e.active && e.severity !== 'info').sort((a, b) => rank(b) - rank(a))
14+
app.platformEvents.filter((e) => e.active && e.severity !== 'info' && only(e)).sort((a, b) => rank(b) - rank(a))
1315
);
1416
const critical = $derived(events.some((e) => e.severity === 'critical'));
1517
/** Location problems link to the location's page if it exists, else the Locations list; server problems only to server status. */
@@ -29,7 +31,7 @@
2931
{@const link = linkOf(event)}
3032
<li>
3133
<strong>{eventKindLabel[event.kind]}</strong>
32-
<span title={event.message}>{event.message}</span>
34+
<span>{event.message}</span>
3335
<small>{formatAgo(event.occurredAt, app.now)}</small>
3436
{#if link}<a href={to(link.href)}>{link.text}</a>{/if}
3537
</li>
@@ -80,10 +82,9 @@
8082
white-space: nowrap;
8183
}
8284
li span {
83-
overflow: hidden;
85+
min-width: 0;
8486
color: var(--muted-foreground);
85-
text-overflow: ellipsis;
86-
white-space: nowrap;
87+
overflow-wrap: anywhere;
8788
}
8889
li small {
8990
color: var(--sb-text-faint);

0 commit comments

Comments
 (0)