Files
jackos1998andClaude Opus 5.5 817655ad77 progress: Share formatting and phases between slop and the web
Times are formatted by `humantime` and sizes by `indicatif`, which
were already dependencies, instead of by our own code, and the web
app's copy of the time format is gone. Sizes now have two decimals.

The latest progress of each phase, and how each node is getting on,
move from `runs::Run` to `progress::Phases`, so `slop` can use them
too. A phase's counts and what's running now are written once, in
`Progress`, for its line, its bar in `slop` and the web app.

Refs #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:33:15 +00:00

113 lines
4.9 KiB
HTML

{# A padlock, marking what needs a passkey #}
{% macro lock() -%}
<svg class="lock" viewBox="0 0 16 16" aria-hidden="true"><path d="M4 7V5a4 4 0 0 1 8 0v2h1v8H3V7zm2 0h4V5a2 2 0 0 0-4 0z"/></svg>
{%- endmacro %}
{% macro card(entry, csrf, open) %}
<article class="request{% if entry.passkey %} needs-passkey{% endif %}" id="r-{{ entry.id }}">
<h2><a href="/requests/{{ entry.id }}">{{ entry.summary }}</a></h2>
<p class="meta">{{ entry.requester }} · {{ entry.op }} · <span class="expires" data-left="{{ entry.expires_in }}">expires in {{ self::elapsed(*entry.expires_in) }}</span>
{%- if entry.passkey %} <span class="badge passkey">{% call lock() %}{% endcall %}Needs passkey</span>{% endif %}
{%- if entry.sensitive %} <span class="badge warn">Sensitive</span>{% endif %}</p>
{% if let Some(label) = entry.label %}
<p class="label">Label (agent-supplied): {{ label }}</p>
{% endif %}
{% call detail(entry.detail, open) %}{% endcall %}
<form method="post" action="/requests/{{ entry.id }}" class="answers">
<input type="hidden" name="csrf" value="{{ csrf }}">
{% for decision in entry.offers %}
{% let deny = self::is_deny(decision) %}
<button type="submit" name="decision" value="{{ decision.name() }}" class="{% if deny %}deny{% else %}approve{% endif %}">
{%- if entry.passkey && !deny %}{% call lock() %}{% endcall %}{% endif %}{{ self::answer(decision) }}</button>
{% endfor %}
</form>
{% if entry.passkey %}
<p class="note">Policy wants a fresh passkey for this one: approving sends you to sign in again. Denying doesn't.</p>
{% endif %}
</article>
{% endmacro %}
{# Fields stay in view; tables, lists and text fold away unless `open`. #}
{% macro detail(detail, open) %}
{% if !detail.fields.is_empty() %}
<dl class="fields">
{% for field in detail.fields %}
<dt>{{ field.label }}</dt><dd class="{{ field.tone.class() }}">{% if field.code %}<code>{{ field.value }}</code>{% else %}{{ field.value }}{% endif %}</dd>
{% endfor %}
</dl>
{% endif %}
{% if !detail.sections.is_empty() %}
<details{% if open %} open{% endif %}><summary>Details ({{ self::section_titles(detail) }})</summary>
{% for section in detail.sections %}
<section class="detail">
<h3>{{ section.title() }}</h3>
{% match section %}
{% when Section::Table with { columns, rows, more, .. } %}
<div class="scroll"><table class="detail">
<thead><tr>{% for column in columns %}<th>{{ column.title }}</th>{% endfor %}</tr></thead>
<tbody>
{% for row in rows %}<tr class="{{ row.tone.class() }}">{% for cell in row.cells %}{% if self::is_code(columns, loop.index0) %}<td class="code"><code>{{ cell }}</code></td>{% else %}<td>{{ cell }}</td>{% endif %}{% endfor %}</tr>
{% endfor %}
</tbody></table></div>
{% if *more > 0 %}<p class="note">… {{ more }} more</p>{% endif %}
{% when Section::List with { items, more, code, .. } %}
<ul>{% for item in items %}<li>{% if *code %}<code>{{ item }}</code>{% else %}{{ item }}{% endif %}</li>{% endfor %}</ul>
{% if *more > 0 %}<p class="note">… {{ more }} more</p>{% endif %}
{% when Section::Text with { text, diff, .. } %}
{% if *diff %}
<pre class="diff">{% for (kind, line) in self::diff_lines(text) %}<span class="diff-{{ kind }}">{{ line }}</span>
{% endfor %}</pre>
{% else %}
<pre>{{ text }}</pre>
{% endif %}
{% endmatch %}
</section>
{% endfor %}
</details>
{% endif %}
{% endmacro %}
{% macro time(rfc3339) -%}
<time datetime="{{ rfc3339 }}">{{ rfc3339.replace('T', " ").trim_end_matches('Z') }} UTC</time>
{%- endmacro %}
{% macro outcome(outcome) -%}
<span class="outcome {{ outcome.tone() }}">{{ outcome.name() }}</span>
{%- endmacro %}
{% macro timeline(records) %}
<ol class="timeline">
{% for record in records %}
{% let (text, detail) = self::describe(record) %}
<li>{% call time(record.time) %}{% endcall %} <span>{{ text }}</span>
{%- if let Some(detail) = detail %}{% call detail(detail, false) %}{% endcall %}{% endif %}</li>
{% endfor %}
</ol>
{% endmacro %}
{% macro select(name, label, chosen, options) -%}
<label>{{ label }} <select name="{{ name }}"><option value="">Any</option>
{%- for (value, text) in options %}<option value="{{ value }}"{% if value.as_str() == chosen.as_str() %} selected{% endif %}>{{ text }}</option>{% endfor -%}
</select></label>
{%- endmacro %}
{# A bar for a phase: its count if it has one, otherwise just whether it's going. #}
{% macro meter(progress) -%}
{% if let Some(count) = progress.bar() -%}
<progress class="{{ self::state_class(progress) }}" max="{{ count.total }}" value="{{ count.done }}"></progress>
{%- else if self::running(progress) -%}
<progress class="active"></progress>
{%- else -%}
<progress class="{{ self::state_class(progress) }}" max="1" value="1"></progress>
{%- endif %}
{%- endmacro %}
{# A request's whole progress in one bar, for lists. #}
{% macro run_meter(run) -%}
{% if let Some(count) = run.phases.bar() -%}
<progress class="active" max="{{ count.total }}" value="{{ count.done }}"></progress>
{%- else -%}
<progress class="active"></progress>
{%- endif %}
{%- endmacro %}