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:
sam committed 2026-11-24 00:04:20 +11:00
1 parent 2bfb262e9c
commit de05bc2cbd
14 files changed
+218 -48

No files matched your search

+15
View File
@@ -3618,6 +3618,10 @@ components:
- "null"
state:
type: string
summary:
type: string
target:
$ref: "#/components/schemas/RunsTarget"
type:
type: string
required:
@@ -3642,6 +3646,17 @@ components:
- needs_repository
- settings
type: object
RunsTarget:
additionalProperties: false
properties:
id:
type: string
kind:
type: string
required:
- kind
- id
type: object
RunsToolCallView:
additionalProperties: false
properties:
+33 -2
View File
@@ -47,6 +47,8 @@ type Context struct {
nextMarker int
// entered holds the top-level steps an earlier attempt reached.
entered map[string]bool
// done holds the top-level steps whose outcome is recorded.
done map[string]bool
// ending is set when the run ends before its last step. A run that
// completes every step has no ending and succeeds.
ending *Ending
@@ -67,11 +69,14 @@ const (
// enteredPrefix names the marker that records the position a top-level
// step began at, so a parked run can retry from it.
enteredPrefix = "at:"
// donePrefix names the marker that records a finished top-level step's
// summary and target, for the run's trail.
donePrefix = "done:"
)
func newContext(ctx context.Context, work runWork, run store.Run, token uuid.UUID, steps []store.Step) *Context {
saved := make(map[int]store.Step, len(steps))
started, entered := map[string]bool{}, map[string]bool{}
started, entered, done := map[string]bool{}, map[string]bool{}, map[string]bool{}
nextMarker := markerBase
for _, s := range steps {
saved[s.Seq] = s
@@ -83,8 +88,12 @@ func newContext(ctx context.Context, work runWork, run store.Run, token uuid.UUI
entered[name] = true
nextMarker = max(nextMarker, s.Seq+1)
}
if name, ok := strings.CutPrefix(s.Name, donePrefix); ok {
done[name] = true
nextMarker = max(nextMarker, s.Seq+1)
}
}
rc := &Context{ctx: ctx, work: work, run: run, token: token, saved: saved, started: started, entered: entered, nextMarker: nextMarker}
rc := &Context{ctx: ctx, work: work, run: run, token: token, saved: saved, started: started, entered: entered, done: done, nextMarker: nextMarker}
rc.resolve = func(ctx context.Context, req StartRequest) (store.NewRun, error) { return newRun(ctx, work, req) }
if run.Dry {
rc.overlay, _ = readOverlay(run.Overlay)
@@ -125,6 +134,28 @@ func (rc *Context) Enter(ctx context.Context, name string) error {
return nil
}
// stepOutcome is what a done marker stores for a finished top-level step.
type stepOutcome struct {
Summary string `json:"summary"`
Target *Target `json:"target,omitzero"`
}
// Done records the summary and target of the top-level step name once it has
// finished, unless an earlier attempt already did.
func (rc *Context) Done(ctx context.Context, name string, res StepResult) error {
if rc.done[name] {
return nil
}
seq := rc.nextMarker
out := stepOutcome{Summary: res.Summary, Target: res.Target}
if _, err := rc.record(ctx, seq, donePrefix+name, out, nil); err != nil && !errors.Is(err, store.ErrStepExists) {
return err
}
rc.done[name] = true
rc.nextMarker = seq + 1
return nil
}
// End records that the run ends before its last step, with this state and
// detail.
func (rc *Context) End(state, detail string) {
+1 -1
View File
@@ -246,7 +246,7 @@ func (d Deps) runStep(rc *Context, p *progress, s Step, index int) error {
p.results[s.ID] = res
}
p.last = res.Summary
return nil
return rc.Done(rc.Context(), name, res)
}
// stepFailed reports whether err is the step's own failure, which on_failure
+6 -4
View File
@@ -32,13 +32,15 @@ func (s messageSettings) describe() string {
// runMessage sends the message. A dry run records it without sending.
func runMessage(d Deps, rc *Context, _ *progress, _ string, s messageSettings) (StepResult, error) {
sent := fmt.Sprintf("send to %s chat %s: %s", s.Channel, s.ChatID, s.Text)
res := StepResult{Summary: s.Text, Target: &Target{Kind: s.Channel, ID: s.ChatID}}
if rc.Dry() {
_, err := rc.Step("send-skipped", func(context.Context, string) (string, error) { return sent, nil })
return StepResult{Summary: sent}, err
_, err := rc.Step("send-skipped", func(context.Context, string) (string, error) {
return fmt.Sprintf("send to %s chat %s: %s", s.Channel, s.ChatID, s.Text), nil
})
return res, err
}
_, err := rc.Step("send", func(ctx context.Context, key string) (bool, error) {
return true, d.Messenger.Send(ctx, s.Channel, s.ChatID, s.Text, key)
})
return StepResult{Summary: sent}, err
return res, err
}
+10 -1
View File
@@ -10,10 +10,19 @@ import (
)
// StepResult is the output later steps can reference as
// steps.<id>.summary and steps.<id>.result.<field>.
// steps.<id>.summary and steps.<id>.result.<field>. Target is not referenceable;
// the run's trail shows it beside the summary.
type StepResult struct {
Summary string `json:"summary"`
Result map[string]any `json:"result,omitzero"`
Target *Target `json:"target,omitzero"`
}
// Target is the item a step acted on: its kind, such as a messaging channel,
// and its identifier.
type Target struct {
Kind string `json:"kind"`
ID string `json:"id"`
}
// referencePattern matches {{ path }} in a step's string settings.
+24
View File
@@ -30,6 +30,10 @@ type Stage struct {
StartedAt *time.Time `json:"started_at,omitzero"`
EndedAt *time.Time `json:"ended_at,omitzero"`
Error string `json:"error,omitzero"`
// Summary and Target are the step's result. They are empty for a step that
// hasn't finished, or that finished before results were recorded.
Summary string `json:"summary,omitzero"`
Target *Target `json:"target,omitzero"`
}
// region is the span of recorded steps one top-level step made, which begins at
@@ -80,10 +84,14 @@ func stagesOf(doc Document, steps []store.Recorded, run RunView) []Stage {
skipped[name] = true
}
}
finished := outcomes(steps)
out := make([]Stage, 0, len(doc.Steps))
for i, step := range doc.Steps {
name := step.name(i)
st := Stage{Name: name, Type: stepKind(step), State: StagePending}
if o, ok := finished[name]; ok {
st.Summary, st.Target = o.Summary, o.Target
}
if terminal(run.State) {
st.State = StageSkipped
}
@@ -95,6 +103,22 @@ func stagesOf(doc Document, steps []store.Recorded, run RunView) []Stage {
return out
}
// outcomes reads the done markers a run recorded, by step name.
func outcomes(steps []store.Recorded) map[string]stepOutcome {
out := map[string]stepOutcome{}
for _, s := range steps {
name, ok := strings.CutPrefix(s.Name, donePrefix)
if !ok || s.Seq < markerBase {
continue
}
var o stepOutcome
if json.Unmarshal(s.Output, &o) == nil {
out[name] = o
}
}
return out
}
// reached fills in a stage for the step that began at regs[at].
func reached(st *Stage, regs []region, at int, skipped bool, run RunView) {
started := regs[at].at
+6 -3
View File
@@ -284,10 +284,13 @@ func (a *runAPI) trail(ctx context.Context, in *runInput) (*httpapi.Reply[Trail]
t.Origin = &o
}
for _, s := range steps {
e := entry(s)
if s.Seq < markerBase {
e.Step = stageOf(regs, s.Seq)
// Markers record step positions and results for the engine. The
// stages show what they record.
if s.Seq >= markerBase {
continue
}
e := entry(s)
e.Step = stageOf(regs, s.Seq)
t.Entries = append(t.Entries, e)
}
decisions, err := a.decisions.ForRun(ctx, id)
+12 -8
View File
@@ -46,14 +46,18 @@ state; the UI presents them and submits operator choices.
## Components and interaction
- Build pages only from components/ui, the design system modelled on Astryx
(astryx.atmeta.com/components). Use Section for a titled card, SettingRow
for a setting, MetadataList for label/value pairs, DataTable for a table
with optional columns, Badge and StatusDot for state, Timestamp for times,
MoreMenu for overflow actions, Empty for empty states, and the type scale
(text-caption, text-label, text-title) instead of pixel sizes. Never
hand-roll a card, heading, caption, status dot or date format; if a pattern
is missing, add it to components/ui with a real consumer first.
- Build pages only from components/ui and the page frame in src/base
(PageHeader for a page title and its actions, CodeView for code or a payload
with a copy button). Use Section for a titled card, SettingRow for a
setting, MetadataList for label/value pairs, DataTable for a table with
optional columns, Item for a list row, Field for a form field, Badge and
StatusDot for state, Timestamp for times, MoreMenu for overflow actions,
Empty for empty states (including an empty value or result), ReadError for a
failed read, Skeleton while loading, Trace for an agent's steps,
CodeBlockCopyButton to copy an ID or value, and the type scale (text-caption,
text-label, text-title) instead of pixel sizes. Never hand-roll a card,
heading, caption, status dot, copy button or date format; if a pattern is
missing, add it to components/ui with a real consumer first.
- Add and update components/ui components with the shadcn-vue CLI, never by
writing or copying them by hand: `pnpm dlx shadcn-vue@latest add <name>` from
`ui/`, or the component's registry URL when the maintainer names one. Search
+6 -1
View File
@@ -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">
+8 -4
View File
@@ -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
View File
@@ -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.
+8
View File
@@ -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
View File
@@ -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>
+6 -3
View File
@@ -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;