{% extends "server/base.html" %} {% import "activity/macros.html" as m with context %} {% block root %} class="goods-page"{% endblock %} {% block title %}{{ t.text("activity.stall.title") }}{% endblock %} {% block top %}{% endblock %} {% block head %}{% endblock %} {% block body %} {# the agents in a computer's stall: a line each with its lantern, its name, the logos of its channels and runtimes and how it is - at work and where for how long, idle since when and what it last did, or its computer away - beside the turns of its last seven days #}
{% for agent in agents %} {% set turn = running.get(agent.id) %} {% set last = latest.get(agent.id) %} {% set state = "off" if not agent.online else "work" if turn else "fail" if agent.activity and agent.activity.state in ("failed", "blocked") else "on" %}
{{ agent.name }}{% for kind in (agent.config.channel | map(attribute="kind") | unique) %}{{ m.logo(kind) }}{% endfor %}{% for kind in (agent.config.harness | map(attribute="kind") | unique) %}{{ m.logo(kind) }}{% endfor %}
{% if not agent.online %}
{{ t.text("activity.stall.away") }}
{% elif turn %}
{{ t.text("activity.live.title") }} {{ m.conversation(names.get(turn.thread_id)) }} · {{ (now_ms - turn.started_ms) | duration }}{{ turn.started_ms | since }}
{% elif last and last.name in ("channel.outbound.sent", "channel.outbound.partial", "channel.outbound.queued") %} {% set asked = messages.get((agent.id, last.metadata.get("reply_to_message_id"))) %}
{{ t.text("activity.idle") }} · {{ last.at_ms | ago }}{{ t.text("activity.stall.in", {"where": m.conversation(names.get(last.thread_id)) | striptags}) }}{{ t.text("activity.stall.replied_to" if asked else "activity.stall.replied", {"who": (m.sender(asked) | striptags) if asked else ""}) }}
{% elif last %}
{{ t.text("activity.idle") }} · {{ last.at_ms | ago }}
{% else %}
{{ t.text("activity.idle") }}
{% endif %}
{# the turns of each six hours of the last seven days, against the busiest #} {% set counts = spark[agent.id] %} {% set top = [counts | max, 1] | max %} {% set points = [] %} {% for count in counts %}{% set _ = points.append(("%.1f %.1f" | format(loop.index0 * 84 / (counts | length - 1), 24 - count / top * 20))) %}{% endfor %} {% set line = "M" ~ points | join(" L") %}
{% endfor %}
{% endblock %}