From e879702588b131c012831171b08c6265bac4da3c Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Tue, 25 Aug 2026 14:46:26 +0300 Subject: [PATCH 1/4] fix(webui): make the Activity and Usage numbers say what they mean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Audit findings F2, F5, F22, F23, F25, F26, F27 and the Activity/Usage part of F36 (#1046). Builds on #1048's storage.CountsAsCall contract. F2 — the status tiles are a partition again. ActivitySummaryResponse gains other_count: the rows whose status is outside the tool-call vocabulary (a quarantine change stores its action there, a policy decision its verdict). They were in the total and in no tile, so the row read 15+4+0+0 under a 42. The tile list now lives in one pure function, an "Other / internal" tile renders the residual, it filters like every other tile, and Go + Vitest tests assert the sum. F5 — repeats fold. Consecutive rows that agree on everything the collapsed line prints become one expandable run. Status is part of the run identity, so a run can never mix outcomes and "echo x12" can never hide the one call that failed; the sensitive-data flag and the code_execution parent link are in the identity for the same reason. Folding is on by default, remembered, and off whenever the table is sorted by something other than time. Successful rows no longer print "Success" at all — the word stays for screen readers only, so the marked rows in the column are exactly the ones needing a human. F22 — the usage charts stop inventing tools and stop quantizing latency. Names that never completed a call are excluded from "Calls per tool" and "Token sinks" (named in a footnote, still charted under errors, and counted the same way by the "active tools" tile). latencyBucketBoundsMs gains sub-10ms resolution, which is where local MCP servers live and where the old first bucket had none; Percentile now reports whether it hit the unbounded overflow bucket, so a figure renders as a bound ("<= 5 ms") or a floor ("> 10 s") and never as a stopwatch reading. Every chart axis says what it measures. F23 — the tokens-saved headline explains itself. It is a structural estimate over the current tool catalog, so it correctly does not move per call; the label said otherwise. Relabelled per-request, given the derivation on hover, and the Dashboard chip now opens the breakdown that computes it. F25 — a security_scan drawer shows its verdict and findings by severity and offers the server and the Security page. A session id is now a control: filter this log, or open Sessions. F26 — the Intent column paints the operation word beside the glyph, the Sensitive badge carries an accessible name, and the filter panel holds a visible legend for both. F27 — the Connected tile names its denominator ("2 of 3 enabled online"): a switched-off server is not an outage. serverCount.disabled is now asked directly and excludes quarantined servers, so the Dashboard rail stops reporting one server as two problems. F36 — the Sessions "View Activity" button stops clipping its label. --- .../src/components/usage/CallHistogram.vue | 50 +- .../src/components/usage/ErrorRateChart.vue | 43 +- .../components/usage/ResponseSizeRanking.vue | 17 +- frontend/src/stores/servers.ts | 7 + frontend/src/types/api.ts | 11 + frontend/src/utils/activity.ts | 334 ++++++++++- frontend/src/utils/usageFormat.ts | 68 +++ frontend/src/views/Activity.vue | 553 +++++++++++++++--- frontend/src/views/Dashboard.vue | 73 ++- frontend/src/views/Servers.vue | 22 +- frontend/src/views/Sessions.vue | 6 +- frontend/src/views/Usage.vue | 56 +- .../tests/unit/activity-run-grouping.spec.ts | 167 ++++++ .../unit/activity-status-partition.spec.ts | 97 +++ .../unit/activity-table-scanning.spec.ts | 254 ++++++++ .../tests/unit/usage-tool-resolution.spec.ts | 77 +++ internal/contracts/activity.go | 13 + internal/contracts/types.go | 37 +- internal/httpapi/activity.go | 18 +- .../activity_summary_partition_test.go | 42 ++ internal/runtime/usage_aggregate.go | 53 +- internal/runtime/usage_aggregate_test.go | 46 +- oas/docs.go | 2 +- oas/swagger.yaml | 21 + 24 files changed, 1890 insertions(+), 177 deletions(-) create mode 100644 frontend/tests/unit/activity-run-grouping.spec.ts create mode 100644 frontend/tests/unit/activity-status-partition.spec.ts create mode 100644 frontend/tests/unit/activity-table-scanning.spec.ts create mode 100644 frontend/tests/unit/usage-tool-resolution.spec.ts create mode 100644 internal/httpapi/activity_summary_partition_test.go diff --git a/frontend/src/components/usage/CallHistogram.vue b/frontend/src/components/usage/CallHistogram.vue index 8cb0de74c..f72efca59 100644 --- a/frontend/src/components/usage/CallHistogram.vue +++ b/frontend/src/components/usage/CallHistogram.vue @@ -2,14 +2,28 @@

Calls per tool

- {{ tools.length }} tool{{ tools.length === 1 ? '' : 's' }} + {{ charted.length }} tool{{ charted.length === 1 ? '' : 's' }}
-
- No tool calls in this window. +
+ No completed tool calls in this window.
+ +

+ {{ unresolved.length }} name{{ unresolved.length === 1 ? '' : 's' }} never completed a call + and {{ unresolved.length === 1 ? 'is' : 'are' }} excluded here — see “Errors & latency”. +

@@ -26,22 +40,33 @@ import { } from 'chart.js' import type { ChartOptions } from 'chart.js' import type { UsageToolStat } from '@/types' -import { formatNumber, toolLabel, paletteColor } from '@/utils/usageFormat' +import { formatNumber, partitionUsageTools, toolLabel, paletteColor } from '@/utils/usageFormat' ChartJS.register(BarElement, CategoryScale, LinearScale, Tooltip, Legend) const props = defineProps<{ tools: UsageToolStat[] }>() +// This chart answers "what do my agents use". A name that has never once +// completed a call answers nothing about use — it is a typo the agent made or a +// server that was never reachable, and charting it invents a tool catalog out +// of failures (audit finding F22, #1046). +const split = computed(() => partitionUsageTools(props.tools)) +const charted = computed(() => split.value.completed) +const unresolved = computed(() => split.value.unresolved) +const unresolvedLabels = computed(() => + unresolved.value.map(t => toolLabel(t.server, t.tool)).join(', ') +) + // Horizontal bars so long server:tool labels stay readable on high cardinality. -const chartHeight = computed(() => `${Math.max(160, props.tools.length * 28 + 40)}px`) +const chartHeight = computed(() => `${Math.max(160, charted.value.length * 28 + 40)}px`) const chartData = computed(() => ({ - labels: props.tools.map(t => toolLabel(t.server, t.tool)), + labels: charted.value.map(t => toolLabel(t.server, t.tool)), datasets: [ { label: 'Calls', - data: props.tools.map(t => t.calls), - backgroundColor: props.tools.map((_, i) => paletteColor(i)), + data: charted.value.map(t => t.calls), + backgroundColor: charted.value.map((_, i) => paletteColor(i)), borderWidth: 0, borderRadius: 3, }, @@ -57,7 +82,7 @@ const chartOptions = computed>(() => ({ tooltip: { callbacks: { label: (ctx) => { - const t = props.tools[ctx.dataIndex] + const t = charted.value[ctx.dataIndex] if (!t) return '' const errPart = t.errors > 0 ? ` · ${formatNumber(t.errors)} errors` : '' return `${formatNumber(t.calls)} calls${errPart}` @@ -66,7 +91,12 @@ const chartOptions = computed>(() => ({ }, }, scales: { - x: { beginAtZero: true, ticks: { callback: (v) => formatNumber(Number(v)) } }, + // Say what the bars measure. An unlabelled axis is guesswork (F22, #1046). + x: { + beginAtZero: true, + title: { display: true, text: 'Calls (cumulative)' }, + ticks: { callback: (v) => formatNumber(Number(v)) }, + }, y: { ticks: { autoSkip: false, font: { size: 11 } } }, }, })) diff --git a/frontend/src/components/usage/ErrorRateChart.vue b/frontend/src/components/usage/ErrorRateChart.vue index 0637fa0ad..b8052547f 100644 --- a/frontend/src/components/usage/ErrorRateChart.vue +++ b/frontend/src/components/usage/ErrorRateChart.vue @@ -5,26 +5,44 @@ No tool calls in this window.