Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions internal/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,30 @@ func TestFormatCellWithMapArray(t *testing.T) {
}
result = formatCell(attachments)
assert.Equal(t, "100, 200", result)

// Test maps with summary fallback (schedule entries: the reports/upcoming API
// uses the calendar partial which emits summary but not title, so title arrives
// as an empty string from the SDK zero-value; summary must win).
entries := []any{
map[string]any{"id": float64(1), "title": "", "summary": "Team standup"},
map[string]any{"id": float64(2), "title": "", "summary": "Paul G OUT (Sabbatical)"},
}
result = formatCell(entries)
assert.Equal(t, "Team standup, Paul G OUT (Sabbatical)", result)

// Test that a non-empty title still wins over summary.
withBoth := []any{
map[string]any{"id": float64(1), "title": "Explicit title", "summary": "Summary text"},
}
result = formatCell(withBoth)
assert.Equal(t, "Explicit title", result)

// Test that an empty name does not shadow a valid title (empty-string guard).
emptyName := []any{
map[string]any{"id": float64(1), "name": "", "title": "A task"},
}
result = formatCell(emptyName)
assert.Equal(t, "A task", result)
}

// =============================================================================
Expand Down
11 changes: 8 additions & 3 deletions internal/output/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,16 @@ func formatCell(val any) string {
case int, int64:
items = append(items, fmt.Sprintf("%d", elem))
case map[string]any:
// Try name, then title, then id, then fallback
if name, ok := elem["name"].(string); ok {
// Try name → title → summary → id.
// summary is checked after title because schedule entries omit title
// from the calendar/reports API response and use summary as their
// display name (Schedule::Entry#title delegates to summary in bc3).
if name, ok := elem["name"].(string); ok && name != "" {
items = append(items, ansi.Strip(name))
} else if title, ok := elem["title"].(string); ok {
} else if title, ok := elem["title"].(string); ok && title != "" {
items = append(items, ansi.Strip(title))
} else if summary, ok := elem["summary"].(string); ok && summary != "" {
items = append(items, ansi.Strip(summary))
} else if id, ok := elem["id"]; ok {
items = append(items, fmt.Sprintf("%v", id))
Comment thread
robzolkos marked this conversation as resolved.
}
Expand Down
Loading