{% 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". #} {% 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 %} {{ 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 %}

Nothing was found.

{% endif %} {% if event.text %}
{{ event.text }}
{% 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 %}