{#- The session page's rows and controls, shared by the page and its fragments. -#} {#- A past moment, ticking (app.js) from data-since-ms; its title is the local time. -#} {% macro moment(m, cls="") -%} {{ m.text }} {%- endmacro %} {#- A block: what it waits on, then how long it has waited (open) or how it closed. -#} {% macro block_row(b) -%}
  • {{ b.what }} {% if b.scope %}In subagent {{ b.scope }}{% endif %} {% if b.is_open %} Waiting for{{ moment(b.opened, "block__wait") }} {% else %} {{ b.close }} Waited {{ b.waited }} Closed {{ moment(b.closed) }} ago {% endif %}
  • {%- endmacro %} {#- An agent of the tree, indented by its depth (a class per depth, no inline style). -#} {% macro agent_row(a) -%}
  • {% if a.agent_type %}{{ a.agent_type }}{% else %}Unknown type{% endif %} {{ a.short_id }} {% if a.background %}Background{% endif %} {% if a.internal %}Internal{% endif %}
    {{ a.status_text }} {% if a.running and a.started %} Started {{ moment(a.started) }} ago {% else %} {% if a.ran %}Ran {{ a.ran }}{% endif %} {% if a.stopped %}Stopped {{ moment(a.stopped) }} ago{% endif %} {% endif %} {% if a.launched_by %}Launched by {{ a.launched_by }}{% endif %}
  • {%- endmacro %} {#- A hook event: its number, when it came, its name and its stored metadata. -#} {% macro event_row(e) -%}
  • Event {{ e.seq }} {{ e.name }} {{ moment(e.at) }} ago {% if e.details %}
    {% for d in e.details %}
    {{ d.label }}
    {% if d.mono %}{{ d.value }}{% else %}{{ d.value }}{% endif %}
    {% endfor %}
    {% endif %}
  • {%- endmacro %} {#- A "Show older" control: appends the next page to target; a fragment replaces it out of band with the control for the page after, or with an empty one at the end. -#} {% macro more_control(id, more, target, label, oob=False) -%}
    {% if more.href %} {% endif %}
    {%- endmacro %} {#- The timeline's tail: on ccobs:changed (live updates) it fetches the events after its cursor and replaces itself; "load" fetches at once when more than a page was new. A trigger during a request replaces it (hx-sync), so the last change of a burst is fetched; the cursor of the element that asked keeps the rows from repeating. -#} {% macro tail_element(tail) -%}
    {%- endmacro %} {#- The session header; out of band in the live fragment. -#} {% macro session_head(head, oob=False) -%}

    {% if head.project %}{{ head.project }}{% else %}Unknown project{% endif %}

    {{ head.short_id }}
    {% if head.path %}

    {{ head.path }}

    {% endif %}
    {{ head.state_label }} {% if head.doing %}{{ head.doing }}{% endif %} {% if head.waiting %}Waiting for{{ moment(head.waiting, "session-head__wait") }}{% endif %} {% if head.error_code %}Last error {{ head.error_code }}{% endif %}
    Started
    {{ moment(head.started) }} ago
    Last event
    {{ moment(head.last_event) }} ago
    {% if head.ended %}
    Ended
    {{ moment(head.ended) }} ago
    {% endif %}
    Session ID
    {{ head.session_id }}
    {%- endmacro %} {#- The session's links to Grafana, each in a new tab: its events in Explore on Loki, its tokens and cost in Explore on Prometheus, and the overview dashboard, over the session's range. Outside the header, so the live refresh leaves them alone. -#} {% macro grafana_links(links) -%} {%- endmacro %} {#- The blocks the live refresh replaces: the heading, every open block, and the closed ones from the page's boundary up. Older pages go to #closed-blocks-older, outside. -#} {% macro blocks_region(blocks, oob=False) -%}

    Blocks {{ blocks.total }}

    {% if blocks.open %}

    Waiting on you now

      {% for b in blocks.open %} {{ block_row(b) }} {% endfor %}
    {% endif %} {% if blocks.closed %}

    Closed, newest first

      {% for b in blocks.closed %} {{ block_row(b) }} {% endfor %}
    {% endif %} {% if not blocks.open and not blocks.closed %}

    No blocks: this session never waited on you.

    {% endif %}
    {%- endmacro %} {#- The agents the live refresh replaces: the heading and the tree of every running agent and the stopped ones from the page's boundary up. Older pages go to #agents-older. -#} {% macro agents_region(agents, oob=False) -%}

    Agents {{ agents.total }}

    {% if agents.rows %}

    Main thread

      {% for a in agents.rows %} {{ agent_row(a) }} {% endfor %}
    {% else %}

    No subagents ran in this session.

    {% endif %}
    {%- endmacro %} {#- An older list, empty until a "Show older" page lands in it; out of band (emptied) when the live refresh starts its window over. -#} {% macro older_list(id, cls, oob=False) -%}
      {%- endmacro %} {#- The live refresh: on ccobs:changed it fetches the header, blocks and agents and replaces itself; the URL keeps the page's boundaries and time (see ui.py). -#} {% macro live_element(live) -%} {%- endmacro %}