From 10808c1c5de5cd51799b5773cb6d98d18c360395 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 17 Jun 2026 16:44:31 -0400 Subject: [PATCH] fix(dashboard): inline cpu sparkline, history graph host label + stable y-axis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Hosts-Overview: move the CPU sparkline inline next to the cpu % value it represents (was floated far right on the name line, reading as unrelated). - Host Agent history widget: caption the chart with the host it represents (the panel title is generic) — links to the host hub. - History widget: snap the y-axis to a stable 0..next-10%-band ceiling instead of auto-scaling to the exact peak, so the 'zoom' no longer jumps each poll. Co-Authored-By: Claude Opus 4.8 (1M context) --- plugins/host_agent/routes.py | 8 +++++++ .../host_agent/templates/widget_history.html | 23 ++++++++++++++----- steward/templates/hosts/overview_widget.html | 3 +-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/plugins/host_agent/routes.py b/plugins/host_agent/routes.py index 848c05a..644dbee 100644 --- a/plugins/host_agent/routes.py +++ b/plugins/host_agent/routes.py @@ -465,8 +465,16 @@ async def widget_history(): # hundreds–thousands of points — a noisy, unreadable line. Bucket-average to a # readable point count, keeping the shape. series = {k: _downsample(v) for k, v in series.items()} + + # Stable y-axis ceiling. All three series are percentages, so snap the top up + # to the next 10% band (floor 20, cap 100). Auto-scaling to the exact peak made + # the chart "zoom" jump on every poll as the peak drifted a few %; snapping to + # a band keeps the axis steady across refreshes while still filling the panel. + peak = max((p[1] for s in series.values() for p in s), default=0.0) + y_max = min(100, max(20, ((int(peak) // 10) + 1) * 10)) return await render_template( "widget_history.html", host=host, series=series, hours=hours, wid=wid, + y_max=y_max, ) diff --git a/plugins/host_agent/templates/widget_history.html b/plugins/host_agent/templates/widget_history.html index 1414ad5..1bd73a8 100644 --- a/plugins/host_agent/templates/widget_history.html +++ b/plugins/host_agent/templates/widget_history.html @@ -11,8 +11,19 @@ No agent metrics for {{ host.name }} in the last {{ hours }}h yet. {% else %} -
- +
+ {# Name the host the graph represents — the panel title is generic. #} +
+ {% if session.user_id %} + {{ host.name }} + {% else %} + {{ host.name }} + {% endif %} + · last {{ hours }}h +
+
+ +