feat(webui): two-section quality gates, sweep the restating card prose

The quality gates card stacked its number and rows across the full row
width -- the rate pinned to the left edge, the counts to the right --
which reads as two places at once. The card now has two internal
sections, left to right: the rate, and the per-workflow rows that
explain it; the row collapses under 720px.

Also swept the restating descriptions: 'Work that passed its quality
gates' under Quality gates, 'Archie needs these before it can work on
its own' under Finish setting up, 'Next 30 days at the current rate'
under Token outlook, 'Last 50, newest first' under Live activity. A
title and a sentence that restate each other are noise; the table or
chart says the thing. CapturesCard's redaction note is a security fact,
not restatement, and stays. The unconfigured versions state is one
quiet line, not a card with a title, a description, and a sentence.
This commit is contained in:
sam committed 2026-09-23 15:29:28 +10:00
1 parent 1e8dc3b8a5
commit 9de96c1d42
14 files changed
+362 -34

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
<script setup lang="ts">
/**
* Inline JSON content with syntax highlighting, or the text verbatim when it
* is not JSON. Every source character survives either way — highlighting adds
* colour spans, never removes or rewrites text. Callers own the surrounding
* <pre> and its classes (borders, max height, wrap behaviour differ per
* surface); this renders only the content.
*/
import { computed } from "vue";
import { tokenClass, tokenizeJson } from "@/lib/json-tokens";
const props = defineProps<{ text: string }>();
const tokens = computed(() => tokenizeJson(props.text));
</script>
<template>
<template v-if="tokens">
<span v-for="(token, i) in tokens" :key="i" :class="tokenClass(token.kind)">{{ token.text }}</span>
</template>
<template v-else>{{ props.text }}</template>
</template>
+2 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed } from "vue";
import HighlightedJson from "@/base/HighlightedJson.vue";
import { prettyPrint } from "./capture-payload";
/**
@@ -24,7 +25,7 @@ const text = computed(() => prettyPrint(props.raw));
<pre
v-else
class="rounded-sm border border-border-strong bg-muted p-3 font-mono text-xs whitespace-pre-wrap wrap-break-word"
>{{ text }}</pre
><HighlightedJson :text="text" /></pre
>
</section>
</template>
+22 -22
View File
@@ -2,7 +2,7 @@
import { computed } from "vue";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { workflows } from "./state";
@@ -24,7 +24,6 @@ const pct = computed(() => {
<Card v-if="workflows">
<CardHeader>
<CardTitle>Quality gates</CardTitle>
<CardDescription>Work that passed its quality gates</CardDescription>
</CardHeader>
<CardContent>
<Empty v-if="!totals.runs">
@@ -34,28 +33,29 @@ const pct = computed(() => {
</Empty>
<template v-else>
<!--
The rate is a number, not a gauge: one value carrying one meaning
reads at a glance, and the rows under it are the actual signal.
Per-workflow counts are the card's body; parked tasks are not
listed here -- Throughput's "Needs you" tile already speaks for
them, from the statuses themselves.
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="flex items-baseline gap-2">
<span class="text-3xl font-semibold">{{ pct }}%</span>
<span class="text-xs text-fg-muted">pass rate · {{ totals.runs }} runs</span>
<div class="grid grid-cols-1 gap-6 min-[720px]: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="(w.merged || 0) === (w.runs || 0) ? 'ok' : (w.parked || 0) > 0 ? 'warn' : 'info'">
{{ w.merged || 0 }}/{{ w.runs || 0 }}
</Badge>
</li>
</ul>
</div>
<ul class="mt-3 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="(w.merged || 0) === (w.runs || 0) ? 'ok' : (w.parked || 0) > 0 ? 'warn' : 'info'">
{{ w.merged || 0 }}/{{ w.runs || 0 }}
</Badge>
</li>
</ul>
</template>
</CardContent>
</Card>
+1 -2
View File
@@ -5,7 +5,7 @@ import { useRouter } from "vue-router";
import { ChevronDown, ChevronRight } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Card, CardAction, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { ago } from "@/lib/format";
@@ -58,7 +58,6 @@ function openTask(taskID: number) {
<Card>
<CardHeader>
<CardTitle>Live activity</CardTitle>
<CardDescription>Last 50, newest first</CardDescription>
<CardAction>
<Badge :variant="streamKind">{{ streamState }}</Badge>
</CardAction>
+1 -2
View File
@@ -2,7 +2,7 @@
import { Check } from "@lucide/vue";
import { computed, ref, watch } from "vue";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
import { setupPanelState, type SetupPanelState } from "./setup-preference";
import { setup } from "./state";
@@ -33,7 +33,6 @@ const pct = computed(() => {
<Card v-if="panel.kind === 'incomplete'">
<CardHeader>
<CardTitle>Finish setting up</CardTitle>
<CardDescription>Archie needs these before it can work on its own.</CardDescription>
<CardAction>
<span class="text-lg font-semibold text-link">{{ pct }}%</span>
</CardAction>
+1 -2
View File
@@ -2,7 +2,7 @@
import { computed } from "vue";
import SegmentBar from "@/base/SegmentBar.vue";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { compact } from "@/lib/format";
import { summary } from "./state";
@@ -20,7 +20,6 @@ const projected = computed(() => Math.round(perDay.value * 30));
<Card>
<CardHeader>
<CardTitle>Token outlook</CardTitle>
<CardDescription v-if="days.length">Next 30 days at the current rate</CardDescription>
</CardHeader>
<CardContent>
<Empty v-if="!days.length">
+7
View File
@@ -149,6 +149,13 @@ export const api = {
// log-row keeps it beside the panel that uses it.
taskLogDownloadURL: (id: string, attempt?: number | null) =>
`/api/tasks/${encodeURIComponent(id)}/logs/download` + (attempt == null ? "" : `?attempt=${attempt}`),
// Versions + updates. The install's synchronous phase (clone + build +
// install) legitimately runs for minutes; its timeout is therefore minutes,
// not the 15s default, and the watchdog owns everything after the restart.
version: <T = unknown>() => request<T>("/api/version"),
updateSnapshot: <T = unknown>() => request<T>("/api/chat/update"),
updateInstall: <T = unknown>(snapshot: unknown) =>
request<T>("/api/chat/update/install", { method: "POST", body: { snapshot }, timeoutMs: 15 * 60_000 }),
captures: <T = unknown>(limit?: number) => request<T>("/api/captures" + qs({ limit })),
mappings: <T = unknown>() => request<T>("/api/mappings"),
mappingCreate: <T = unknown>(mapping: Payload) => request<T>("/api/mappings", { method: "POST", body: mapping }),
+70
View File
@@ -0,0 +1,70 @@
/**
* JSON syntax highlighting, tokenised.
*
* Capture bodies and stored config documents are strings that are "valid JSON
* or not" — the reader's rule is: valid JSON renders with typed colour, and
* anything else renders plain, exactly as stored. There is no projection and
* no library: one pass with a JSON-aware scanner, every character of the
* source preserved verbatim in the output tokens.
*
* Keys and values are distinguished by what follows the string (a colon makes
* it a key), which is exactly how JSON itself decides.
*/
export type JsonTokenKind = "key" | "string" | "number" | "keyword" | "punct";
export interface JsonToken {
text: string;
kind: JsonTokenKind;
}
/** Matches one JSON token: a string (which may be a key), a number, a keyword. */
const SCANNER =
/("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b|\bnull\b)/g;
export function tokenizeJson(text: string): JsonToken[] | null {
if (!text.trim()) return null;
try {
JSON.parse(text);
} catch {
return null; // not JSON: the caller renders it plain
}
const tokens: JsonToken[] = [];
let last = 0;
for (const match of text.matchAll(SCANNER)) {
const [full, str, colon, num, keyword] = match;
const at = match.index ?? 0;
if (at > last) tokens.push({ text: text.slice(last, at), kind: "punct" });
if (str !== undefined) {
tokens.push({ text: str, kind: colon ? "key" : "string" });
if (colon) tokens.push({ text: colon, kind: "punct" });
last = at + full.length;
continue;
}
if (num !== undefined) {
tokens.push({ text: num, kind: "number" });
} else if (keyword !== undefined) {
tokens.push({ text: keyword, kind: "keyword" });
}
last = at + full.length;
}
if (last < text.length) tokens.push({ text: text.slice(last), kind: "punct" });
return tokens;
}
/** The token's colour class, from the design tokens only. */
export function tokenClass(kind: JsonTokenKind): string {
switch (kind) {
case "key":
return "text-primary";
case "string":
return "text-ok";
case "number":
return "text-warn";
case "keyword":
return "text-info";
default:
return "text-foreground";
}
}
+2
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import PageHeader from "@/base/PageHeader.vue";
import HealthStatusCard from "./HealthStatusCard.vue";
import VersionsCard from "./VersionsCard.vue";
</script>
<template>
@@ -8,5 +9,6 @@ import HealthStatusCard from "./HealthStatusCard.vue";
<PageHeader title="Status" />
<HealthStatusCard />
<VersionsCard class="mt-4" />
</div>
</template>
+188
View File
@@ -0,0 +1,188 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { ApiError, api } from "@/lib/api";
/**
* Per-component versions and the update that applies them.
*
* Everything behind this card already exists: /api/version reports what is
* running, what the check command claims, what is available, and the honest
* status between those (ok, update_available, drift, unknown); the install
* endpoint re-validates freshness and refuses a stale snapshot. This card
* only surfaces them.
*/
interface ComponentVersion {
id: string;
label: string;
install_type?: string;
reference?: string;
running_version?: string;
installed_claim?: string;
latest_available?: string;
status: "ok" | "update_available" | "drift" | "unknown";
}
interface ComponentSnapshot {
id?: string;
label?: string;
installed?: string;
available?: string;
}
interface UpdateSnapshot {
components?: ComponentSnapshot[];
deferred?: boolean;
}
const components = ref<ComponentVersion[]>([]);
const snapshot = ref<UpdateSnapshot | null>(null);
const canInstall = ref(false);
const notConfigured = ref(false);
const loading = ref(true);
const loadError = ref<string | null>(null);
const installing = ref(false);
const installProgress = ref<string[]>([]);
const installResult = ref<string | null>(null);
const installError = ref<string | null>(null);
const updateable = computed(() => components.value.filter((c) => c.status === "update_available"));
const statusKind: Record<ComponentVersion["status"], "ok" | "warn" | "danger" | "idle"> = {
ok: "ok",
update_available: "warn",
drift: "danger",
unknown: "idle",
};
const statusLabel: Record<ComponentVersion["status"], string> = {
ok: "Up to date",
update_available: "Update available",
drift: "Version drift",
unknown: "Unknown",
};
async function load(): Promise<void> {
loading.value = true;
loadError.value = null;
try {
const [report, update] = await Promise.all([
api.version<{ components: ComponentVersion[] }>(),
api.updateSnapshot<{ snapshot: UpdateSnapshot; can_install: boolean }>().catch((err) => {
if (err instanceof ApiError && err.status === 501) {
notConfigured.value = true;
return null;
}
throw err;
}),
]);
components.value = report.components;
if (update) {
snapshot.value = update.snapshot;
canInstall.value = update.can_install;
}
} catch (err) {
loadError.value = err instanceof Error ? err.message : String(err);
} finally {
loading.value = false;
}
}
// The snapshot the install endpoint demands is the one the operator saw —
// the endpoint re-checks freshness and answers 409 when releases moved.
function installableSnapshot(): UpdateSnapshot | null {
if (!snapshot.value) return null;
if (snapshot.value.components?.some((c) => c.available && c.available !== c.installed)) {
return snapshot.value;
}
return null;
}
async function install(): Promise<void> {
const snap = installableSnapshot();
if (!snap || installing.value) return;
installing.value = true;
installError.value = null;
installProgress.value = [];
installResult.value = null;
try {
const result = await api.updateInstall<{ progress?: string[]; result?: { installed?: Record<string, string> } }>(snap);
installProgress.value = result.progress ?? [];
const installed = result.result?.installed;
installResult.value = installed
? Object.entries(installed)
.map(([id, version]) => `${id} → ${version}`)
.join(", ")
: "update finished";
await load();
} catch (err) {
installError.value = err instanceof Error ? err.message : String(err);
} finally {
installing.value = false;
}
}
onMounted(load);
</script>
<template>
<p v-if="notConfigured" class="text-sm text-fg-muted">Update checks not configured.</p>
<Card v-else>
<CardHeader>
<CardTitle>Versions</CardTitle>
</CardHeader>
<CardContent>
<p v-if="loadError" class="text-sm text-danger">{{ loadError }}</p>
<p v-else-if="loading" class="text-sm text-fg-muted">Checking…</p>
<template v-else>
<Table>
<TableHeader>
<TableRow>
<TableHead>Component</TableHead>
<TableHead>Running</TableHead>
<TableHead>Available</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-for="component in components" :key="component.id">
<TableCell class="font-medium">{{ component.label || component.id }}</TableCell>
<TableCell class="font-mono text-fg-muted">{{ component.running_version || component.installed_claim || "—" }}</TableCell>
<TableCell class="font-mono text-fg-muted">{{ component.latest_available || "—" }}</TableCell>
<TableCell>
<Badge :variant="statusKind[component.status]">{{ statusLabel[component.status] }}</Badge>
</TableCell>
</TableRow>
</TableBody>
</Table>
<div v-if="canInstall && updateable.length" class="mt-4 flex flex-col gap-2">
<Button :disabled="installing" @click="install">
{{ installing ? "Installing…" : `Install ${updateable.map((c) => c.label || c.id).join(", ")}` }}
</Button>
<p v-if="installing" class="text-xs text-fg-muted">
The build runs on this host and the restart is verified out of band; the page can be left.
</p>
</div>
<div v-if="installProgress.length" class="mt-3 rounded-sm border border-border bg-muted p-3 font-mono text-xs">
<p v-for="(line, i) in installProgress" :key="i">{{ line }}</p>
</div>
<p v-if="installResult" class="mt-2 text-sm text-ok">{{ installResult }}</p>
<p v-if="installError" class="mt-2 text-sm text-danger">{{ installError }}</p>
</template>
</CardContent>
</Card>
</template>
+3 -1
View File
@@ -4,6 +4,8 @@
* and the debug view), and both must show exactly what the daemon stored --
* no projection, no prettifying beyond indentation.
*/
import HighlightedJson from "@/base/HighlightedJson.vue";
defineProps<{ value: unknown }>();
</script>
@@ -14,5 +16,5 @@ defineProps<{ value: unknown }>();
-->
<pre
class="max-h-[60vh] overflow-auto rounded-sm border border-border bg-muted p-3 font-mono text-xs leading-normal whitespace-pre-wrap break-words"
>{{ JSON.stringify(value ?? {}, null, 2) }}</pre>
><HighlightedJson :text="JSON.stringify(value ?? {}, null, 2)" /></pre>
</template>