{% import "chats/macros.html" as m with context %} {# messages, a day at a time: who said it - a person, this conversation's agent in amber, another agent in purple - when, and what, Markdown as it reads; pictures that came in shown, other files by name; a reminder or other notice on a line of its own; a reply of the agent with what its turn did before it #} {% set seen = namespace(day=none) %} {% for message in messages %} {% set key, label = message.at_ms | day %} {% if key != seen.day %}{{ label }}{% set seen.day = key %}{% endif %} {% if message.system_message_kind %}
{{ m.icon("alarm-clock") }}{{ message.body }}{{ message.at_ms | minute }}
{% else %} {% set mine = message.direction == "outbound" %} {% set name = agent.name if mine else (m.who(message.sender) | trim) %} {% set role = "agent" if mine else ("peer" if message.sender_kind == "agent" else "human") %} {% set found = receipts.get(message.message_id) if mine else none %}
{{ name[:1] | upper }}
{{ name }}{{ t.text("chats.tag." ~ ("agent" if role != "human" else "human")) }}{{ message.at_ms | minute }}
{% if found and found.calls.total %}{{ m.icon("terminal") }}{{ m.receipt(found) }}{{ m.icon("chevron-right") }}{% endif %} {% for item in message.attachments %} {% if item.attachment_id and item.state == "ready" and (item.media_type or "").startswith("image/") %}
{{ item.name }}
{{ m.icon("image") }}{{ item.name }}{% if item.size_bytes is not none %}{{ item.size_bytes | size }}{% endif %}
{% else %}
{{ m.icon("file") }}{{ item.name }}{% if item.size_bytes is not none %}{{ item.size_bytes | size }}{% endif %}
{% endif %} {% endfor %} {% if message.body %}
{{ message.body | markdown }}
{% endif %}
{% endif %} {% endfor %}