fix(ui): count completed runs as delivered on the workflows surfaces

The workflows page's per-workflow bar and its 'N of M' text, and the
workflow picker's percent on the new-task form, counted `merged` alone.
A workflow whose runs now end `completed` (a no-change build, a triage
that needed no code) therefore rendered zero delivery beside three
sibling surfaces that already counted both.

The count moves into ui/src/lib/delivered.ts, which GatePulseCard,
ThroughputTiles and TasksSummary now read too instead of keeping their
own copies of the arithmetic. The picker's label says delivered, not
merged: a run that ends completed is not merged.
This commit is contained in:
sam committed 2026-09-26 04:01:08 +10:00
1 parent d0fb41320c
commit 15efec696f
8 files changed
+114 -21

No files matched your search

+2 -3
View File
@@ -4,7 +4,8 @@ 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";
import { delivered } from "@/lib/delivered";
import { workflows } from "./state";
/** Sharer of runs: how much of the work that finished passed its gates. */
const stats = computed(() => workflows.value?.workflows ?? []);
@@ -13,8 +14,6 @@ const stats = computed(() => workflows.value?.workflows ?? []);
// 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(
+4 -3
View File
@@ -2,6 +2,7 @@
import { computed } from "vue";
import { StatStrip } from "@/components/ui/stat-strip";
import { delivered } from "@/lib/delivered";
import { compact } from "@/lib/format";
import { attentionStatusIds } from "@/lib/task-meta";
import { summary } from "./state";
@@ -11,9 +12,9 @@ import { summary } from "./state";
const counts = computed(() => summary.value?.statuses ?? {});
const tokensByDay = computed(() => summary.value?.tokens_by_day ?? []);
const used = computed(() => tokensByDay.value.reduce((a, d) => a + (d.tokens || 0), 0));
const done = computed(
() => (counts.value.merged || 0) + (counts.value.completed || 0) + (counts.value.pr_open || 0),
);
// Delivered work is out of archied's hands: merged, finished with no change to
// make (`completed`), or open in review.
const done = computed(() => delivered(counts.value) + (counts.value.pr_open || 0));
// "Needs you" is the server's grouping (attentionStatusIds), the same one the
// Tasks page's needs_you filter reads.
const attention = computed(() => {
+17
View File
@@ -0,0 +1,17 @@
/**
* The delivered count: work that finished and left archied's hands.
*
* A workflow can end a run `completed` instead of `merged` -- a no-change
* build, or a triage that needed no code -- so a surface that reads `merged`
* alone renders zero for exactly the runs that had nothing to merge. Every
* surface that reports delivered work counts both, through this one function.
*/
export interface DeliveredCounts {
merged?: number;
completed?: number;
}
/** delivered counts the runs that finished without needing a merge. */
export function delivered(counts: DeliveredCounts | null | undefined): number {
return (counts?.merged || 0) + (counts?.completed || 0);
}
+2 -1
View File
@@ -17,6 +17,7 @@ import {
import { Spinner } from "@/components/ui/spinner";
import { Textarea } from "@/components/ui/textarea";
import { api } from "@/lib/api";
import { delivered } from "@/lib/delivered";
import { useIdentitiesStore } from "@/stores/identities";
import type { WorkflowDefinition, WorkflowStats } from "@/workflows/workflow-rows";
@@ -119,7 +120,7 @@ async function submit() {
<span class="block truncate font-mono text-[13px] font-medium">{{ d.name || d.id }}</span>
<span class="block text-xs text-fg-subtle">
{{ statFor(d.id)?.runs || 0 }} runs<template v-if="statFor(d.id)?.runs">
· {{ Math.round(((statFor(d.id)?.merged || 0) / (statFor(d.id)?.runs || 1)) * 100) }}% merged</template
· {{ Math.round((delivered(statFor(d.id)) / (statFor(d.id)?.runs || 1)) * 100) }}% delivered</template
>
</span>
</RadioGroupItem>
+4 -8
View File
@@ -2,6 +2,7 @@
import { computed } from "vue";
import StatTile from "@/base/StatTile.vue";
import { delivered } from "@/lib/delivered";
import { attentionStatusIds } from "@/lib/task-meta";
import type { Task } from "./TaskRow.vue";
@@ -26,12 +27,7 @@ const working = computed(() => counts.value.running ?? 0);
// Delivered counts everything whose work is out of archied's hands: merged,
// in review, or finished with no change to make (completed, which is how a
// no-change build and a no-code triage end).
const delivered = computed(
() =>
(counts.value.merged ?? 0) +
(counts.value.completed ?? 0) +
(counts.value.pr_open ?? 0),
);
const done = computed(() => delivered(counts.value) + (counts.value.pr_open ?? 0));
// "Needs you" is the server's grouping, not a local pair of ids: the same set
// backs the ?status=needs_you filter, so the tile and the filter cannot drift.
@@ -68,10 +64,10 @@ const needsYou = computed(() => {
/>
<StatTile
label="Delivered"
:value="delivered"
:value="done"
:compare="
total
? `${Math.round((delivered / total) * 100)}% of all tasks`
? `${Math.round((done / total) * 100)}% of all tasks`
: 'No tasks yet'
"
/>
+6 -3
View File
@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button";
import { StatusPill } from "@/components/ui/status-pill";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { api } from "@/lib/api";
import { delivered } from "@/lib/delivered";
import { compact } from "@/lib/format";
import { cn } from "@/lib/utils";
import { statusLabel } from "@/lib/task-meta";
@@ -86,7 +87,9 @@ async function restoreShipped() {
if (await store.replace("workflow-definitions", cloneControlPlaneValue(shipped)))
selected.value = shipped.definitions[0]?.id ?? "";
}
const rate = (merged = 0, total = 0) => (total ? merged / total : 0);
// The share of a workflow's runs whose work is finished: merged, or ended
// with nothing to merge (a no-change build, a no-code triage -- `completed`).
const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total : 0);
</script>
<template>
@@ -116,9 +119,9 @@ const rate = (merged = 0, total = 0) => (total ? merged / total : 0);
<span class="mt-1.5 flex items-center gap-2 text-xs text-fg-subtle">
<span class="w-20 shrink-0">{{ row.runs || 0 }} runs</span>
<span class="h-1 flex-1 overflow-hidden rounded-full bg-secondary">
<span class="block h-full rounded-full bg-primary" :style="{ width: `${rate(row.merged, row.runs) * 100}%` }" />
<span class="block h-full rounded-full bg-primary" :style="{ width: `${rate(delivered(row), row.runs) * 100}%` }" />
</span>
<span class="w-16 shrink-0 text-right font-mono">{{ row.merged || 0 }} of {{ row.runs || 0 }}</span>
<span class="w-16 shrink-0 text-right font-mono">{{ delivered(row) }} of {{ row.runs || 0 }}</span>
</span>
</button>
</li>