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
2 changes: 1 addition & 1 deletion pkg/cli/logs_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ func downloadRunArtifactsConcurrent(ctx context.Context, runs []WorkflowRun, out

// Clear progress bar silently - detailed summary shown at the end
if progressBar != nil {
fmt.Fprint(os.Stderr, "\r\033[K") // Clear the line
console.ClearLine() // Clear the line
}

if verbose {
Expand Down
8 changes: 8 additions & 0 deletions pkg/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ func ClearScreen() {
}
}

// ClearLine clears the current line in the terminal if stderr is a TTY
// Uses ANSI escape codes: \r moves cursor to start, \033[K clears to end of line
func ClearLine() {
if tty.IsStderrTerminal() {
fmt.Fprint(os.Stderr, "\r\033[K")
}
}

// TreeNode represents a node in a hierarchical tree structure
type TreeNode struct {
Value string
Expand Down
14 changes: 14 additions & 0 deletions pkg/console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,20 @@ func TestClearScreen(t *testing.T) {
})
}

func TestClearLine(t *testing.T) {
// ClearLine should not panic when called
// It only clears if stderr is a TTY, so we can't easily test the output
// but we can verify it doesn't panic
t.Run("clear line does not panic", func(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("ClearLine() panicked: %v", r)
}
}()
ClearLine()
})
}

func TestRenderTree(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading