fix(cli): restore progress bars on human format and check tty in auto mode (#4860) - #4875
Closed
dlowzzxx wants to merge 2 commits into
Closed
fix(cli): restore progress bars on human format and check tty in auto mode (#4860)#4875dlowzzxx wants to merge 2 commits into
dlowzzxx wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f333c9c. Configure here.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #4860
Description
In
autooutput mode, AI agent detection (e.g. from terminals like Warp settingTERM_PROGRAM=WarpTerminalor other environment variables matching the agent harness registry) caused progress bars and ANSI colors to be silently disabled, even when running interactively in a user terminal. Additionally, when switching formats back tohumanviaset_mode(OutputFormat.human), progress bars remained disabled becauseenable_progress_bars()was not called.This PR addresses this with:
automode:In
Output.set_mode(), whenmode == OutputFormat.auto, we check ifsys.stderris interactive viais_interactive = bool(getattr(sys.stderr, "isatty", lambda: False)()). We only selectOutputFormat.agentifis_agent() and not is_interactive; otherwise, interactive terminals resolve toOutputFormat.human.When
mode == OutputFormat.human,enable_progress_bars()is called to re-enable progress bars if they had previously been disabled.In
ANSI._format(), colors are preserved if the terminal is interactive, only suppressing colors for agents in non-interactive environments (is_agent() and not bool(getattr(sys.stderr, "isatty", lambda: False)())).set_mode(OutputFormat.agent)still forcesagentmode regardless of TTY status.Reproduction & Verification
test_set_mode_human_reenables_progress_bars,test_auto_resolves_to_human_in_interactive_terminal_even_if_agent, andtest_ansi_agent_interactive_preserves_colorfailed with progress bars remaining disabled and mode resolving to agent in interactive sessions.tests/test_cli_output.pyandtests/test_utils_terminal.py.uv run pytest tests/test_cli_output.py(36 passed)uv run pytest tests/test_utils_detect_agent.py(17 passed)uv run pytest tests/test_utils_terminal.py(6 passed)uv run --with ruff ruff check src tests(clean)uv run --with ruff ruff format --check src tests(clean)Note
Low Risk
CLI output and TTY detection only; no auth, data handling, or API behavior changes.
Overview
Fixes agent auto-detection treating interactive terminals (e.g. Warp) like headless agent sessions, which turned off progress bars and ANSI styling even for real users.
Auto format now picks
agentonly whenis_agent()is true andstderris not a TTY; interactive sessions stay on human mode. Explicit--format agentstill forces agent mode and disables bars.Adds a defensive
is_terminal()helper (used byOutput,StatusLine, andANSI) soisatty()on missing/closed streams does not crash. Human mode callsenable_progress_bars()again when switching back (unlessHF_HUB_DISABLE_PROGRESS_BARSis set). ANSI keeps color in interactive terminals even whenis_agent()is true; colors stay suppressed only for non-interactive agent runs.Regression tests cover mode resolution, progress bar toggling, and ANSI behavior.
Reviewed by Cursor Bugbot for commit 87c0fb8. Bugbot is set up for automated code reviews on this repo. Configure here.