Files
archie/ui/src/dashboard/GatePulseCard.vue
T
sam 5e1e365c05 feat(webui): events counts, YAML reading, log rows and dashboard filters
Four findings from the ui-redesign verification pass, each with the module that
owns the rule and the test that pins it.

- events: the three-step strip's and the tab chips' counts move out of the SFC
  into events/counts.ts -- one read per step, an unreadable count stays blank
  rather than reading as zero (events-counts.test.ts).
- workflows: workflows/workflow-yaml.ts reads the editor's YAML with a real
  parser (the yaml package, not a line scanner) to drive the read-only Steps
  preview and a live validity indicator; the editor gains a line-number gutter
  and light syntax colouring behind the textarea. Step types and their settings
  are not served to the dashboard, so those remain the server's to check on
  save, and a save it refuses still reports its own reason.
- tasks: an ERROR log row is a block rather than only red text (lib/log.ts), the
  log pane ends with "End of attempt N - M lines", and the task head offers
  Archive when the server's own action list offers it (task-actions.ts, and
  TaskRowActions' new `only` narrows the list without inventing a control).
- dashboard: the live activity feed gains the All/Tasks/System filter
  (activity-filter.ts) and every quality-gate row gains a pass bar
  (pass-bar.ts) that is red when the gate is failing.

ui/dist regenerated; ui/package.json carries yaml ^2.9.1.
2026-09-30 11:41:33 +10:00

98 lines
3.5 KiB
Vue

<script setup lang="ts">
import { computed } from "vue";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { delivered } from "@/lib/delivered";
import { STATUS_FILL } from "@/lib/status";
import { passBar } from "./pass-bar";
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 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);
});
/** One row's bar: the share of that gate's runs which got through, and whether
* the gate is failing -- both decided in pass-bar.ts. */
const rowBar = (stat: WorkflowStat) =>
passBar(delivered(stat), stat.runs || 0);
</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 flex-col gap-1.5 border-b border-hairline py-2 last:border-b-0"
>
<span class="flex items-baseline justify-between gap-3 text-sm">
<span class="truncate text-fg-muted">{{
w.workflow || "workflow"
}}</span>
<span class="shrink-0 font-mono text-xs text-fg-subtle">{{
delivered(w)
}}/{{ w.runs || 0 }}</span>
</span>
<!-- The bar restates the counts as a length: a gate drifting down
is visible before the two numbers are read. Its track carries
the failure when there is no width to show. -->
<span
class="block h-1.5 overflow-hidden rounded-full"
:class="STATUS_FILL[rowBar(w).track]"
>
<span
class="block h-full rounded-full"
:class="STATUS_FILL[rowBar(w).kind]"
:style="`width:${rowBar(w).pct}%`"
/>
</span>
</li>
</ul>
</div>
</template>
</CardContent>
</Card>
</template>