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

+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)