Files
archie/ui/src/dashboard/GatePulseCard.vue
T
sam 36b25f78cf feat(taskstate): count completed runs in the per-workflow stats
The transition table moved the no-change outcomes to StatusCompleted, so a
run that opens no pull request now ends in a status the per-workflow stats
did not count at all: it was not merged, not in review, not parked, and the
workflows page would have shown it as a run that went nowhere. The count
travels the whole State Store path, since every dashboard consumer reads it
through the gRPC client rather than the local store.

- WorkflowStats filters `completed` beside merged and pr_open; the SQL is
  the count, so a wrong filter reads as zero rather than failing, and
  TestWorkflowStatsCountsCompletedRuns holds it against a real store.
- storecontract.WorkflowStat gains Completed (json "completed"), the proto
  message gains field 9, and workflowStatProto/workflowStatValue carry it;
  TestWorkflowStatProtoCarriesEveryField round-trips every field by name.
- The gateway's chat task report names the status.
- The dashboard counts a completed run as delivered in GatePulseCard's
  totals and badge numerator, and the WorkflowStat/WorkflowStats/WorkflowRow
  interfaces carry the field.
- TestOutcomeSitesAreTransitionsFromRunning is the guard that keeps the
  producer and the table agreeing: it re-reads this package's tc.Outcome
  assignment sites from source and requires each status to be one
  internal/taskstate allows from running, so a new or moved site has to be
  adjudicated against the table instead of discovered on a live run.
2026-09-26 04:01:08 +10:00

86 lines
2.8 KiB
Vue

<script setup lang="ts">
import { computed } from "vue";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { workflows, type WorkflowStat } from "./state";
/** Sharer of runs: how much of the work that finished passed its gates. */
const stats = computed(() => workflows.value?.workflows ?? []);
// A run that finished without opening a pull request (a no-change build, a
// triage that needed no code) is delivered like a merge or a PR in review, so
// both totals count it: the pass rate would otherwise read every `completed`
// row as a failed gate.
const delivered = (w: WorkflowStat) => (w.merged || 0) + (w.completed || 0);
const totals = computed(() => ({
runs: stats.value.reduce((a, w) => a + (w.runs || 0), 0),
merged: stats.value.reduce(
(a, w) => a + delivered(w) + (w.pr_open || 0),
0,
),
}));
const pct = computed(() => {
if (!totals.value.runs) return 0;
return Math.round((totals.value.merged / totals.value.runs) * 100);
});
</script>
<template>
<Card v-if="workflows">
<CardHeader>
<CardTitle>Quality gates</CardTitle>
</CardHeader>
<CardContent>
<Empty v-if="!totals.runs">
<EmptyHeader>
<EmptyTitle>No completed runs yet</EmptyTitle>
</EmptyHeader>
</Empty>
<template v-else>
<!--
Two sections, read left to right: the rate on its own, and the
per-workflow counts that explain it. Parked tasks are not listed
here -- Throughput's Needs-you tile already speaks for them, from
the statuses themselves.
-->
<div
class="grid grid-cols-1 gap-6 md:grid-cols-[auto_minmax(0,1fr)]"
>
<div class="flex flex-col justify-center">
<span class="text-3xl font-semibold">{{ pct }}%</span>
<span class="text-xs text-fg-muted"
>pass rate · {{ totals.runs }} runs</span
>
</div>
<ul class="flex flex-col">
<li
v-for="(w, i) in stats.slice(0, 3)"
:key="i"
class="flex items-center justify-between gap-3 border-b border-hairline py-1.5 text-sm last:border-b-0"
>
<span class="truncate text-fg-muted">{{
w.workflow || "workflow"
}}</span>
<Badge
:variant="
delivered(w) === (w.runs || 0)
? 'ok'
: (w.parked || 0) > 0
? 'warn'
: 'info'
"
>
{{ delivered(w) }}/{{ w.runs || 0 }}
</Badge>
</li>
</ul>
</div>
</template>
</CardContent>
</Card>
</template>