feat(runs): show each step's summary and target on the run page
- a finished top-level step records its summary and target in a done marker; stages return them - a message step's summary is the message, and its target the channel and chat - the trail no longer lists the engine's markers as entries - run page: short run ID in the breadcrumb, copyable IDs, version badge, step rows from stages, No output for an empty result - event detail: No payload for an empty body, and links only the dispatches that started a run - ui/AGENTS.md lists the components that exist
This commit is contained in:
14 files changed
+218
-48
No files matched your search
+6
-1
@@ -36,6 +36,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const workflowsPage = computed(() => route.name === "workflow");
|
||||
const hidden = computed(() => hiddenPaths(session.sections));
|
||||
const sectionLink = computed(() => ({ workflow: "/workflows", run: "/runs" })[String(route.name)]);
|
||||
// The redirect below must not run during the router's first navigation: route
|
||||
// is still the start location then, so a deep link would be replaced by the
|
||||
// landing page before it resolves.
|
||||
@@ -118,11 +119,15 @@ watch(() => accounts.status?.user, (user) => {
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem><OrgCrumb /></BreadcrumbItem>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem><SectionCrumb :hidden="hidden" :link="route.name === 'workflow' ? '/workflows' : undefined" /></BreadcrumbItem>
|
||||
<BreadcrumbItem><SectionCrumb :hidden="hidden" :link="sectionLink" /></BreadcrumbItem>
|
||||
<template v-if="route.name === 'workflow'">
|
||||
<BreadcrumbSeparator class="max-md:hidden" />
|
||||
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate">{{ route.params.id }}</BreadcrumbPage></BreadcrumbItem>
|
||||
</template>
|
||||
<template v-else-if="route.name === 'run'">
|
||||
<BreadcrumbSeparator class="max-md:hidden" />
|
||||
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate font-mono">{{ String(route.params.id).slice(0, 8) }}</BreadcrumbPage></BreadcrumbItem>
|
||||
</template>
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
<div class="ml-auto flex shrink-0 items-center gap-4 max-sm:gap-1">
|
||||
|
||||
@@ -3,26 +3,30 @@ import { computed, onMounted } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { api } from "@/lib/api";
|
||||
import { emptyValue } from "@/lib/format";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** One event's payload and the runs it started. */
|
||||
const props = defineProps<{ id: string }>();
|
||||
const { data, error, reload } = useRead(() => api.event(props.id));
|
||||
onMounted(reload);
|
||||
const body = computed(() => JSON.stringify(data.value?.body ?? null, null, 2));
|
||||
const body = computed(() => (emptyValue(data.value?.body) ? "" : JSON.stringify(data.value?.body, null, 2)));
|
||||
const started = computed(() => (data.value?.runs ?? []).filter((run) => run.run_id));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<Skeleton v-else-if="!data" class="h-24 w-full" />
|
||||
<div v-else class="space-y-2" @click.stop>
|
||||
<p v-if="data.runs?.length" class="text-caption text-fg-muted">
|
||||
<p v-if="started.length" class="text-caption text-fg-muted">
|
||||
Started
|
||||
<template v-for="(run, i) in data.runs" :key="run.run_id"><template v-if="i">, </template><RouterLink class="underline" :to="`/runs/${run.run_id}`">a run</RouterLink> through {{ run.trigger }}</template>
|
||||
<template v-for="(run, i) in started" :key="run.run_id"><template v-if="i">, </template><RouterLink class="underline" :to="`/runs/${run.run_id}`">a run</RouterLink> through {{ run.trigger }}</template>
|
||||
</p>
|
||||
<CodeView :code="body" lang="json" />
|
||||
<CodeView v-if="body" :code="body" lang="json" />
|
||||
<Empty v-else><EmptyHeader><EmptyTitle>No payload</EmptyTitle></EmptyHeader></Empty>
|
||||
</div>
|
||||
</template>
|
||||
+5
-1
@@ -920,6 +920,10 @@ export interface RunStage {
|
||||
started_at?: string;
|
||||
ended_at?: string;
|
||||
error?: string;
|
||||
/** The step's result summary. */
|
||||
summary?: string;
|
||||
/** The item the step acted on, such as a chat on a messaging channel. */
|
||||
target?: { kind: string; id: string };
|
||||
}
|
||||
|
||||
export interface RunTrail {
|
||||
@@ -976,7 +980,7 @@ export interface TriggerRun {
|
||||
|
||||
export interface EventDetail {
|
||||
body: unknown;
|
||||
runs?: { run_id: string; trigger: string }[];
|
||||
runs?: { run_id?: string; trigger: string; outcome: string }[];
|
||||
}
|
||||
|
||||
// Named with a trailing underscore: EventSource is the browser's SSE class.
|
||||
|
||||
@@ -77,3 +77,11 @@ export function duration(milliseconds: unknown): string {
|
||||
const remMin = minutes - hours * 60;
|
||||
return remMin === 0 ? `${hours} h` : `${hours} h ${remMin} min`;
|
||||
}
|
||||
|
||||
/** emptyValue reports whether a JSON value is null, an empty string, an empty
|
||||
* array or an empty object. */
|
||||
export function emptyValue(value: unknown): boolean {
|
||||
if (value == null || value === "") return true;
|
||||
if (Array.isArray(value)) return value.length === 0;
|
||||
return typeof value === "object" && Object.keys(value).length === 0;
|
||||
}
|
||||
+78
-20
@@ -6,14 +6,18 @@ import CodeView from "@/base/CodeView.vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CodeBlockCopyButton } from "@/components/ui/code-block";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusDot } from "@/components/ui/status-dot";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type RunAction } from "@/lib/api";
|
||||
import { api, describeError, type RunAction, type RunEntry, type RunStage } from "@/lib/api";
|
||||
import { duration, emptyValue } from "@/lib/format";
|
||||
import AgentTranscript from "@/workflows/AgentTranscript.vue";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import ApprovalsSection from "./ApprovalsSection.vue";
|
||||
@@ -43,18 +47,51 @@ const origin = computed(() => {
|
||||
];
|
||||
});
|
||||
|
||||
// A run that succeeded ends with the summary of its last finished step, so
|
||||
// that step's target is the run's target.
|
||||
const finalTarget = computed(() => {
|
||||
const trail = data.value;
|
||||
if (trail?.run.state !== "succeeded") return undefined;
|
||||
return trail.stages.filter((stage) => stage.state === "succeeded").at(-1)?.target;
|
||||
});
|
||||
|
||||
const details = computed(() => {
|
||||
const run = data.value?.run;
|
||||
if (!run) return [];
|
||||
return [
|
||||
{ label: "Workflow", value: `${run.workflow} v${run.workflow_version}` },
|
||||
{ label: "Workflow", value: run.workflow },
|
||||
...origin.value,
|
||||
...(run.attempts > 1 ? [{ label: "Attempts", value: String(run.attempts) }] : []),
|
||||
...(run.error ? [{ label: "Error", value: run.error }] : []),
|
||||
...(run.detail ? [{ label: "Detail", value: run.detail }] : []),
|
||||
...(finalTarget.value ? [{ label: "Target", value: finalTarget.value.id }] : []),
|
||||
...(run.detail ? [{ label: "Summary", value: run.detail }] : []),
|
||||
{ label: "Run", value: run.id, mono: true },
|
||||
];
|
||||
});
|
||||
|
||||
// A step without an id is named by its type and position, which the type
|
||||
// badge already shows.
|
||||
const unnamed = (stage: RunStage, index: number) => stage.name === `${stage.type}@${index}`;
|
||||
|
||||
function stageDuration(stage: RunStage): string {
|
||||
if (!stage.started_at || !stage.ended_at) return "";
|
||||
return duration(new Date(stage.ended_at).getTime() - new Date(stage.started_at).getTime());
|
||||
}
|
||||
|
||||
const transcripts = computed(() => {
|
||||
const byStage = new Map<string, RunEntry[]>();
|
||||
for (const entry of data.value?.entries ?? []) {
|
||||
if (!entry.step || entry.kind === "step") continue;
|
||||
byStage.set(entry.step, [...(byStage.get(entry.step) ?? []), entry]);
|
||||
}
|
||||
return byStage;
|
||||
});
|
||||
const openTranscripts = ref(new Set<string>());
|
||||
function toggleTranscript(name: string): void {
|
||||
const open = new Set(openTranscripts.value);
|
||||
if (!open.delete(name)) open.add(name);
|
||||
openTranscripts.value = open;
|
||||
}
|
||||
const retrying = ref(false);
|
||||
const retryError = ref("");
|
||||
async function retry(): Promise<void> {
|
||||
@@ -87,9 +124,10 @@ function target(action: RunAction): string {
|
||||
const t = action.decision.action.target;
|
||||
return t?.ID ? `${t.Kind ? `${t.Kind} ` : ""}${t.ID}` : "";
|
||||
}
|
||||
const result = computed(() =>
|
||||
data.value?.run.result == null ? "" : JSON.stringify(data.value.run.result, null, 2),
|
||||
);
|
||||
const result = computed(() => {
|
||||
const value = data.value?.run.result;
|
||||
return emptyValue(value) ? "" : JSON.stringify(value, null, 2);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -109,13 +147,23 @@ const result = computed(() =>
|
||||
<Section title="Details">
|
||||
<MetadataList :rows="details">
|
||||
<template #value="{ row }">
|
||||
<RouterLink v-if="row.label === 'Workflow'" class="underline" :to="`/workflows/${data.run.workflow}`">{{ row.value }}</RouterLink>
|
||||
<RouterLink v-else-if="row.label === 'Event'" class="underline" :to="{ path: '/events', query: { event: row.value } }">{{ row.value }}</RouterLink>
|
||||
<span v-if="row.label === 'Workflow'" class="inline-flex flex-wrap items-center gap-2">
|
||||
<RouterLink class="underline" :to="`/workflows/${data.run.workflow}`">{{ row.value }}</RouterLink>
|
||||
<Badge variant="outline">v{{ data.run.workflow_version }}</Badge>
|
||||
</span>
|
||||
<span v-else-if="row.label === 'Event' || row.label === 'Run'" class="inline-flex items-center gap-1">
|
||||
<RouterLink v-if="row.label === 'Event'" class="underline" :to="{ path: '/events', query: { event: row.value } }">{{ row.value }}</RouterLink>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
<CodeBlockCopyButton :value="row.value ?? ''" />
|
||||
</span>
|
||||
<span v-else-if="row.label === 'Target' && finalTarget">
|
||||
<span class="capitalize">{{ finalTarget.kind }}</span> · <span class="font-mono">{{ finalTarget.id }}</span>
|
||||
</span>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
</Section>
|
||||
<Empty v-if="!data.actions?.length && !data.entries?.length"><EmptyHeader><EmptyTitle>Nothing recorded yet</EmptyTitle></EmptyHeader></Empty>
|
||||
<Empty v-if="!data.actions?.length && !data.stages.length"><EmptyHeader><EmptyTitle>Nothing recorded yet</EmptyTitle></EmptyHeader></Empty>
|
||||
<Section v-if="data.actions?.length" title="Actions">
|
||||
<ul class="divide-y divide-border">
|
||||
<li v-for="action in data.actions" :key="action.decision.id" class="space-y-1 py-3">
|
||||
@@ -139,23 +187,33 @@ const result = computed(() =>
|
||||
</li>
|
||||
</ul>
|
||||
</Section>
|
||||
<Section v-if="data.entries?.length" title="Steps">
|
||||
<Section v-if="data.stages.length" title="Steps">
|
||||
<ol class="divide-y divide-border">
|
||||
<li v-for="entry in data.entries" :key="entry.seq" class="space-y-1 py-2">
|
||||
<li v-for="(stage, index) in data.stages" :key="stage.name" class="space-y-1 py-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="secondary">{{ entry.kind }}</Badge>
|
||||
<span v-if="entry.name" class="font-mono text-label">{{ entry.name }}</span>
|
||||
<Badge v-if="entry.unknown" variant="warn">Outcome unknown</Badge>
|
||||
<Timestamp class="ml-auto text-caption text-fg-subtle" :at="entry.at" />
|
||||
<StatusDot :tone="stateTone(stage.state)" :live="stage.state === 'running'" />
|
||||
<span class="text-caption text-fg-muted">{{ stateLabel(stage.state) }}</span>
|
||||
<span v-if="!unnamed(stage, index)" class="text-label font-medium">{{ stage.name }}</span>
|
||||
<Badge variant="outline" class="font-mono">{{ stage.type }}</Badge>
|
||||
<span v-if="stageDuration(stage)" class="text-caption text-fg-muted">{{ stageDuration(stage) }}</span>
|
||||
<Timestamp v-if="stage.started_at" class="ml-auto text-caption text-fg-subtle" :at="stage.started_at" />
|
||||
</div>
|
||||
<p v-if="entry.text" class="text-label whitespace-pre-wrap">{{ entry.text }}</p>
|
||||
<p v-for="call in entry.tool_calls ?? []" :key="call.name + call.input" class="font-mono text-caption text-fg-muted [overflow-wrap:anywhere]">{{ call.name }} {{ call.input }}</p>
|
||||
<p v-if="entry.error" class="text-caption text-danger">{{ entry.error }}</p>
|
||||
<CodeView v-if="entry.output" :code="entry.output" />
|
||||
<p v-if="stage.target" class="text-caption text-fg-muted">
|
||||
<span class="capitalize">{{ stage.target.kind }}</span> · <span class="font-mono">{{ stage.target.id }}</span>
|
||||
</p>
|
||||
<p v-if="stage.summary" class="text-label whitespace-pre-wrap">{{ stage.summary }}</p>
|
||||
<p v-if="stage.error" class="text-caption text-danger">{{ stage.error }}</p>
|
||||
<template v-if="transcripts.get(stage.name)">
|
||||
<Button variant="link" size="xs" class="px-0 text-caption text-fg-muted" :aria-expanded="openTranscripts.has(stage.name)" @click="toggleTranscript(stage.name)">Transcript</Button>
|
||||
<AgentTranscript v-if="openTranscripts.has(stage.name)" :entries="transcripts.get(stage.name) ?? []" />
|
||||
</template>
|
||||
</li>
|
||||
</ol>
|
||||
</Section>
|
||||
<Section v-if="result" title="Result"><CodeView :code="result" /></Section>
|
||||
<Section v-if="data.run.finished_at || result" title="Result">
|
||||
<CodeView v-if="result" :code="result" />
|
||||
<Empty v-else><EmptyHeader><EmptyTitle>No output</EmptyTitle></EmptyHeader></Empty>
|
||||
</Section>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
||||
import type { RunEntry } from "@/lib/api";
|
||||
import { duration } from "@/lib/format";
|
||||
import { duration, emptyValue } from "@/lib/format";
|
||||
import { stageStatusMeta } from "@/tasks/stage-rail";
|
||||
import AgentTranscript from "./AgentTranscript.vue";
|
||||
import type { StageRun } from "./workflow-graph";
|
||||
@@ -17,8 +17,11 @@ const transcriptOpen = ref(false);
|
||||
|
||||
const meta = computed(() => stageStatusMeta(props.stage.status));
|
||||
const talked = computed(() => props.entries.some((entry) => entry.kind === "model"));
|
||||
// An agent's own steps are the transcript; every other recorded step is shown by name.
|
||||
const recorded = computed(() => props.entries.filter((entry) => entry.kind === "step"));
|
||||
// An agent's own steps are the transcript. Every other recorded step with a
|
||||
// value or an error is listed by its name.
|
||||
const recorded = computed(() =>
|
||||
props.entries.filter((entry) => entry.kind === "step" && (entry.error || !emptyValue(entry.value))),
|
||||
);
|
||||
|
||||
function shown(entry: RunEntry): string {
|
||||
if (entry.error) return entry.error;
|
||||
|
||||
Reference in new issue
Block a user