pipekit/pipekit/web/templates/_module_live.html
Paul Trowbridge 780f73021c Run buttons stay on page with live status updates via HTMX polling
Module detail and index Run/Dry run buttons no longer redirect to the
run page. The status cell (index) and recent runs panel (detail) poll
every 3s while running and stop automatically when idle. force_poll
ensures polling starts immediately after clicking Run despite the race
between the HTTP response and the background task setting running=1.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-05-22 12:31:14 -04:00

44 lines
1.8 KiB
HTML

{# Partial: recent runs panel + out-of-band status pill update.
Rendered by both module_detail.html (on load) and the live-fragment endpoint.
Polls every 3s while running; stops automatically when idle. #}
<div id="module-live"
{% if module.running or force_poll %}
hx-get="/modules/{{ module.id }}/live-fragment"
hx-trigger="every 3s"
hx-swap="outerHTML"
{% endif %}>
<div class="panel">
<header>Recent runs
<span class="subtitle">last {{ recent_runs|length }}</span>
<span style="margin-left:auto"><a href="/runs?module_id={{ module.id }}">all →</a></span>
</header>
<div class="body tight">
{% if recent_runs %}
<table class="grid">
<thead><tr><th>id</th><th>started</th><th>duration</th><th>status</th><th>rows</th></tr></thead>
<tbody>
{% for r in recent_runs %}
<tr>
<td><a href="/runs/{{ r.id }}">#{{ r.id }}</a></td>
<td class="mono">{{ r.started_at or '—' }}</td>
<td class="mono">{{ r.duration_s | duration }}</td>
<td><span class="pill {{ r.status }}">{{ r.status }}</span></td>
<td class="mono">{{ r.row_count if r.row_count is not none else "—" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty">No runs yet.</div>
{% endif %}
</div>
</div>
</div>
{# Out-of-band: keep the status pills in the page header in sync #}
<span id="module-pills" hx-swap-oob="true">
{% if module.running %}<span class="pill running">running</span>{% endif %}
{% if not module.enabled %}<span class="pill disabled">disabled</span>{% endif %}
</span>