Merge branch 'main' into worktree-agent-a6a4a1df2423fa389
This commit is contained in:
46 files changed
+2695
-818
No files matched your search
@@ -0,0 +1,70 @@
|
||||
<script setup lang="ts">
|
||||
import { ChevronDown } from "@lucide/vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import type { ConnectorHealth, HealthCheck } from "@/lib/api";
|
||||
|
||||
defineProps<{ checks: HealthCheck[]; connectors: ConnectorHealth[] }>();
|
||||
|
||||
const contract: Record<string, string> = {
|
||||
connector: "Connector",
|
||||
secretengine: "Secret engine",
|
||||
guard: "Guard",
|
||||
mcp: "MCP server",
|
||||
};
|
||||
|
||||
const moduleColumns: DataTableColumn<HealthCheck>[] = [
|
||||
{ id: "name", label: "Module", fixed: true },
|
||||
{ id: "state", label: "State" },
|
||||
];
|
||||
const connectorColumns: DataTableColumn<ConnectorHealth>[] = [
|
||||
{ id: "name", label: "Connector", fixed: true },
|
||||
{ id: "kind", label: "Kind" },
|
||||
{ id: "failed", label: "Failed", hidden: true },
|
||||
{ id: "state", label: "State" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Section title="Modules">
|
||||
<DataTable :columns="moduleColumns" :rows="checks" :row-key="(row) => row.name" storage-key="status.modules">
|
||||
<template #cell-name="{ row }"><span class="font-mono">{{ row.name }}</span></template>
|
||||
<template #cell-state="{ row }">
|
||||
<Popover v-if="!row.healthy">
|
||||
<PopoverTrigger as-child>
|
||||
<Button type="button" variant="ghost" class="h-auto rounded-sm p-0" :aria-label="`Why ${row.name} is unhealthy`">
|
||||
<Badge variant="danger">unhealthy<ChevronDown data-icon="inline-end" /></Badge>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" class="w-96 max-w-[calc(100vw-2rem)] space-y-1 text-label">
|
||||
<p class="whitespace-pre-line break-words">{{ row.error }}</p>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
</DataTable>
|
||||
</Section>
|
||||
<Section v-if="connectors.length" title="Connectors">
|
||||
<DataTable :columns="connectorColumns" :rows="connectors" :row-key="(row) => row.name" storage-key="status.connectors">
|
||||
<template #cell-name="{ row }"><span class="font-mono">{{ row.name }}</span></template>
|
||||
<template #cell-kind="{ row }"><span class="text-fg-muted">{{ contract[row.contract] ?? row.contract }}</span></template>
|
||||
<template #cell-failed="{ row }"><Timestamp v-if="row.failed_at" :at="row.failed_at" class="text-fg-muted" /></template>
|
||||
<template #cell-state="{ row }">
|
||||
<Popover v-if="!row.healthy">
|
||||
<PopoverTrigger as-child>
|
||||
<Button type="button" variant="ghost" class="h-auto rounded-sm p-0" :aria-label="`Why ${row.name} failed`">
|
||||
<Badge variant="danger">failed<ChevronDown data-icon="inline-end" /></Badge>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" class="w-96 max-w-[calc(100vw-2rem)] space-y-1 text-label">
|
||||
<p class="whitespace-pre-line break-words">{{ row.error }}</p>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
</DataTable>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import type { SystemHealth } from "@/lib/api";
|
||||
|
||||
const props = defineProps<{ health: SystemHealth }>();
|
||||
|
||||
const rows = computed(() => {
|
||||
const h = props.health;
|
||||
const runs = h.waiting?.runs;
|
||||
return [
|
||||
{ label: "Version", value: h.version, mono: true },
|
||||
{ label: "Workers", value: String(h.runner.workers) },
|
||||
...(h.waiting
|
||||
? [
|
||||
{ label: "Approvals waiting", value: String(h.waiting.approvals) },
|
||||
{ label: "Runs parked", value: String(runs?.parked ?? 0) },
|
||||
{ label: "Runs waiting", value: String((runs?.waiting ?? 0) + (runs?.waiting_approval ?? 0)) },
|
||||
{ label: "Runs queued", value: String(runs?.queued ?? 0) },
|
||||
{ label: "Runs running", value: String(runs?.running ?? 0) },
|
||||
]
|
||||
: []),
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Section title="Instance">
|
||||
<p v-if="health.runner.error" role="alert" class="mb-3 flex flex-wrap items-center gap-x-2 text-label text-danger">
|
||||
Runner: {{ health.runner.error }}
|
||||
<Timestamp v-if="health.runner.error_at" :at="health.runner.error_at" />
|
||||
</p>
|
||||
<p v-if="health.last_failure" class="mb-3 flex flex-wrap items-center gap-x-2 text-label text-danger">
|
||||
<Timestamp :at="health.last_failure.at" />
|
||||
<span class="font-mono">{{ health.last_failure.source }}</span><span class="min-w-0 break-words" :title="health.last_failure.cause">{{ health.last_failure.cause.split("\n")[0] }}</span>
|
||||
<RouterLink v-if="health.last_failure.run_id" :to="`/runs/${health.last_failure.run_id}`" class="underline">Run</RouterLink>
|
||||
</p>
|
||||
<MetadataList :rows="rows" />
|
||||
</Section>
|
||||
</template>
|
||||
@@ -1,144 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
import { ChevronDown } from "@lucide/vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { api, describeError } from "@/lib/api";
|
||||
import { errors } from "@/copy/errors";
|
||||
|
||||
interface AppliedRecord {
|
||||
kind: string;
|
||||
applied_version: number;
|
||||
error?: string;
|
||||
state: "current" | "failed" | "unknown";
|
||||
}
|
||||
|
||||
interface Service {
|
||||
service: string;
|
||||
instance_id: string;
|
||||
state: "up" | "degraded" | "down" | "unknown";
|
||||
version: string;
|
||||
install_type: string;
|
||||
started_at: string;
|
||||
reported_at: string;
|
||||
detail?: string;
|
||||
applied: AppliedRecord[];
|
||||
checks?: { name: string; status: "ok" | "degraded"; detail?: string }[];
|
||||
}
|
||||
|
||||
const services = ref<Service[]>([]);
|
||||
const error = ref<string | null>(null);
|
||||
let timer: ReturnType<typeof setInterval> | undefined;
|
||||
|
||||
const tone = { up: "ok", degraded: "warn", down: "danger", unknown: "idle" } as const;
|
||||
|
||||
const columns = (agent: boolean): DataTableColumn<Service>[] => [
|
||||
{ id: "name", label: agent ? "Task" : "Service", fixed: true },
|
||||
{ id: "version", label: "Version" },
|
||||
{ id: "install", label: "Runs as", hidden: true },
|
||||
{ id: "uptime", label: "Uptime" },
|
||||
{ id: "seen", label: "Last seen", hidden: true },
|
||||
{ id: "state", label: "State" },
|
||||
];
|
||||
|
||||
// An agent reports for one task, so agents get their own table keyed by task.
|
||||
const tables = computed(() => {
|
||||
const agents = services.value.filter((s) => s.service === "archie-agent");
|
||||
return [
|
||||
{ title: "Services", key: "services", agent: false, rows: services.value.filter((s) => s.service !== "archie-agent") },
|
||||
...(agents.length ? [{ title: "Agents", key: "agents", agent: true, rows: agents }] : []),
|
||||
];
|
||||
});
|
||||
const rowKey = (service: Service) => `${service.service}/${service.instance_id}`;
|
||||
|
||||
function uptime(service: Service): string {
|
||||
if (!service.started_at || service.state === "down") return "";
|
||||
const seconds = Math.max(
|
||||
0,
|
||||
Math.round((Date.now() - Date.parse(service.started_at)) / 1000),
|
||||
);
|
||||
const days = Math.floor(seconds / 86400);
|
||||
const hours = Math.floor((seconds % 86400) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
if (days) return `${days}d ${hours}h`;
|
||||
if (hours) return `${hours}h ${minutes}m`;
|
||||
return `${minutes}m`;
|
||||
}
|
||||
|
||||
// A row names what is wrong with a service and nothing else: passing checks
|
||||
// and applied versions that match are noise here.
|
||||
function problems(service: Service): { key: string; text: string }[] {
|
||||
return [
|
||||
...(service.checks ?? [])
|
||||
.filter((check) => check.status !== "ok")
|
||||
.map((check) => ({
|
||||
key: `check:${check.name}`,
|
||||
text: [check.name, check.detail].filter(Boolean).join(": "),
|
||||
})),
|
||||
...service.applied
|
||||
.filter((record) => record.error)
|
||||
.map((record) => ({ key: `applied:${record.kind}`, text: `${record.kind}: ${record.error}` })),
|
||||
];
|
||||
}
|
||||
|
||||
const reasons = (service: Service) => {
|
||||
const found = problems(service).map((problem) => problem.text);
|
||||
return found.length || !service.detail ? found : [service.detail];
|
||||
};
|
||||
|
||||
let loadGeneration = 0;
|
||||
async function load(): Promise<void> {
|
||||
const current = ++loadGeneration;
|
||||
try {
|
||||
services.value = await api.services<Service[]>();
|
||||
if (current !== loadGeneration) return;
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
if (current !== loadGeneration) return;
|
||||
error.value = describeError(err, errors.common.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
timer = setInterval(() => void load(), 15_000);
|
||||
});
|
||||
onUnmounted(() => clearInterval(timer));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-4" @retry="load" />
|
||||
<Section v-for="table in tables" v-else :key="table.key" :title="table.title">
|
||||
<DataTable :columns="columns(table.agent)" :rows="table.rows" :row-key="rowKey" :storage-key="`status.${table.key}`">
|
||||
<template #cell-name="{ row }">
|
||||
<RouterLink v-if="table.agent" :to="`/tasks/${row.instance_id}`" class="hover:underline">#{{ row.instance_id }}</RouterLink>
|
||||
<span v-else class="font-mono">{{ row.service }}</span>
|
||||
</template>
|
||||
<template #cell-version="{ row }"><span class="font-mono text-fg-muted">{{ row.version }}</span></template>
|
||||
<template #cell-install="{ row }"><span class="text-fg-muted">{{ row.install_type }}</span></template>
|
||||
<template #cell-uptime="{ row }"><span class="tabular-nums">{{ uptime(row) }}</span></template>
|
||||
<template #cell-seen="{ row }"><Timestamp :at="row.reported_at" class="text-fg-muted" /></template>
|
||||
<template #cell-state="{ row }">
|
||||
<template v-if="row.state !== 'up'">
|
||||
<Popover v-if="reasons(row).length">
|
||||
<PopoverTrigger as-child>
|
||||
<Button type="button" variant="ghost" class="h-auto rounded-sm p-0" :aria-label="`Why ${row.service} is ${row.state}`">
|
||||
<Badge :variant="tone[row.state]">{{ row.state }}<ChevronDown data-icon="inline-end" /></Badge>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" class="w-96 max-w-[calc(100vw-2rem)] space-y-1 text-label">
|
||||
<p v-for="reason in reasons(row)" :key="reason" class="break-words">{{ reason }}</p>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<Badge v-else :variant="tone[row.state]">{{ row.state }}</Badge>
|
||||
</template>
|
||||
</template>
|
||||
</DataTable>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -1,45 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { computed, onMounted, onUnmounted } from "vue";
|
||||
import { computed, onMounted } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import ServicesCard from "./ServicesCard.vue";
|
||||
import UpdateSettingsCard from "./UpdateSettingsCard.vue";
|
||||
import VersionsCard from "./VersionsCard.vue";
|
||||
import { useSettingsStore } from "@/stores/settings";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { api } from "@/lib/api";
|
||||
import { useSystemHealth } from "@/lib/system-health";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import HealthTables from "./HealthTables.vue";
|
||||
import InstanceCard from "./InstanceCard.vue";
|
||||
|
||||
const { data: health, error, reload } = useSystemHealth();
|
||||
const startup = useRead(() => api.bootstrap());
|
||||
onMounted(startup.reload);
|
||||
|
||||
const store = useSettingsStore();
|
||||
const { config, catalogError } = storeToRefs(store);
|
||||
const bootstrapRows = computed(() =>
|
||||
Object.entries(config.value?.bootstrap ?? {}).map(([label, value]) => ({ label, value, mono: true })),
|
||||
Object.entries(startup.data.value ?? {}).map(([label, value]) => ({ label, value: String(value), mono: true })),
|
||||
);
|
||||
|
||||
let timer: ReturnType<typeof setInterval>;
|
||||
onMounted(() => {
|
||||
void store.loadConfig();
|
||||
timer = setInterval(() => void store.loadConfig(), 15_000);
|
||||
});
|
||||
onUnmounted(() => clearInterval(timer));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PageHeader title="Status" />
|
||||
<div>
|
||||
<ReadError v-if="catalogError" :message="catalogError" retry-label="Retry" class="mb-4" @retry="store.load()" />
|
||||
<Alert v-if="config?.reload?.last_error" variant="destructive" class="mb-4">
|
||||
<AlertTitle>{{ errors.settings.status.reload }}</AlertTitle>
|
||||
<AlertDescription>{{ config.reload.last_error }}</AlertDescription>
|
||||
</Alert>
|
||||
<ServicesCard />
|
||||
<VersionsCard />
|
||||
<UpdateSettingsCard />
|
||||
<Section v-if="config?.bootstrap && Object.keys(config.bootstrap).length" title="Startup settings">
|
||||
<MetadataList :rows="bootstrapRows" />
|
||||
<ReadError v-if="error && !health" :message="error" retry-label="Retry" class="mb-4" @retry="reload" />
|
||||
<div v-else-if="!health" role="status" aria-label="Loading status" class="space-y-2"><Skeleton class="h-8 w-full" /><Skeleton class="h-8 w-full" /></div>
|
||||
<template v-else>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-4" @retry="reload" />
|
||||
<InstanceCard :health="health" />
|
||||
<HealthTables :checks="health.checks" :connectors="health.connectors" />
|
||||
</template>
|
||||
<Section v-if="bootstrapRows.length" title="Startup settings">
|
||||
<MetadataList :rows="bootstrapRows" />
|
||||
</Section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,70 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { computed, onMounted } from "vue";
|
||||
|
||||
import { Field, FieldContent, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import { useSettingsStore } from "@/stores/settings";
|
||||
import { fieldInvalid } from "./settings-form";
|
||||
import KindGate from "./KindGate.vue";
|
||||
|
||||
const KIND = "update-settings";
|
||||
type UpdateSettings = { channel: string; pin: string };
|
||||
|
||||
const store = useSettingsStore();
|
||||
onMounted(store.load);
|
||||
|
||||
const form = computed(() => store.formFor(KIND));
|
||||
const channel = computed(() => (store.draftValue(KIND) as UpdateSettings | undefined)?.channel || "stable");
|
||||
const error = computed(() => store.pageErrorFor(KIND));
|
||||
|
||||
const channels = [
|
||||
{ value: "stable", label: "Stable" },
|
||||
{ value: "next", label: "Prereleases" },
|
||||
{ value: "exact-pin", label: "Pinned" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<KindGate v-if="!form" :kind="KIND" />
|
||||
<Section v-if="form" title="Updates">
|
||||
<Alert v-if="error" variant="destructive" class="mb-2"><AlertDescription>{{ error }}</AlertDescription></Alert>
|
||||
<FieldGroup class="@container/field-group">
|
||||
<form.Field v-slot="{ field }" name="channel">
|
||||
<Field orientation="responsive">
|
||||
<FieldContent><FieldLabel>Release channel</FieldLabel></FieldContent>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||
<ToggleGroup
|
||||
type="single"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
:model-value="channel"
|
||||
aria-label="Release channel"
|
||||
@update:model-value="(value) => { if (value) field.handleChange(value); }"
|
||||
>
|
||||
<ToggleGroupItem v-for="option in channels" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
</div>
|
||||
</Field>
|
||||
</form.Field>
|
||||
<form.Field v-if="channel === 'exact-pin'" v-slot="{ field }" name="pin">
|
||||
<Field orientation="responsive" :data-invalid="fieldInvalid(field)">
|
||||
<FieldContent><FieldLabel for="update-pin">Version</FieldLabel></FieldContent>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||
<Input
|
||||
id="update-pin"
|
||||
:model-value="field.state.value"
|
||||
class="max-w-40 font-mono"
|
||||
placeholder="1.48.0"
|
||||
:aria-invalid="fieldInvalid(field)"
|
||||
@blur="field.handleBlur"
|
||||
@update:model-value="field.handleChange"
|
||||
/>
|
||||
</div>
|
||||
</Field>
|
||||
</form.Field>
|
||||
</FieldGroup>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -1,214 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { ApiError, api, describeError } from "@/lib/api";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
|
||||
/**
|
||||
* Per-component versions and the update that applies them: /api/version reports
|
||||
* what is running, what the check command claims, what is available and the
|
||||
* status between those (ok, update_available, drift, unknown).
|
||||
*/
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
const components = ref<ComponentVersion[]>([]);
|
||||
const snapshot = ref<unknown>(null);
|
||||
const available = ref<unknown[]>([]);
|
||||
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 outcome = ref<{ at: string; summary: string; failed: boolean } | null>(null);
|
||||
const outcomeError = 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: "",
|
||||
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: unknown; available: unknown[] | null; 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;
|
||||
available.value = update.available ?? [];
|
||||
canInstall.value = update.can_install;
|
||||
}
|
||||
} catch (err) {
|
||||
loadError.value = describeError(err, errors.common.unknown);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// The last update's outcome is the update_report event the watchdog records
|
||||
// after it restarts and health-checks the daemon.
|
||||
async function loadOutcome(): Promise<void> {
|
||||
try {
|
||||
const page = await api.audit<{
|
||||
records: {
|
||||
at: string;
|
||||
summary: string;
|
||||
detail: { data: { health_check?: string; rolled_back?: boolean } | null };
|
||||
}[];
|
||||
}>({ actions: "update_report", limit: 1 });
|
||||
const last = page.records[0];
|
||||
const data = last?.detail.data;
|
||||
outcome.value = last
|
||||
? {
|
||||
at: last.at,
|
||||
summary: last.summary,
|
||||
failed: !!data?.rolled_back || data?.health_check !== "passed",
|
||||
}
|
||||
: null;
|
||||
outcomeError.value = null;
|
||||
} catch (err) {
|
||||
outcomeError.value = describeError(err, errors.common.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
// 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(): unknown {
|
||||
return snapshot.value && available.value.length ? snapshot.value : 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";
|
||||
installResult.value = `Staged: ${installResult.value}. The outcome appears below after the restart.`;
|
||||
await load();
|
||||
} catch (err) {
|
||||
installError.value = describeError(err, errors.common.unknown);
|
||||
} finally {
|
||||
installing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
void loadOutcome();
|
||||
});
|
||||
useLiveResource("updates", () => void loadOutcome());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p v-if="notConfigured" class="text-label text-fg-muted">Update checks not configured.</p>
|
||||
<Section v-else title="Versions">
|
||||
<ReadError v-if="loadError" :message="loadError" retry-label="Retry" class="mb-3" @retry="load" />
|
||||
<p v-else-if="loading" class="text-label text-fg-muted">Checking…</p>
|
||||
<template v-else>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Component</TableHead>
|
||||
<TableHead>Running</TableHead>
|
||||
<TableHead>Available</TableHead>
|
||||
<TableHead class="w-full"></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-for="component in components" :key="component.id">
|
||||
<TableCell>{{ 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 v-if="component.status !== 'ok'" :variant="statusKind[component.status]">{{
|
||||
statusLabel[component.status]
|
||||
}}</Badge>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Button class="mt-4 self-start" :disabled="installing || !installableSnapshot()" @click="install">{{ installing ? "Installing…" : `Install ${updateable.map((c) => c.label || c.id).join(", ")}`.trim() }}</Button>
|
||||
|
||||
<CodeView v-if="installProgress.length" :code="installProgress.join('\n')" class="mt-3" />
|
||||
<p v-if="installResult" class="mt-2 text-label text-ok">
|
||||
{{ installResult }}
|
||||
</p>
|
||||
<p v-if="outcome" class="mt-2 text-label" :class="outcome.failed ? 'text-danger' : 'text-ok'">
|
||||
<Timestamp :at="outcome.at" /> {{ outcome.summary }}
|
||||
</p>
|
||||
<ReadError v-if="outcomeError" :message="outcomeError" class="mt-2" />
|
||||
<ReadError v-if="installError" :message="installError" class="mt-2" />
|
||||
</template>
|
||||
</Section>
|
||||
</template>
|
||||
Reference in new issue
Block a user