{#- A task's comment thread, refetched on live events. Expects: t (the task), comments, optional error, doc_refs (board targets of document links) and wait_reason (why undelivered comments wait). The form that adds a comment lives outside it (_comment_form.html), so a draft survives. -#} {%- macro stamp(ts) -%}{%- endmacro -%}
{% if error %}{% endif %} {#- Comments on review steps and the replies to them live in the step's own thread (Review). #} {%- set ns = namespace(step=[]) %} {%- for c in comments %}{% if c.step_id or c.in_reply_to in ns.step %}{% set ns.step = ns.step + [c.id] %}{% endif %}{% endfor %} {%- set shown = comments|rejectattr("id", "in", ns.step)|list %} {% if ns.step %}

{{ ns.step|length }} comment{{ "s" if ns.step|length != 1 else "" }} on review steps: see the Review tab.

{% endif %} {% if shown %}
    {% for c in shown %} {%- set external = c.author_kind == "external" %}
  1. {#- A raw desktop id says nothing to the owner: an agent without a readable name is "Agent". #} {{ "You" if c.from_owner else ("External via " ~ c.author if external else ("Agent" if c.author.startswith("local_") else c.author)) }}
    {#- External text is shown as plain text, never rendered as markdown. #} {% if external %}

    {{ c.body_md }}

    {% else %}
    {{ c.body_md|markdown(doc_refs) }}
    {% endif %}

    {%- if c.to_agent %} sent {{ stamp(c.created_at) }} {%- if c.delivered_at %} · delivered {{ stamp(c.delivered_at) }} {%- else %} · not delivered yet{% if wait_reason %}: {{ wait_reason }}{% endif %}{% endif %} {%- if c.read_at %} · read {{ stamp(c.read_at) }}{% endif %} {%- else %} reply {{ stamp(c.created_at) }} {%- if not c.read_at %} · unread{% endif %} {%- endif %}

  2. {% endfor %}
{% if shown|rejectattr("to_agent")|selectattr("read_at", "none")|list %}
{% endif %} {% endif %}

{% if wait_reason %}A new comment waits: {{ wait_reason }}.{% else %}A new comment reaches {{ t.session_name }} through its hooks on its next prompt or tool call.{% endif %}