{% extends "base.html" %} {% from "_rows.html" import source_label, hhmm, hhmmss %} {% block title %}Session {{ session }}{% endblock %} {#- The text a body shows: its ``text``, a tool result's ``content``, else its JSON. -#} {% macro text_into(ns, body) -%} {%- if body is mapping and body.text is defined and body.text is string -%} {%- set ns.text = body.text -%} {%- elif body is mapping and body.content is defined and body.content is string -%} {%- set ns.text = body.content -%} {%- elif body is mapping and body.content is defined and body.content is iterable -%} {%- set ns.text = body.content | select('mapping') | selectattr('type', 'equalto', 'text') | map(attribute='text') | select('string') | join('\n') -%} {%- else -%} {%- set ns.text = body | full_text -%} {%- endif -%} {%- endmacro %} {#- A decision as the person reads it: allowed by a rule, asked and approved, or denied. -#} {% macro verdict(d) -%} {%- set b = d.body if d.body is mapping else {} -%} {%- set source = b.source if b.source is string else '' -%} {%- if b.decision == 'accept' -%} {%- set label = 'asked' if source.startswith('user') else 'allowed' -%} {%- elif b.decision == 'reject' -%} {%- set label = 'denied' -%} {%- else -%} {%- set label = b.decision | string -%} {%- endif -%} {{ label }} {%- endmacro %} {% macro tokens(text) -%} {%- set n = (text | length / 4) | round(0, 'ceil') | int -%} {%- if n >= 1000 %}~{{ '%.1f' | format(n / 1000) }}k{% else %}~{{ n }}{% endif %} tokens {%- endmacro %} {% macro load_full(key) -%} load full {%- endmacro %} {% macro long_body(text, key) -%}
{{ text[:preview_chars] }}
{% if text | length > preview_chars and key %} {{ load_full(key) }} {% endif %} {%- endmacro %} {% macro when(n) -%} {%- endmacro %} {% macro steps(n) -%}
    {% for child in n.subagent.timeline %} {{ entry(child) }} {% endfor %}
{%- endmacro %} {% macro entry(n) -%}
  • {% if n.incomplete %}
    {{ when(n) }} {{ n.kind }} part of this entry has not arrived
    {% elif n.kind == 'thinking' %} {% set body = n.body if n.body is mapping else {} %} {% set text = body.text if body.text is string else '' %}
    {{ when(n) }} ⋯ thinking ({% if body.redacted %}redacted{% elif not text %}not shown{% else %}{{ tokens(text) }}{% endif %}) {% if text %} {{ long_body(text, n.key) }} {% endif %}
    {% elif n.kind == 'tool_call' or (n.kind == 'subagent' and n.orphan) %} {% set body = n.body if n.body is mapping else {} %} {% set input = body.input if body.input is mapping else {} %} {% set ns = namespace(arg='', text='') %} {% for value in input.values() %}{% if not ns.arg and (value is string or value is number) %}{% set ns.arg = value | string %}{% endif %}{% endfor %} {% if n.subagent %} {% set count = n.subagent.timeline | length %}
    {{ when(n) }} {{ body.name or 'Agent' }}{% if n.orphan %} (its call is not in the record){% elif input.description is string %} “{{ input.description | truncate(80) }}”{% endif %}{% if n.decision %} {{ verdict(n.decision) }}{% endif %} [{{ count }} step{{ '' if count == 1 else 's' }}] {% if input %}
    input {{ text_into(ns, input) }}{{ long_body(ns.text, n.key) }}
    {% endif %} {{ steps(n) }}
    {% else %} {% if n.result %}{{ text_into(ns, n.result.body) }}{% endif %}
    {{ when(n) }} {{ body.name or n.kind }}{% if ns.arg %} {{ ns.arg | truncate(60) }}{% endif %} {% if n.decision %}{{ verdict(n.decision) }}{% else %}—{% endif %}{% if n.result %} → {{ (ns.text.split('\n') | first | default('')) | truncate(80) }}{% endif %}
    {% if input %}
    input {{ text_into(ns, input) }}{{ long_body(ns.text, n.key) }}
    {% endif %} {% if n.result %}
    result {{ text_into(ns, n.result.body) }}{{ long_body(ns.text, n.result.key) }}
    {% endif %}
    {% endif %} {% elif n.body is not none %} {% set ns = namespace(text='') %} {{ text_into(ns, n.body) }}
    {{ when(n) }} {{ n.kind }}:{% if n.person and n.kind == 'prompt' %} {{ n.person }}{% endif %}
    {{ long_body(ns.text, n.key) }} {% else %}
    {{ when(n) }} {{ n.kind }}
    {% endif %}
  • {%- endmacro %} {% block main %} {% set first = namespace(prompt=none, ts=none, identity='', person='') %} {% for n in nodes %} {% if first.ts is none and n.ts %}{% set first.ts = n.ts %}{% endif %} {% if not first.identity and n.identity %}{% set first.identity = n.identity %}{% set first.person = n.person or '' %}{% endif %} {% if first.prompt is none and n.kind == 'prompt' and n.body is mapping and n.body.text is string and not n.body.is_meta %}{% set first.prompt = n.body.text %}{% endif %} {% endfor %}

    Sessions

    {% if first.ts %} {% endif %} {% if first.identity %} {{ source_label(first.identity, [first.person]) }} · {{ first.person or '—' }} {% endif %} {% if first.prompt %} “{{ first.prompt | truncate(160) }}” {% endif %} {{ session }}
    {% if not complete %}

    This session is incomplete: the record has not yet answered every entry it holds for it.

    {% endif %} {% if newer_href %}

    Entries arrived after this page was read. Read from the start

    {% endif %}
      {% for n in nodes %} {{ entry(n) }} {% endfor %}
    {% if next_href %} {% endif %} {% endblock %}