{#- The polled region of /tokens (#refresh-region): htmx re-fetches the view every 5s and the alpine-morph extension morphs the fresh fragment over the region in place. The route renders THIS template alone on an HX-Request (a poll is a cheap region render, never a full page). There is no filter form here, so the view's current params are baked into the region's hx-get URL — each poll re-requests exactly the slice the page rendered. -#} {% import "_links.html" as links with context %} {% import "_table.html" as tables with context %} {% import "_cards.html" as cards with context %} {%- set token_q = {} %} {%- if window != "all" %}{% set _ = token_q.update({'window': window}) %}{% endif %}
{#- FR-002: the label names the mode that produced these numbers; uncalibrated means the window had no usable stored-summary sample, so the chars/token heuristic divisor stood in. -#}

Estimation mode: {{ tools.token_mode }}{% if tools.calibrated %} — calibrated at ~{{ tools.chars_per_token }} chars/token from this window's stored summaries{% elif 'heuristic' not in tools.token_mode %} — uncalibrated for this window; estimates use the {{ tools.chars_per_token }} chars/token heuristic divisor{% endif %}.

{% include "window_control.html" %} {#- FR-005: exports ride the view's current filters (the selected store rides links.url). -#} {%- set export_q = {} %} {%- if window != "all" %}{% set _ = export_q.update({'window': window}) %}{% endif %}

Export: CSV JSON

{% if tools %} {{ cards.stat_row([ {"value": tools | length, "label": "tools"}, {"value": tools | sum(attribute='calls'), "label": "calls"}, {"value": "~" ~ (tools | sum(attribute='total_tokens')), "label": "est. tokens total"}, ]) }} {% call tables.table(['Tool', 'Calls', 'Est. req tokens', 'Est. resp tokens', 'Total est. tokens', 'Mean est. tokens', 'Truncated calls', 'Chars cut']) %} {% for t in tools %} {{ links.view_link('history', 'tool', t.tool_name, window) }} {{ t.calls }} ~{{ t.est_req_tokens }} ~{{ t.est_resp_tokens }} ~{{ t.total_tokens }} ~{{ t.mean_tokens | mean }} {#- FR-003: unknown (no recorded truncation evidence) is not zero. -#} {% if t.truncated_calls is none %}unknown{% else %}{{ t.truncated_calls }}{% endif %} {% if t.truncated_chars is none %}—{% else %}{{ t.truncated_chars }}{% endif %} {% endfor %} {% endcall %} {% else %} {{ tables.empty_state('No tool calls recorded yet.') }} {% endif %}