Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

fix(dashboard): deduplicate repeated savings metrics (#1804)

Rod Boev88f935a1eb52
diff --git a/headroom/dashboard/templates/dashboard.html b/headroom/dashboard/templates/dashboard.html
index 389bf03be..0caea0b62 100644
--- a/headroom/dashboard/templates/dashboard.html
+++ b/headroom/dashboard/templates/dashboard.html
@@ -433,7 +433,6 @@
<div>
<div class="text-xs text-gray-500 mb-1">Compression</div>
<div class="text-2xl font-light tabular-nums text-emerald-400" x-text="'$' + formatCurrency(stats.cost?.compression_savings_usd || 0)"></div>
- <div class="text-xs text-gray-500" x-text="formatNumber(stats.tokens?.proxy_compression_saved || 0) + ' proxy tokens removed'"></div>
</div>
<template x-if="(stats.cost?.cache_savings_usd || 0) > 0">
<div>
@@ -1079,18 +1078,10 @@
<div class="bg-surface rounded-lg p-4 border border-border">
<div class="text-sm font-medium mb-4 text-gray-300">Performance</div>
<div class="space-y-3">
- <div class="flex justify-between items-center">
- <span class="text-sm text-gray-400">Headroom Overhead</span>
- <span class="font-mono text-sm" x-text="(stats.overhead?.average_ms || 0).toFixed(0) + 'ms avg'"></span>
- </div>
<div class="flex justify-between items-center">
<span class="text-sm text-gray-400">Overhead Range</span>
<span class="font-mono text-sm" x-text="(stats.overhead?.min_ms || 0).toFixed(0) + ' - ' + (stats.overhead?.max_ms || 0).toFixed(0) + 'ms'"></span>
</div>
- <div class="flex justify-between items-center">
- <span class="text-sm text-gray-400">TTFB (upstream)</span>
- <span class="font-mono text-sm" x-text="((stats.ttfb?.average_ms || 0) / 1000).toFixed(2) + 's avg'"></span>
- </div>
<div class="flex justify-between items-center">
<span class="text-sm text-gray-400">TTFB Range</span>
<span class="font-mono text-sm" x-text="((stats.ttfb?.min_ms || 0) / 1000).toFixed(2) + ' - ' + ((stats.ttfb?.max_ms || 0) / 1000).toFixed(2) + 's'"></span>
diff --git a/tests/test_proxy_dashboard_stats_cache.py b/tests/test_proxy_dashboard_stats_cache.py
index ba0cde706..0a2569483 100644
--- a/tests/test_proxy_dashboard_stats_cache.py
+++ b/tests/test_proxy_dashboard_stats_cache.py
@@ -605,6 +605,17 @@ def test_dashboard_uses_cached_stats_and_lazy_history_feed_polling() -> None:
assert "cliFilteringLabel + ' Filtered (lifetime)'" in html
+def test_dashboard_session_metrics_do_not_repeat_proxy_tokens_without_new_context() -> None:
+ html = get_dashboard_html()
+
+ assert "proxy tokens removed" not in html
+ assert '<span class="text-sm text-gray-400">Headroom Overhead</span>' not in html
+ assert '<span class="text-sm text-gray-400">TTFB (upstream)</span>' not in html
+ assert "Overhead Range" in html
+ assert "TTFB Range" in html
+ assert "Proxy Removed" in html
+
+
def test_proxy_throughput_in_stats_endpoint(monkeypatch: pytest.MonkeyPatch) -> None:
"""Verify that the /stats endpoint includes a 'throughput' key in the response.