fix(ui): name and link the identity a parked reason names

This commit is contained in:
sam committed 2026-10-25 16:24:03 +11:00
1 parent d4558c15d3
commit cae19ca42e
3 files changed
+23 -3

No files matched your search

+21 -1
View File
@@ -15,6 +15,7 @@ import { Badge } from "@/components/ui/badge";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { api } from "@/lib/api";
import { useOrgStore } from "@/stores/org";
import { runQuery, type LogState } from "./task-run";
import { firstLine } from "./first-line";
import { approvalLabels, statusKind, statusLabel } from "@/lib/task-meta";
@@ -46,6 +47,20 @@ const failure = computed(() => {
if (attempt.value?.status === "failed" || (current && status.value === "dead")) return { title: `Attempt ${run.attemptNumber} failed${stage?.name ? ` during ${stage.name}` : ""}`, detail: stage?.error || run.task?.park_reason || "", parked: false };
return null;
});
// The daemon names a workflow's identity by its id in the parked reason; this
// page knows which ids are identities and shows each by name, linked to the
// page that manages it. An id this install does not know keeps its raw text.
const identities = useOrgStore();
identities.watchIdentities();
const detailParts = computed(() => {
const text = failure.value?.detail ?? "";
const known = identities.identities.map((actor) => actor.id).filter((id) => text.includes(id));
if (!known.length) return [{ text, to: "" }];
const pattern = new RegExp(`(${known.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`, "g");
return text
.split(pattern)
.map((part) => (known.includes(part) ? { text: identities.identityName(part), to: "/org/agents" } : { text: part, to: "" }));
});
const jumping = ref(false);
const jumpError = ref("");
watch(() => run.attemptNumber, () => { jumpError.value = ""; });
@@ -175,7 +190,12 @@ const headerActions = computed(() =>
<Button variant="ghost" size="sm" :disabled="jumping || run.attemptNumber == null" @click="jumpToLog">Jump to log line</Button>
</AlertTitle>
<AlertDescription>
<p v-if="failure.detail" class="mt-0.5 font-mono text-xs text-fg-muted [overflow-wrap:anywhere]">{{ failure.detail }}</p>
<p v-if="failure.detail" class="mt-0.5 font-mono text-xs text-fg-muted [overflow-wrap:anywhere]">
<template v-for="(part, index) in detailParts" :key="index">
<RouterLink v-if="part.to" :to="part.to" class="underline decoration-dotted hover:text-foreground">{{ part.text }}</RouterLink>
<template v-else>{{ part.text }}</template>
</template>
</p>
<p v-if="jumpError" class="mt-1 text-xs" role="alert">{{ jumpError }}</p>
<Button v-if="failure.parked && run.attempts?.recovery" as-child size="sm" class="mt-2">
<RouterLink :to="run.attempts.recovery.link">{{ run.attempts.recovery.label }}</RouterLink>