From 23d79e24658aa4c94f0313ee82ac0f12605e05cf Mon Sep 17 00:00:00 2001 From: devitway Date: Fri, 20 Mar 2026 19:23:41 +0000 Subject: [PATCH] ui: group consecutive identical activity entries Repeated cache hits for the same artifact now show as "artifact (x4)" instead of 4 identical rows. Reduces visual noise in dashboard activity log. --- nora-registry/src/ui/templates.rs | 47 ++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/nora-registry/src/ui/templates.rs b/nora-registry/src/ui/templates.rs index 7e778f7..23ef658 100644 --- a/nora-registry/src/ui/templates.rs +++ b/nora-registry/src/ui/templates.rs @@ -74,17 +74,44 @@ pub fn render_dashboard(data: &DashboardResponse, lang: Lang) -> String { t.no_activity ) } else { - data.activity - .iter() - .map(|entry| { + // Group consecutive identical entries (same action+artifact+registry+source) + let mut grouped: Vec<(String, String, String, String, String, usize)> = Vec::new(); + for entry in &data.activity { + let action = entry.action.to_string(); + let last_match = grouped + .last() + .map(|(_, a, art, reg, src, _)| { + *a == action + && *art == entry.artifact + && *reg == entry.registry + && *src == entry.source + }) + .unwrap_or(false); + + if last_match { + grouped.last_mut().unwrap().5 += 1; + } else { let time_ago = format_relative_time(&entry.timestamp); - render_activity_row( - &time_ago, - &entry.action.to_string(), - &entry.artifact, - &entry.registry, - &entry.source, - ) + grouped.push(( + time_ago, + action, + entry.artifact.clone(), + entry.registry.clone(), + entry.source.clone(), + 1, + )); + } + } + + grouped + .iter() + .map(|(time, action, artifact, registry, source, count)| { + let display_artifact = if *count > 1 { + format!("{} (x{})", artifact, count) + } else { + artifact.clone() + }; + render_activity_row(time, action, &display_artifact, registry, source) }) .collect() };