-
Notifications
You must be signed in to change notification settings - Fork 145
Add interactive mode to user agent #4497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonfaltum
wants to merge
7
commits into
main
Choose a base branch
from
add-interactive-mode-to-user-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
This change adds terminal capability detection to the user agent string to track what proportion of CLI invocations support interactive features. The field captures one of three values in the user agent: - "interactive/full": Both interactive output (spinners, colors) and user prompts are supported. Requires stderr to be a TTY, color enabled, stdin to be a TTY, and not running in Git Bash. - "interactive/output_only": Interactive output is supported but prompts are not. This occurs when stdin is not a TTY (e.g., input piped) or when running in Git Bash (which has broken readline/ANSI support). - "interactive/none": Non-interactive environment where neither spinners nor prompts work. This includes CI/CD pipelines, cron jobs, and cases where stderr is redirected. Changes: - Add InteractiveMode() method to Capabilities struct in libs/cmdio - Add GetInteractiveMode(ctx) public function for context-safe access - Create user_agent_interactive_mode.go to integrate with user agent - Add withInteractiveModeInUserAgent() call in root.go Why user agent instead of telemetry: - User agent data is captured on every authenticated API call across all commands, while telemetry only fires on bundle deploy - No latency impact (telemetry is sent synchronously) - Data goes to eng_deco_usage.deco_usage_logs_normalized for broader visibility This will help inform decisions about when the CLI can prompt users for missing information versus requiring explicit flags.
Collaborator
|
Commit: 99bfcf1
20 interesting tests: 8 KNOWN, 5 SKIP, 5 RECOVERED, 2 flaky
Top 50 slowest tests (at least 2 minutes):
|
- Replace testify assertions with standard Go testing in user_agent_interactive_mode_test.go (new code should not use testify) - Add test for interactive/none mode in user agent - Add comment explaining why GetInteractiveMode returns "" when cmdio is not initialized in the context
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Changes
This PR adds terminal capability detection to the user agent string to track what proportion of CLI invocations support interactive features.
Having a better understanding of how the CLI is being used, and which commands are called in which context, can help guide us to improve the UX without over-investing in commands that are never used in a certain context
The user agent will include one of three values:
interactive/full: Both interactive output (spinners, colors) and user prompts are supported. Requires stderr to be a TTY, color enabled, stdin to be a TTY, and not running in Git Bash.interactive/output_only: Interactive output is supported but prompts are not. This occurs when stdin is not a TTY (e.g., input piped) or when running in Git Bash (which has broken readline/ANSI support).interactive/none: Non-interactive environment where neither spinners nor prompts work. This includes CI/CD pipelines, cron jobs, and cases where stderr is redirected.Implementation
InteractiveMode()method toCapabilitiesstruct inlibs/cmdioGetInteractiveMode(ctx)public function for context-safe accesscmd/root/user_agent_interactive_mode.goto integrate with user agentwithInteractiveModeInUserAgent()call inroot.goWhy User Agent Instead of Telemetry
As discussed with @pietern, this should be added to the user agent rather than telemetry because:
bundle deployUse Case
This telemetry helps inform decisions about when the CLI can prompt users for missing information versus requiring explicit flags. By measuring the proportion of invocations in each mode, we can understand how often interactive prompts would actually be shown to users.
This will also help track the impact of changes that affect interactive behavior.
Tests
Added comprehensive unit tests covering: