feat(alerts): history reads as episodes; tests follow the confirm dialog (#5316, #5314)
CI / lint (push) Successful in 3s
CI / integration (push) Failing after 54s
CI / unit (push) Successful in 1m34s
CI / publish (push) Skipped

History (#5316):
- Transitions fold into episodes (steward/alerts/episodes.py): each stretch
  out of quiet, the worst state it reached, how long it lasted, its worst
  reading against the rule ('3m 21s (fires above 3m)'), who was told across
  its changes, and its Ansible runs. The changes themselves fold under it.
- An episode cut by paging says so ('cleared later (above)', 'earlier').
- For one rule: a verdict ('Fired 4 times in the last 7d, 1h 2m in all') and
  no Rule column. Notified and Action show only when the range has any.

Tests:
- The confirm guard looks for a confirm( call, not the word in the comment
  that says it is gone (lesson #4365).
- The Hosts viewer test looks for the add-host dialog by id, since every page
  now carries the confirm dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 23:02:01 -04:00
co-authored by Claude Opus 5.5
parent 0c66c1e7d3
commit 531a193bd1
11 changed files with 346 additions and 61 deletions
+23 -11
View File
@@ -1,17 +1,29 @@
{# alerts/_history_rows.html — the history table; swapped in on a range or rule
change. Its rows come a page at a time (alerts/_history_page.html). #}
{% from "_macros.html" import status_badge, empty_state %}
{% if events %}
<div class="card-flush" style="overflow-x:auto;">
<table class="table">
{# alerts/_history_rows.html — the history: for one rule, how often it fired
and for how long in all; then its episodes (#5316), swapped in on a range
or rule change. The rule column shows only across rules, Notified and
Action only when the range has something to put in them. Episodes come a
page of transitions at a time (alerts/_history_page.html). #}
{% from "_macros.html" import empty_state %}
{% if chosen and verdict %}
<p class="page-verdict">
{%- if verdict.fired %}<strong class="tone-{{ 'crit' if verdict.ongoing else 'warn' }}">Fired {{ verdict.fired }} time{{ "s" if verdict.fired != 1 }}</strong> in the last {{ current_range }}
{%- if verdict.seconds %}, {{ verdict.seconds|duration }} in all{% endif %}
{%- if verdict.ongoing %} · <span class="tone-crit">firing now</span>{% endif %}
{%- else %}<strong class="tone-ok">Never fired</strong> in the last {{ current_range }}{% endif %}
<span class="tone-dim">· fires when {{ rule_condition(chosen) }} on {{ chosen.resource_name }}</span>
</p>
{% endif %}
{% if episodes %}
<div class="card-flush">
<table class="table alert-episodes">
<thead>
<tr>
<th>When</th>
<th>Rule</th>
<th>Change</th>
<th>Reading</th>
<th>Notified</th>
<th>Action</th>
{% if not chosen %}<th>Rule</th>{% endif %}
<th>What happened</th>
<th title="The reading furthest past the rule's threshold">Worst reading</th>
{% if show_notified %}<th>Notified</th>{% endif %}
{% if show_action %}<th>Action</th>{% endif %}
</tr>
</thead>
<tbody>