{% endif %}
{% if hidden %}
{% endif %}
{% set ns = namespace(last_role=None) %}
{% for b in blocks %}
{% if b.kind == "message" %}
{% set t = b.turn %}
{% set same_as_prev = (ns.last_role == t.role) %}
{% set lc = (t.text or "").count("\n") + 1 %}
{% set cc = (t.text or "")|length %}
{% set long = lc > long_lines or cc > long_chars %}
{% set label = (lc ~ " lines") if lc > 10 else (cc ~ " chars") %}
{% if not same_as_prev and t.meta.ts %}
{% endif %}
{{ t.text }}
{% if long %}
{% endif %}
{% set ns.last_role = t.role %}
{% else %}
{% set names = b.turns | map(attribute='meta.name') | select | list | unique | list %}
{% set calls = b.turns | length %}
tools{{ calls }}
{% if names %}{{ names | join(', ') }}{% endif %}
{% for t in b.turns %}
{% if t.role == "tool_use" %}
→ {{ t.meta.name or "?" }}