{# Render a potentially long text body with an Alpine-driven collapse wrapper. When ``needs_collapse`` is false the body renders as a plain
; when
   true, a single 
 toggles the ``msg-text-clamp`` class and a meta/banner
   line exposes line + char counts. ``extra_class`` appends modifiers like
   ``msg-text-human`` / ``msg-text-error``. Inner Alpine scope uses
   ``expanded`` (not ``open``) to avoid shadowing the outer tool-call scope. #}
{% macro clamp_body(text, needs_collapse, line_count, char_count, extra_class='') %}
    {% if needs_collapse %}
    
{{ text }}
{{ line_count }} lines · {{ char_count }} chars — click to expand
{% else %}
{{ text }}
{% endif %} {% endmacro %}

Messages ({{ messages|length }})

{% for msg in messages %} {%- set show_class = 'kind-' ~ msg.kind -%}
{% if msg.kind == 'human_prompt' %}
you {{ msg.timestamp }}
{{ clamp_body(msg.text, msg.text_needs_collapse, msg.text_line_count, msg.text_char_count, 'msg-text-human') }} {% elif msg.kind == 'subagent_prompt' %}
prompt to subagent subagent {{ msg.timestamp }}
{{ clamp_body(msg.text, msg.text_needs_collapse, msg.text_line_count, msg.text_char_count) }} {% elif msg.kind == 'slash_command' %}
{{ msg.command_label }}
{% elif msg.kind == 'agent_text' %}
assistant{% if msg.is_sidechain %} subagent{% endif %}{% if msg.tokens_summary %} {{ msg.tokens_summary }}{% endif %} {{ msg.timestamp }}
{{ clamp_body(msg.text, msg.text_needs_collapse, msg.text_line_count, msg.text_char_count) }} {% elif msg.kind == 'agent_thinking' %}
thinking{% if msg.is_sidechain %} subagent{% endif %}{% if msg.tokens_summary %} {{ msg.tokens_summary }}{% endif %} {{ msg.timestamp }}
{% if msg.thinking_has_more %}
{{ msg.thinking_preview }}
{% else %}
{{ msg.thinking_text }}
{% endif %} {% elif msg.kind == 'agent_tool_call' %}
{{ msg.tool_name }} {% if msg.tool_hint %}{{ msg.tool_hint }}{% endif %} {% if msg.is_error %}error{% endif %} {% if msg.exec_time %}{{ msg.exec_time }}{% endif %} {% if msg.is_sidechain %}subagent{% endif %} {{ msg.timestamp }}
{{ clamp_body(msg.tool_input, msg.tool_input_needs_collapse, msg.tool_input_line_count, msg.tool_input_char_count) }} {% if msg.tool_result %} {{ clamp_body(msg.tool_result, msg.tool_result_needs_collapse, msg.tool_result_line_count, msg.tool_result_char_count, 'msg-text-error' if msg.is_error else '') }} {% endif %}
{% endif %}
{% endfor %}