{% from "_macros.html" import icon %} {# What the model did before answering. Rendered both live (streamed as a whole block, like the reasoning and the answer) and from the stored message afterwards, so the sources behind an answer stay in the transcript rather than vanishing when the stream ends. EVERYTHING in here is third-party text and is untrusted, exactly as much as model output is -- a search provider's results, an administrator's HTTP tool relaying whatever it was pointed at, an MCP server's reply. Jinja autoescaping covers it. Two things are handled separately: the URL, because `is_linkable` is the only thing standing between a result carrying a javascript: URL and an anchor pointing at it, and `event.text`, which is rendered as preformatted text and deliberately NOT through services/markdown.py -- markdown is the one path allowed to emit HTML, and this is the last content that should be given it. `kind` says how to label the event. Rows written before it existed have none, so web_search reads as a search and everything else falls to the generic branch: an old notes_search event used to claim it had searched the web. What a tool is *called* is not decided here. `tool_label` and `tool_icon` are Jinja globals over services/tool_labels.py, which is the one table the status line and the approval card read too. It deliberately ignores an `event.label` it recognises the name of: rows already on disk carry the SSH profile's name, so a resolver that preferred the stored value would leave every existing transcript saying "homeserver" where it means "Bash". #} {# `message_id` and `step_index` place this block in the reply, and an id is emitted only when the caller gave one. That is not defensiveness: an id is what carries an *opened* block across a swap, and a caller with no message to key on would emit the same id in every bubble on the page, which is worse than emitting none. `_step.html` always passes one. `steps.js` records which of these are open before a swap and puts them back after. It works because the id is stable -- the step index comes from a mark, the marks are append-only, and the finished bubble emits exactly what the live one did, so a block opened at round three is still open after the `done` frame replaces the whole article. #} {% for event in tool_events %} {% set kind = event.kind or ('search' if event.name == 'web_search' else 'tool') %}
{{ icon(tool_icon(event), "icon--sm tool-activity__icon") }} {% if kind == 'search' %} {# Prose, not "Web search · mallorn". A search is the one thing here common enough to be worth a sentence. #} {% if event.status == "error" %} Web search failed {% elif event.query %} Searched the web for “{{ event.query }}” {% else %} Searched the web {% endif %} {% else %} {% set label = tool_label(event) %} {% if event.status == "error" %} {{ label }} failed {% else %} {{ label }} {% endif %} {% if event.query %} · {{ event.query }} {% endif %} {% endif %} {% if event.results %} · {{ event.results | length }} result{{ '' if event.results | length == 1 else 's' }} {% endif %} {% if event.edited %} {# Corrected on the approval card before it ran, so what is shown above is the reader's command and not the model's. Said out loud rather than left to be inferred: attributing somebody's own typing to a model is the same misattribution as the other way round, and a transcript read back a week later has nothing else to go on. #} edited by you {% endif %} {% if event.why %} {# What the model said this call was for. In the summary rather than the body because the body is collapsed: in Auto mode nothing stops for approval, so without this a reader watches a list of commands with no account of what any of them is for until the reply ends. Model text, escaped like everything else here, and styled as a quieter second line so it reads as the model's account rather than ours. #} {{ event.why }} {% endif %} {{ icon("chevron-down", "icon--sm reasoning__chevron") }}
{% if event.detail and kind != 'search' %}

{{ event.detail }}

{% endif %} {% if event.error %}

{{ event.error }}

{% elif not event.results and not event.text and not event.image %}

Nothing was found.

{% endif %} {% if event.image and event.image.id %} {# What was drawn, in the block that drew it. The picture is also an attachment on this bubble, so the reader sees it without opening anything; this copy is what makes the block make sense on its own once it is expanded, beside the seed and the attempts. The address is built here from an id and is never taken from the event. That is the same rule the result links a few lines down follow, and it matters more here: an event is a dict a runner wrote, and a `src` taken from one would be a model-supplied URL fetched by the reader's browser. `/api/files/{id}/content` is owner-checked on the way out. #} The generated image {% endif %} {% if event.text %}
{{ event.text }}
{% endif %} {% if event.diff %} {# What a write or an update changed, in the shape everybody already reads a change in. Every line is text off somebody's machine and is escaped exactly like the rest of this file. The classification reads the first character and never interprets the rest — a line is coloured, never parsed. Header lines are checked BEFORE the bare +/- ones, or `+++ b/x.py` renders as an addition and `--- a/x.py` as a removal at the top of every diff. The test is against the `a/` and `b/` prefixes rather than against three dashes, because a removed line whose own text begins with `--` produces exactly three dashes too. No whitespace between the spans: they are `display: block` inside a
,
      so a newline between two of them is a blank line on screen.
    #}
    

      {%- for line in event.diff.split("\n") -%}
        {%- if line.startswith('@@') or line.startswith('--- a/')
               or line.startswith('+++ b/') or line.startswith('diff ') -%}
          {%- set cls = 'meta' -%}
        {%- elif line.startswith('+') -%}
          {%- set cls = 'add' -%}
        {%- elif line.startswith('-') -%}
          {%- set cls = 'del' -%}
        {%- else -%}
          {%- set cls = 'ctx' -%}
        {%- endif -%}
        {{ line }}
      {%- endfor -%}
    
{% endif %} {% for result in event.results %}
{% set scheme = (result.url or "").split(":")[0] | lower %} {% if scheme in ("http", "https") %} {{ result.title }} {% else %} {# Not a link. A result is third-party text and its URL is not trusted to be safe to click. #} {{ result.title }} {% endif %} {{ result.host }} {% if result.snippet %}

{{ result.snippet }}

{% endif %}
{% endfor %}
{% endfor %}