feat(host_agent): horizontal zebra-striped fleet widget rows
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 7s
CI / integration (push) Successful in 2m14s
CI / publish (push) Successful in 7s

Restore the host_agent fleet-glance widget to one horizontal row per host
(name left, metric cells + sparklines right) instead of the multi-column
block grid, and zebra-stripe odd rows so adjacent hosts read as distinct.
Names still wrap rather than hard-truncate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 16:31:27 -04:00
parent fed9973899
commit ebc67723d2
+22 -18
View File
@@ -1,37 +1,41 @@
{# host_agent widget — fleet glance. Per host: name on its own line (never {# host_agent widget — fleet glance. One horizontal row per host, zebra-striped
truncated), then a row of metric cells (cpu/mem/disk/load), each value with a so adjacent hosts read as distinct groupings: health dot + host name on the
trend sparkline beneath it — the host-page AGENT panel, on the dashboard. #} left, metric cells (cpu/mem/disk/load) each with a trend sparkline laid out
horizontally on the right. The name wraps (never hard-truncated) but the row
stays horizontal. #}
{% from "_macros.html" import metric_style %} {% from "_macros.html" import metric_style %}
{% if rows %} {% if rows %}
{% macro metric_cell(label, value, fmt, svg, style="", title="") %} {% macro metric_cell(label, value, fmt, svg, style="", title="") %}
<div style="min-width:74px;flex:0 0 auto;" title="{{ title }}"> <div style="min-width:62px;flex:0 0 auto;" title="{{ title }}">
<div style="font-size:0.66rem;color:var(--text-dim);text-transform:uppercase;letter-spacing:0.03em;">{{ label }}</div> <div style="font-size:0.62rem;color:var(--text-dim);text-transform:uppercase;letter-spacing:0.03em;">{{ label }}</div>
<div style="font-weight:600;font-size:0.8rem;font-variant-numeric:tabular-nums;{{ style }}"> <div style="font-weight:600;font-size:0.8rem;font-variant-numeric:tabular-nums;{{ style }}">
{% if value is not none %}{{ fmt|format(value) }}{% else %}—{% endif %} {% if value is not none %}{{ fmt|format(value) }}{% else %}—{% endif %}
</div> </div>
<div style="line-height:0;height:16px;">{{ svg | safe }}</div> <div style="line-height:0;height:16px;">{{ svg | safe }}</div>
</div> </div>
{% endmacro %} {% endmacro %}
<div class="host-blocks"> <div class="host-fleet">
{% for r in rows %} {% for r in rows %}
{% set stale = r.stale %} {% set stale = r.stale %}
<div style="padding:0.55rem 0;border-bottom:1px solid var(--border);"> <div style="display:flex;align-items:center;gap:0.6rem 1rem;flex-wrap:wrap;padding:0.5rem 0.6rem;border-radius:4px;{% if loop.index0 % 2 %}background:var(--bg-elevated);{% endif %}">
{# Line 1 — health dot + full host name (own line) + last seen #} {# Left — health dot + full host name (wraps, never truncated) + last seen #}
<div style="display:flex;align-items:center;gap:0.5rem;"> <div style="display:flex;align-items:center;gap:0.5rem;flex:1 1 150px;min-width:120px;">
<span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}" <span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}"
style="flex-shrink:0;" style="flex-shrink:0;"
title="{% if stale %}stale / no recent data{% else %}warns at CPU/memory ≥90% or any disk mount ≥90% (the 'disk /' figure shows root only){% endif %}"></span> title="{% if stale %}stale / no recent data{% else %}warns at CPU/memory ≥90% or any disk mount ≥90% (the 'disk /' figure shows root only){% endif %}"></span>
{% if session.user_id %} <span style="min-width:0;">
<a href="/hosts/{{ r.host.id }}" style="font-weight:600;font-size:0.85rem;overflow-wrap:anywhere;">{{ r.host.name }}</a> {% if session.user_id %}
{% else %} <a href="/hosts/{{ r.host.id }}" style="font-weight:600;font-size:0.85rem;overflow-wrap:anywhere;">{{ r.host.name }}</a>
<span style="font-weight:600;font-size:0.85rem;overflow-wrap:anywhere;">{{ r.host.name }}</span> {% else %}
{% endif %} <span style="font-weight:600;font-size:0.85rem;overflow-wrap:anywhere;">{{ r.host.name }}</span>
<span style="margin-left:auto;font-size:0.72rem;color:var(--text-dim);flex-shrink:0;"> {% endif %}
{{ r.reg.last_seen_at.strftime("%H:%M:%S") if r.reg.last_seen_at else "never" }} <span style="display:block;font-size:0.7rem;color:var(--text-dim);">
{{ r.reg.last_seen_at.strftime("%H:%M:%S") if r.reg.last_seen_at else "never" }}
</span>
</span> </span>
</div> </div>
{# Line 2 — metric cells with value + trend; wraps instead of truncating #} {# Right — metric cells with value + trend, laid out horizontally #}
<div style="display:flex;flex-wrap:wrap;gap:0.4rem 1.1rem;margin-top:0.35rem;padding-left:1.1rem;"> <div style="display:flex;flex-wrap:wrap;gap:0.4rem 1rem;justify-content:flex-end;">
{{ metric_cell("cpu", r.cpu_pct, "%.0f%%", r.sparks.cpu, metric_style(r.cpu_pct), "Average CPU utilization") }} {{ metric_cell("cpu", r.cpu_pct, "%.0f%%", r.sparks.cpu, metric_style(r.cpu_pct), "Average CPU utilization") }}
{{ metric_cell("mem", r.mem_used_pct, "%.0f%%", r.sparks.mem, metric_style(r.mem_used_pct), "Memory in use") }} {{ metric_cell("mem", r.mem_used_pct, "%.0f%%", r.sparks.mem, metric_style(r.mem_used_pct), "Memory in use") }}
{{ metric_cell("disk /", r.disk_root, "%.0f%%", r.sparks.disk, metric_style(r.disk_root), "Root filesystem (/) usage") }} {{ metric_cell("disk /", r.disk_root, "%.0f%%", r.sparks.disk, metric_style(r.disk_root), "Root filesystem (/) usage") }}