diff --git a/.nextchanges/air/active-runs-empty-message.md b/.nextchanges/air/active-runs-empty-message.md new file mode 100644 index 00000000000..71e55247c87 --- /dev/null +++ b/.nextchanges/air/active-runs-empty-message.md @@ -0,0 +1 @@ +* `air list` now reports `No active runs found.` for an empty active-only result. ([#7276](https://github.com/databricks/cli/pull/7276)) diff --git a/cmd/air/list.go b/cmd/air/list.go index 4b5c623eccc..b80c644d17e 100644 --- a/cmd/air/list.go +++ b/cmd/air/list.go @@ -173,7 +173,7 @@ Filters: warnIfTruncated(ctx, fetcher) return renderEnvelope(ctx, listData{Rows: rows}) } - return renderListText(cmd, fetcher, limit) + return renderListText(cmd, fetcher, limit, !allStatus) } return cmd diff --git a/cmd/air/list_tui.go b/cmd/air/list_tui.go index 636836a84a0..10ce1ca76dc 100644 --- a/cmd/air/list_tui.go +++ b/cmd/air/list_tui.go @@ -17,7 +17,7 @@ import ( // renderListText renders the table for text output: an inline navigable table in // a terminal (paging in older runs on demand), otherwise printed once. JSON is // handled by the caller. -func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error { +func renderListText(cmd *cobra.Command, f *runFetcher, limit int, activeOnly bool) error { ctx := cmd.Context() out := cmd.OutOrStdout() @@ -36,7 +36,7 @@ func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error { return err } if len(first) == 0 { - _, err := io.WriteString(out, "No runs found.\n") + _, err := io.WriteString(out, emptyListMessage(activeOnly)) return err } _, err = tea.NewProgram( @@ -53,10 +53,21 @@ func renderListText(cmd *cobra.Command, f *runFetcher, limit int) error { return err } warnIfTruncated(ctx, f) + if len(rows) == 0 { + _, err = io.WriteString(out, emptyListMessage(activeOnly)) + return err + } _, err = io.WriteString(out, staticListTable(r, rows, color)) return err } +func emptyListMessage(activeOnly bool) string { + if activeOnly { + return "No active runs found. Use --all-status to include runs that are no longer active.\n" + } + return "No runs found.\n" +} + // staticListTable renders the whole table once, with no selection — used when // piped or non-interactive. func staticListTable(r *lipgloss.Renderer, rows []listRow, links bool) string { diff --git a/cmd/air/list_tui_test.go b/cmd/air/list_tui_test.go index 50dfa7706f1..583cc570c07 100644 --- a/cmd/air/list_tui_test.go +++ b/cmd/air/list_tui_test.go @@ -183,6 +183,11 @@ func TestStaticListTable(t *testing.T) { assert.Equal(t, "No runs found.\n", staticListTable(r, nil, false)) } +func TestEmptyListMessage(t *testing.T) { + assert.Equal(t, "No active runs found. Use --all-status to include runs that are no longer active.\n", emptyListMessage(true)) + assert.Equal(t, "No runs found.\n", emptyListMessage(false)) +} + func TestStatusColor(t *testing.T) { assert.Equal(t, colGreen, statusColor("SUCCESS")) assert.Equal(t, colAmber, statusColor("RUNNING"))