Let runs carry an operator title shown in the CLI and TUI

Add a bounded, never-empty title to every run. `pipelines run --title "..."`
sets it explicitly and skips model generation; otherwise the server generates
it from the prompt through the shared summariser and falls back to the prompt's
first line, recording title_source (model/fallback/explicit) and title_model.

- protocol/store: RunSummary.Title plus Label(), a set_run_title message, title
  columns with an idempotent migration, CreateRunTitled, and SetRunTitle renames.
- summarise: Title/GenerateTitle/DeriveTitle/ExplicitTitle bounded to TitleCap.
- runner: generate the title outside the admission lock and only for a request
  that starts a run; a replay reuses the stored title and an explicit title
  skips the model entirely.
- CLI: `--title` on run and a `title <run-id> "<title>"` rename command; human
  `runs` and `inspect` show the title beside the pipeline name and version.
- TUI: the run list row, run detail header, Home run cards and last-run line,
  and the pipeline Results line show the title via Label().

Tests cover storage/migration/fallback, explicit-title and rename, the
end-to-end CLI flow, and title rendering; CLI and operations docs updated.
This commit is contained in:
2026-10-16 13:35:43 +01:00
parent 0e6fbcc062
commit f3e0593f4d
23 changed files with 916 additions and 74 deletions
+3 -3
View File
@@ -10,9 +10,9 @@ import (
)
type RunOptions struct {
Pipeline, Prompt, Workspace string
Yes, AllowTools bool
WritePaths []string
Pipeline, Prompt, Title, Workspace string
Yes, AllowTools bool
WritePaths []string
}
func NewRun(ctx context.Context, url string, options RunOptions) Model {
+2 -2
View File
@@ -98,7 +98,7 @@ func (m Model) homeLines() []string {
limit = 2
}
for _, r := range m.runs[:min(limit, len(m.runs))] {
runs = append(runs, bar(fmt.Sprintf("#%d %s", r.ID, r.Name), m.progress(r.Status), max(1, panelWidth-4), false))
runs = append(runs, bar(fmt.Sprintf("#%d %s", r.ID, r.Label()), m.progress(r.Status), max(1, panelWidth-4), false))
runs = append(runs, previewRows(resultLabel(r), max(1, panelWidth-4), 3)...)
runs = append(runs, lipgloss.NewStyle().Foreground(themeMuted).Render(fmt.Sprintf("v%d · %d completed visits · %s", r.Version, r.CompletedSteps, runDuration(r.CreatedAt, r.FinishedAt))))
if r.CurrentStage != "" && (r.Status == "running" || r.Status == "queued") {
@@ -123,7 +123,7 @@ func (m Model) homeLines() []string {
lines = append(lines,
lipgloss.NewStyle().Bold(true).Render(p.Name), lipgloss.NewStyle().Foreground(themeMuted).Render(fmt.Sprintf("v%d · %d stages", p.Version, p.Stages)))
if r := m.latestPipelineRun(p.ID, 0); r != nil {
lines = append(lines, fmt.Sprintf("Last run #%d · v%d · %s", r.ID, r.Version, m.progress(r.Status)))
lines = append(lines, fmt.Sprintf("Last run #%d · %s · v%d · %s", r.ID, r.Label(), r.Version, m.progress(r.Status)))
lines = append(lines, previewRows(resultLabel(*r), max(1, pipelineWidth-4), 2)...)
} else {
lines = append(lines, "Not run yet · no recorded results")
+1 -1
View File
@@ -48,7 +48,7 @@ func (m Model) pipelineResultLines() []string {
if r == nil {
return []string{"Results · This version has not run yet. No accomplishments recorded."}
}
lines := []string{fmt.Sprintf("Results · run #%d · %s · %d completed visits · %s", r.ID, ansi.Strip(m.progress(r.Status)), r.CompletedSteps, runDuration(r.CreatedAt, r.FinishedAt)), resultLabel(*r)}
lines := []string{fmt.Sprintf("Results · run #%d · %s · %s · %d completed visits · %s", r.ID, r.Label(), ansi.Strip(m.progress(r.Status)), r.CompletedSteps, runDuration(r.CreatedAt, r.FinishedAt)), resultLabel(*r)}
if r.Status != "succeeded" && r.ResultPreview != "" && r.Diagnostic != "" {
lines = append(lines, "Partial output: "+ansi.Strip(r.ResultPreview))
}
+3 -3
View File
@@ -126,7 +126,7 @@ func (m Model) visibleRuns() []protocol.RunSummary {
}
labels := make([]string, len(runs))
for i, run := range runs {
labels[i] = fmt.Sprintf("#%d %s v%d %s %s %s %s", run.ID, run.Name, run.Version, run.Status, run.Outcome, run.CurrentStage, run.Diagnostic)
labels[i] = fmt.Sprintf("#%d %s v%d %s %s %s %s", run.ID, run.Label(), run.Version, run.Status, run.Outcome, run.CurrentStage, run.Diagnostic)
}
matched := make([]protocol.RunSummary, 0)
for _, match := range fuzzy.Find(query, labels) {
@@ -589,7 +589,7 @@ func (m Model) runsDetailsView(height int) string {
start, end := selectionWindow(len(runs), m.runIndex, max(1, (height-4-len(rows))/2))
for i := start; i < end; i++ {
r := runs[i]
text := fmt.Sprintf("#%d %s · v%d · %s · %s", r.ID, r.Name, r.Version, m.progress(r.Status), dateLabel(r.FinishedAt))
text := fmt.Sprintf("#%d %s · v%d · %s · %s", r.ID, r.Label(), r.Version, m.progress(r.Status), dateLabel(r.FinishedAt))
rows = append(rows, menuOption(text, i == m.runIndex))
rows = append(rows, " "+ansi.Truncate(resultLabel(r), max(1, m.width-6), "…"))
}
@@ -612,7 +612,7 @@ func (m Model) runsDetailsView(height int) string {
return panel(m.width, height, []string{bar(title, fmt.Sprint(len(runs)), max(1, m.width-4), true)}, rows, footer, true)
}
r := m.runDetail
header := bar(fmt.Sprintf("#%d %s · v%d", r.ID, r.Name, r.Version), m.progress(r.Status)+" · "+runDuration(r.CreatedAt, r.FinishedAt), m.width, false)
header := bar(fmt.Sprintf("#%d %s · v%d", r.ID, r.Label(), r.Version), m.progress(r.Status)+" · "+runDuration(r.CreatedAt, r.FinishedAt), m.width, false)
if height <= 6 {
return fitBlock([]string{header, runHighlight(m.runSelectionLabel(), m.width), m.runActions() + " · Tab pane · Esc back"}, m.width, height)
}
+1 -1
View File
@@ -147,7 +147,7 @@ func (m *Model) startSelectedRun() tea.Cmd {
m.runCollapsed = nil
m.runDetail = nil
m.runTop = 0
request := protocol.Message{Type: protocol.RunPipeline, PipelineID: m.detail.ID, Version: m.detail.Version, RequestKey: fmt.Sprintf("tui-%d", time.Now().UnixNano()), Input: initialRunInput(m.runTask), AllowTools: m.runHasMutationTools(), WritePaths: m.runPaths, Workspace: m.runWorkspace}
request := protocol.Message{Type: protocol.RunPipeline, PipelineID: m.detail.ID, Version: m.detail.Version, RequestKey: fmt.Sprintf("tui-%d", time.Now().UnixNano()), Title: m.cliOptions.Title, Input: initialRunInput(m.runTask), AllowTools: m.runHasMutationTools(), WritePaths: m.runPaths, Workspace: m.runWorkspace}
updated, cmd := m.runRequest(request)
*m = updated.(Model)
return cmd
+18
View File
@@ -43,6 +43,24 @@ func TestRunFormAndInspection(t *testing.T) {
}
}
func TestRunTitleIsShownToOperator(t *testing.T) {
titled := protocol.RunSummary{ID: 1, Name: "bug fix", Version: 2, Title: "Fix the flaky login test", Status: "succeeded"}
if got := titled.Label(); got != "Fix the flaky login test" {
t.Fatalf("Label = %q, want the generated title", got)
}
if got := (protocol.RunSummary{Name: "bug fix"}).Label(); got != "bug fix" {
t.Fatalf("Label without a title = %q, want the pipeline name fallback", got)
}
m := New(context.Background(), "")
m.width = 100
m.height = 28
m.runOpen = true
m.runDetail = &protocol.RunDetail{RunSummary: titled}
if view := ansi.Strip(m.runsDetailsView(24)); !strings.Contains(view, "Fix the flaky login test") {
t.Fatalf("run detail header omitted the title:\n%s", view)
}
}
func runInspectionModel() Model {
m := New(context.Background(), "")
m.width = 100