{#- One message of a chat, a message of the user or an answer to one, from `message`, `chat`, `agent_names`, `talks`, `steps`, `model_names` and `access`. `talks` is by answer id: the answers to what the agent of the answer asked other agents, each with its question. `steps` is by answer id: what the agent of each answer still being written has done so far. `model_names` is by agent id: the name of each model the agent's CLI offers now, by its id; an answer written with a model that is not among them shows the id. `access` is the user's level in the project: only `full` gets the button that stops an agent. A message of the user also needs `writers`: by answer id, the id of the agent that wrote it. The chat page includes it. An answer an agent still writes fetches itself again every second, until the server gives it without the `hx-` attributes. While the chat has no title the fetch says so: the first one after the agent named the chat then tells the page to show the title. Under an answer that ended are the files that changed while its agent wrote. The text of an agent is shown as Markdown; a relative link in it leads to a file of the project, from the project folder. Safe: the filter shows its raw HTML as text. -#} {#- What an answer to the user and an answer to a question both show: the agent, the text, and the steps so far. -#} {% macro answer_parts(answer) %}
{{ agent_names[answer.agent_id] }}{% if answer.model %} {{ model_names[answer.agent_id].get(answer.model, answer.model) }}{% if answer.effort %} · {{ answer.effort }}{% endif %}{% endif %}
{% if answer.text is not none %}
{{ answer.text | markdown(chat.project_slug) | safe }}
{% endif %} {% if answer.status == "writing" %} {% for step in steps[answer.id] %} {% if step.tool %}
{{ step.tool }}{% if not step.done %}…{% endif %} {{ step.text }}
{% else %}
{{ step.text | markdown(chat.project_slug) | safe }}
{% endif %} {% endfor %} {% endif %} {% endmacro %} {% set writing = message.kind == "answer" and message.status == "writing" %}
  • {% if message.kind == "user" %} {% if message.added_to_id %}
    added while {{ agent_names[writers[message.added_to_id]] }} worked
    {% endif %}
    {{ message.text }}
    {# A link leads nowhere once an agent has moved the file into the project. #} {% for path in message.attachments %}
    {{ path.rsplit("/", 1)[-1] }}
    {% endfor %} {% else %} {{ answer_parts(message) }} {% if talks[message.id] %} {# Open while the agent writes: the answer is drawn anew every second, and a fold the user opened would close. #}
    Talk with other agents {% for part in talks[message.id] %}
    {{ agent_names[message.agent_id] }} asked
    {{ part.question | markdown(chat.project_slug) | safe }}
    {{ answer_parts(part) }} {% if part.status == "writing" %}
    Writing… {{ part.created_at | elapsed }}
    {% elif part.error %}
    {{ part.error }}
    {% endif %} {% endfor %}
    {% endif %} {% if writing %}
    Writing… {{ message.created_at | elapsed }}{% if access == "full" %} {% endif %}
    {% elif message.error %}
    {{ message.error }}
    {% endif %} {% if message.changed_files %} {# A long list starts folded. A link leads nowhere once a later answer has moved or deleted the file. #} {% set count = message.changed_files | length %}
    {{ count }} file{{ "s" if count > 1 }} changed
    {% endif %} {% endif %}