fix(webui): group live activity by payload, not by event kind
The first cut grouped consecutive same-kind events, but the real noise shape is an interleave: one background cycle emits curator_run, session-memory and curator_action events carrying the same payload, and kind-keyed grouping left them all visible. The grouping key is now the rendered detail plus the task, so one cycle of noise collapses to one row regardless of which internal kind emitted each event, while events carrying different information never merge. Verified against a live daemon: 50 background events collapse to one expandable row.
This commit is contained in:
1 parent
fd3f661a73
commit
89fc8fc7f1
5 files changed
+70
-27
No files matched your search
@@ -12,7 +12,7 @@ import { ago } from "@/lib/format";
|
||||
import { useLiveUpdatesStore } from "@/stores/live-updates";
|
||||
import ActivityRow from "./ActivityRow.vue";
|
||||
import { activityDetail } from "./activity-detail";
|
||||
import { groupActivity, groupKey, type ActivityGroup } from "./activity-group";
|
||||
import { groupActivity, type ActivityGroup } from "./activity-group";
|
||||
|
||||
/**
|
||||
* The last 50 events, newest first, with the stream's own state on the card.
|
||||
@@ -36,7 +36,7 @@ function toggle(key: string) {
|
||||
}
|
||||
|
||||
function isOpen(group: ActivityGroup): boolean {
|
||||
return expanded.has(groupKey(group.label, group.taskID));
|
||||
return expanded.has(group.key);
|
||||
}
|
||||
|
||||
// The collapsed group row shows what its newest event would have shown, so
|
||||
@@ -92,7 +92,7 @@ function openTask(taskID: number) {
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<template v-if="activity.length">
|
||||
<template v-for="group in groups" :key="`${group.label}:${group.taskID}`">
|
||||
<template v-for="group in groups" :key="group.key">
|
||||
<!-- A singleton is exactly the row the raw feed would show. -->
|
||||
<ActivityRow v-if="group.count === 1" :event="group.representative" @open="openTask" />
|
||||
<template v-else>
|
||||
@@ -118,7 +118,7 @@ function openTask(taskID: number) {
|
||||
class="inline-flex items-center gap-1 rounded hover:opacity-80"
|
||||
:aria-expanded="isOpen(group)"
|
||||
:aria-label="`${isOpen(group) ? 'Hide' : 'Show'} ${group.count} ${group.label} events`"
|
||||
@click.stop="toggle(groupKey(group.label, group.taskID))"
|
||||
@click.stop="toggle(group.key)"
|
||||
>
|
||||
<ChevronDown v-if="isOpen(group)" class="size-3.5 shrink-0 text-fg-subtle" />
|
||||
<ChevronRight v-else class="size-3.5 shrink-0 text-fg-subtle" />
|
||||
@@ -133,7 +133,7 @@ function openTask(taskID: number) {
|
||||
<TableCell>{{ groupWhen(group) }}</TableCell>
|
||||
</TableRow>
|
||||
<template v-if="isOpen(group)">
|
||||
<ActivityRow v-for="(event, i) in group.events" :key="`${group.label}:${group.taskID}:${i}`" :event="event" @open="openTask" />
|
||||
<ActivityRow v-for="(event, i) in group.events" :key="`${group.key}:${i}`" :event="event" @open="openTask" />
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
import type { ActivityEvent } from "./state";
|
||||
import { activityDetail } from "./activity-detail.ts";
|
||||
|
||||
/**
|
||||
* The live activity feed's grouping projection.
|
||||
*
|
||||
* The daemon emits high-frequency background telemetry (session-memory
|
||||
* cycles, runner calls) that arrives as dozens of same-shape rows an hour.
|
||||
* Printed raw, the table stops being scannable and real milestones drown.
|
||||
* The rule: a *run of consecutive* events sharing one label and one task
|
||||
* collapses into a single group row; anything else stays on its own line, so
|
||||
* a milestone is never merged with a different event that merely shares its
|
||||
* kind. The grouping is consecutive, not global, so interleaved kinds keep
|
||||
* their order and nothing is reordered under the operator.
|
||||
* The daemon emits high-frequency background telemetry that arrives as dozens
|
||||
* of same-shape rows an hour — often as an interleave of kinds (a curator
|
||||
* cycle emits curator_run, session-memory and curator_action events that all
|
||||
* carry the same payload). Printed raw, the table stops being scannable and
|
||||
* real milestones drown.
|
||||
*
|
||||
* The rule: a *run of consecutive* events sharing one task and one rendered
|
||||
* detail collapses into a single group row. Kind is deliberately not part of
|
||||
* the key — an interleave of kinds over one payload is one cycle of noise,
|
||||
* not three events — so anything else stays on its own line, and a milestone
|
||||
* is never merged with an event carrying different information. The grouping
|
||||
* is consecutive, not global, so interleaved events keep their order and
|
||||
* nothing is reordered under the operator.
|
||||
*
|
||||
* This is a pure view projection over the store's raw stream: the store keeps
|
||||
* every event, and this module decides only how the feed presents them.
|
||||
*/
|
||||
|
||||
|
||||
/** One displayed row: either a single event (count 1) or a collapsed run. */
|
||||
export interface ActivityGroup {
|
||||
/** Stable identity of the run: the grouping key of its first event. */
|
||||
key: string;
|
||||
/** The resolved label the row shows, matching the Event column's fallback. */
|
||||
label: string;
|
||||
/** The task the group's events resolve to, or 0 for none. */
|
||||
@@ -30,8 +39,8 @@ export interface ActivityGroup {
|
||||
events: ActivityEvent[];
|
||||
}
|
||||
|
||||
export function groupKey(label: string, taskID: number | undefined): string {
|
||||
return `${label}:${taskID ?? 0}`;
|
||||
export function groupKey(detail: string, taskID: number | undefined): string {
|
||||
return `${detail}:${taskID ?? 0}`;
|
||||
}
|
||||
|
||||
export function groupActivity(events: ActivityEvent[]): ActivityGroup[] {
|
||||
@@ -39,13 +48,14 @@ export function groupActivity(events: ActivityEvent[]): ActivityGroup[] {
|
||||
for (const event of events) {
|
||||
const label = event.kind || event.type || "event";
|
||||
const taskID = Number(event.task_id) || 0;
|
||||
const key = groupKey(activityDetail(event).text, taskID);
|
||||
const last = groups[groups.length - 1];
|
||||
if (last && last.label === label && last.taskID === taskID) {
|
||||
if (last && last.key === key) {
|
||||
last.count += 1;
|
||||
last.events.push(event);
|
||||
continue;
|
||||
}
|
||||
groups.push({ label, taskID, count: 1, representative: event, events: [event] });
|
||||
groups.push({ key, label, taskID, count: 1, representative: event, events: [event] });
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
Reference in new issue
Block a user