fix(gateway): bound task titles in the /tasks and /agents listings (#1076)

This commit is contained in:
sam committed 2026-11-14 15:29:36 +11:00
1 parent c5382a8476
commit 48c28b36ba
1 file changed
+17 -2
+17 -2
View File
@@ -657,6 +657,21 @@ func summarizeParkReason(reason string) string {
return strings.TrimSpace(string(runes[:parkReasonMaxRunes])) + "..."
}
// listingTitleMaxRunes bounds a task title in a listing. New titles are capped
// when created, but a task from another writer (an issue, a schedule) can still
// carry a long one, and a listing line must stay readable.
const listingTitleMaxRunes = 80
// listingTitle reduces a task title to one bounded line.
func listingTitle(title string) string {
line := strings.Join(strings.Fields(title), " ")
runes := []rune(line)
if len(runes) <= listingTitleMaxRunes {
return line
}
return strings.TrimSpace(string(runes[:listingTitleMaxRunes])) + "..."
}
// formatTasks renders each task's id, title, status, workflow/stage and age
// since its last transition.
func formatTasks(tasks []ChatTaskSummary, now time.Time) string {
@@ -672,7 +687,7 @@ func formatTasks(tasks []ChatTaskSummary, now time.Time) string {
if d, ok := taskStateDisplays[t.Status]; ok {
icon, label = d.icon, d.label
}
fmt.Fprintf(&b, "%s #%d %s%s", icon, t.ID, t.Title, reportLineBreak)
fmt.Fprintf(&b, "%s #%d %s%s", icon, t.ID, listingTitle(t.Title), reportLineBreak)
fmt.Fprintf(&b, " %s", label)
if t.Workflow != "" {
fmt.Fprintf(&b, " · %s", t.Workflow)
@@ -1053,7 +1068,7 @@ func (r *Router) handleAgents(ctx context.Context) (string, error) {
var b strings.Builder
b.WriteString("Active agents:\n")
for _, a := range agents {
fmt.Fprintf(&b, " #%d %s — %s (%s)\n", a.ID, a.Title, a.Status, a.Identity)
fmt.Fprintf(&b, " #%d %s — %s (%s)\n", a.ID, listingTitle(a.Title), a.Status, a.Identity)
}
return strings.TrimSpace(b.String()), nil
}