Dashboard: flag stale alerts and tickets left open
Lint / JS (eslint) (push) Successful in 19s
Lint / Python (flake8) (push) Successful in 1m7s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 52s
Test / Python Tests (pytest) (push) Successful in 44s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Python (flake8) (pull_request) Successful in 50s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 52s
Test / Python Tests (pytest) (pull_request) Successful in 1m35s

Gandalf only comments on tickets, so a ticket can stay open long after its
alert cleared (pbs's ticket sat open for a month), and an alert can stay
active for days once nobody is looking.

- The monitor reads Tinker's open ticket list (tickets_api.php, read scope)
  every 15 minutes and saves it. A failed read keeps the previous list.
- Active alerts get a stale badge after monitor.stale_alert_days (3), and a
  "ticket closed" badge when their ticket was closed while still active.
- A Needs Follow-up panel lists open tickets whose every alert cleared at
  least monitor.stale_ticket_hours (24) ago.
- A "TO FOLLOW UP" status chip counts both. If the open ticket list is over
  2 hours old, the ticket flags are left off rather than guessed.
- Replaced an — in the alert count notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 15:57:58 -05:00
co-authored by Claude Opus 5.5
parent 7b80633088
commit 0921e82c54
10 changed files with 462 additions and 4 deletions
+46 -4
View File
@@ -55,7 +55,10 @@ async function refreshAll() {
if (statusResult.status === 'fulfilled') {
const status = statusResult.value;
updateEventsTable(status.events || [], status.total_active);
updateStatusBar(status.summary || {}, status.last_check || '', status.daemon_ok);
updateFollowUp(status.stale_tickets || []);
updateStatusBar(status.summary || {}, status.last_check || '', status.daemon_ok,
followUpCount(status.events || [], status.stale_tickets || []),
(status.stale_tickets || []).length > 0);
if (typeof window.gandalfNotifUpdate === 'function') window.gandalfNotifUpdate(status.events || []);
} else {
showToast('Status data unavailable', 'warning');
@@ -66,7 +69,14 @@ async function refreshAll() {
}
}
function updateStatusBar(summary, lastCheck, daemonOk) {
// Active alerts flagged stale or with a closed ticket, plus tickets left open after clearing
function followUpCount(events, staleTickets) {
const flagged = events.filter(e => e.severity !== 'info' &&
((e.stale_days !== null && e.stale_days !== undefined) || e.ticket_closed)).length;
return flagged + staleTickets.length;
}
function updateStatusBar(summary, lastCheck, daemonOk, followUps = 0, hasStaleTickets = false) {
const bar = document.querySelector('.status-chips');
if (!bar) return;
const chips = [];
@@ -74,6 +84,10 @@ function updateStatusBar(summary, lastCheck, daemonOk) {
if (summary.critical) chips.push(`<span class="chip chip-critical">● ${summary.critical} CRITICAL</span>`);
if (summary.warning) chips.push(`<span class="chip chip-warning">● ${summary.warning} WARNING</span>`);
if (!summary.critical && !summary.warning && daemonOk !== false) chips.push('<span class="chip chip-ok">✔ ALL SYSTEMS NOMINAL</span>');
if (followUps) {
const href = hasStaleTickets ? '#followup' : '#events-table-wrap';
chips.push(`<a class="chip chip-warning chip-followup" href="${href}">⏳ ${followUps} TO FOLLOW UP</a>`);
}
bar.innerHTML = chips.join('');
const lc = document.getElementById('last-check');
@@ -469,7 +483,7 @@ function updateEventsTable(events, totalActive) {
const truncated = totalActive !== null && totalActive !== undefined && totalActive > active.length;
const countNotice = truncated
? `<div class="pagination-notice">Showing ${active.length} of ${totalActive} active alerts &mdash; <a href="/api/events?limit=1000">view all via API</a></div>`
? `<div class="pagination-notice">Showing ${active.length} of ${totalActive} active alerts: <a href="/api/events?limit=1000">view all via API</a></div>`
: '';
const rows = active.map(e => {
@@ -485,9 +499,15 @@ function updateEventsTable(events, totalActive) {
const supBadge = e.is_suppressed
? `<span class="lt-badge badge-suppressed" title="Alert suppressed">🔕 sup</span>`
: '';
const staleBadge = (e.stale_days !== null && e.stale_days !== undefined)
? `<span class="lt-badge badge-stale" title="Active for ${Number(e.stale_days)} days with no fix yet">⏳ ${Number(e.stale_days)}d</span>`
: '';
const closedBadge = e.ticket_closed
? `<span class="lt-badge badge-ticket-closed" title="Ticket #${lt.escHtml(String(e.ticket_id))} was closed in Tinker, but this alert is still active">ticket closed</span>`
: '';
return `
<tr class="row-${e.severity}${e.is_suppressed ? ' row-suppressed' : ''}">
<td><span class="lt-badge badge-${e.severity}">${e.severity}</span>${supBadge}</td>
<td><span class="lt-badge badge-${e.severity}">${e.severity}</span>${supBadge}${staleBadge}${closedBadge}</td>
<td>${lt.escHtml(e.event_type.replace(/_/g,' '))}</td>
<td><strong>${lt.escHtml(e.target_name)}</strong></td>
<td>${lt.escHtml(e.target_detail || '-')}</td>
@@ -522,6 +542,28 @@ function updateEventsTable(events, totalActive) {
</div>`;
}
// ── Needs follow-up: tickets left open after their alert cleared ──────
function updateFollowUp(tickets) {
const section = document.getElementById('followup');
const tbody = document.querySelector('#followup-table tbody');
if (!section || !tbody) return;
section.hidden = !tickets.length;
const badge = document.getElementById('followup-badge');
if (badge) badge.textContent = tickets.length;
const ticketBase = (typeof GANDALF_CONFIG !== 'undefined' && GANDALF_CONFIG.ticket_web_url)
? GANDALF_CONFIG.ticket_web_url : 'http://t.lotusguild.org/ticket/';
tbody.innerHTML = tickets.map(t => `
<tr>
<td><a href="${lt.escHtml(ticketBase)}${lt.escHtml(String(t.ticket_id))}" target="_blank" rel="noopener"
class="ticket-link">#${lt.escHtml(String(t.ticket_id))}</a></td>
<td><strong>${lt.escHtml(t.target_name || '')}</strong></td>
<td>${lt.escHtml((t.event_type || '').replace(/_/g, ' '))}${t.target_detail
? ` <span class="lt-text-muted">${lt.escHtml(t.target_detail)}</span>` : ''}</td>
<td class="ts-cell" title="${lt.escHtml(t.cleared_at || '')}">${lt.time.ago(_toIso(t.cleared_at))}</td>
<td>${Number(t.events) || 0}</td>
</tr>`).join('');
}
// ── Suppression modal ─────────────────────────────────────────────────
function openSuppressModal(type, name, detail) {
const modal = document.getElementById('suppress-modal');
+6
View File
@@ -229,6 +229,12 @@
.badge-resolved { color: var(--text-muted); border-color: var(--border-color); text-decoration: line-through; }
.badge-suppressed { font-size: .9em; padding: 0; border: none; color: var(--text-muted); }
.badge-purple { color: var(--accent-purple); border-color: var(--accent-purple); }
.badge-stale { color: var(--amber, var(--orange)); border-color: transparent; margin-left: 4px; white-space: nowrap; }
.badge-ticket-closed { color: var(--accent-purple); border-color: var(--accent-purple); margin-left: 4px; white-space: nowrap; }
.chip-followup { text-decoration: none; cursor: pointer; }
.chip-followup:hover, .chip-followup:focus-visible { background: rgba(255,107,0,.12); }
.followup-intro { color: var(--text-muted); font-size: .85em; margin: 0 0 8px; }
#followup-table td { white-space: nowrap; }
/* ── Table row state colors ───────────────────────────────────────── */
.lt-table tr.row-critical td { background: rgba(255,45,85,.04); }