Skip to content

Configure spinner to write to stderr for better output redirection#5122

Merged
pelikhan merged 2 commits intomainfrom
copilot/configure-spinner-to-stderr
Nov 30, 2025
Merged

Configure spinner to write to stderr for better output redirection#5122
pelikhan merged 2 commits intomainfrom
copilot/configure-spinner-to-stderr

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

Spinners currently write to stdout, mixing progress indicators with actual command output when users redirect output to files.

Changes

  • Added spinner.WithWriter(os.Stderr) to spinner initialization
  • Changed TTY detection from IsStdoutTerminal() to IsStderrTerminal() since spinner now writes to stderr

Behavior

# Before: spinner and data both go to file
gh-aw logs download > output.txt

# After: spinner shows in terminal, only data goes to file
gh-aw logs download > output.txt

Follows CLI best practice: progress → stderr, data → stdout.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Configure spinner to write to stderr for better output redirection</issue_title>
<issue_description>## Objective

Configure spinners to write to os.Stderr instead of os.Stdout to follow CLI best practices and enable better output redirection.

Context

CLI tools should write:

  • Progress indicators (spinners, status) → stderr
  • Actual command output (data, results) → stdout

This allows users to redirect actual output while still seeing progress in the terminal.

Current Behavior

gh-aw logs download > output.txt
# Spinner output and actual output both mixed in file

Desired Behavior

gh-aw logs download > output.txt
# Spinner shows in terminal, only data goes to file

Approach

Update spinner initialization in pkg/console/spinner.go to use the WithWriter() option:

func NewSpinner(message string) *SpinnerWrapper {
    // ... TTY detection ...
    
    s := spinner.New(
        spinner.CharSets[14],
        100*time.Millisecond,
        spinner.WithWriter(os.Stderr), // Add this option
    )
    
    // ... rest of setup ...
}

Benefits

  • Better piping: Users can redirect output without spinner interference
  • Best practice alignment: Follows recommended CLI tool design
  • Cleaner output: Progress indicators stay in terminal, data goes where directed

Files to Modify

  • pkg/console/spinner.go - Add spinner.WithWriter(os.Stderr) to initialization

Acceptance Criteria

  • Spinner configured to write to stderr
  • Spinner still displays correctly in terminal
  • Output redirection works correctly (spinner in terminal, data to file)
  • TTY detection behavior unchanged
  • Existing tests pass

Testing

Manual test:

# Spinner should appear in terminal, only logs in file
gh-aw logs download > output.txt

# Check that output.txt contains only actual output
cat output.txt

References

AI generated by Plan Command for discussion #5094

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Configure spinner to write to stderr for output redirection Configure spinner to write to stderr for better output redirection Nov 30, 2025
Copilot AI requested a review from pelikhan November 30, 2025 15:10
@pelikhan pelikhan marked this pull request as ready for review November 30, 2025 17:52
@pelikhan pelikhan merged commit 3bcf82e into main Nov 30, 2025
110 checks passed
@pelikhan pelikhan deleted the copilot/configure-spinner-to-stderr branch November 30, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Configure spinner to write to stderr for better output redirection

2 participants