Files
jackos1998andClaude Opus 5.5 0b2cdf4155
CI / Check (push) Successful in 4m44s
web: Show history details as approvals show them
The audit log kept a request's detail as text, so the web app's history
showed it as one preformatted block. Keep the structure instead, and
render it with the same fields, tables and coloured diffs as a pending
request. Older records' text still reads, as a text section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 16:34:58 +00:00

93 lines
4.1 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::left(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 %}