From 3ae6e597297cde386a3156e190875ce4f2b5535f Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 17 Oct 2026 17:05:35 +0200 Subject: [PATCH 1/2] =?UTF-8?q?test:=20reproduce=20#675=20=E2=80=94=20cons?= =?UTF-8?q?ole=20Activity=20shows=20the=20highest=20seq,=20not=20the=20lat?= =?UTF-8?q?est=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/model/overview.test.ts | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ui/src/model/overview.test.ts b/ui/src/model/overview.test.ts index e29bcbea6..89b9c1330 100644 --- a/ui/src/model/overview.test.ts +++ b/ui/src/model/overview.test.ts @@ -151,6 +151,44 @@ describe("the overview", () => { expect(activity[1]).not.toHaveProperty("tone"); }); + it("lists the eight latest events across a daemon restart, not the eight with the highest seq", () => { + // why: the console's first load reads the daemon's event file, which survives a restart, so one + // buffer holds the previous run's events beside the restarted counter's own. `seq` restarts with + // every daemon, so only `timestamp` then `seq` orders them (docs/EVENTS.md). + const previousGeneration = [91, 92, 93, 94, 95, 96].map((seq, index) => ({ + event: "lease.released", + id: `before-${seq}`, + payload: {}, + seq, + timestamp: NOW - (20 - index) * 60_000, + })); + const currentGeneration = [1, 2, 3, 4].map((seq, index) => ({ + event: "lease.granted", + id: `after-${seq}`, + payload: {}, + seq, + timestamp: NOW - (4 - index) * 60_000, + })); + + const { activity } = overviewOf({ + events: [...previousGeneration, ...currentGeneration], + now: NOW, + requests: [], + workers: fleet, + }); + + expect(activity.map((row) => row.key)).toEqual([ + "after-4", + "after-3", + "after-2", + "after-1", + "before-96", + "before-95", + "before-94", + "before-93", + ]); + }); + it("gives each worker its health square, its slots and its load, and a lost worker no load", () => { const { workers } = overviewOf({ events: [], now: NOW, requests: [], workers: fleet }); From 56ae347f99b76e2d83d7d28eea8c781d838725e2 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 17 Oct 2026 17:06:24 +0200 Subject: [PATCH 2/2] fix(console): order the overview's activity by time, then seq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Activity panel sorted by `seq` alone. `seq` is a per-daemon-run counter, so a buffer holding events from before a restart — the event file survives one — showed the previous generation's higher numbers and dropped the newest events. Every other reader sorts by `timestamp`, then `seq` (src/bus/order.ts, the Events page, the attention detail), which is the order docs/EVENTS.md promises a replay is listed in. --- ui/src/model/overview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/model/overview.ts b/ui/src/model/overview.ts index 3d0a3be1a..68379cae0 100644 --- a/ui/src/model/overview.ts +++ b/ui/src/model/overview.ts @@ -194,7 +194,7 @@ export function overviewOf(input: { const minutes = held === undefined ? [] : leaseHistory(held, events, now); return { activity: [...events] - .sort((a, b) => b.seq - a.seq) + .sort((a, b) => b.timestamp - a.timestamp || b.seq - a.seq) .slice(0, ACTIVITY_ROWS) .map((event) => { const tone = eventTone(event.event);