Open
Conversation
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: 0dbe649
21 interesting tests: 9 RECOVERED, 5 SKIP, 5 flaky, 2 KNOWN
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>
pietern
reviewed
Feb 13, 2026
| // happen early in command setup before cmdio is configured in the context. | ||
| // The caller is expected to treat unknown as a no-op and skip adding the mode. | ||
| func GetInteractiveMode(ctx context.Context) InteractiveMode { | ||
| c, ok := ctx.Value(cmdIOKey).(*cmdIO) |
Contributor
There was a problem hiding this comment.
Why not fromContext like the other accessors?
IMO, it is a feature to panic if initialization hasn't happened.
| const ( | ||
| InteractiveModeUnknown InteractiveMode = "" // cmdio not initialized in context | ||
| InteractiveModeFull InteractiveMode = "full" // Both interactive output and prompts supported | ||
| InteractiveModeOutputOnly InteractiveMode = "output_only" // Interactive output only, no prompts (stdin not TTY or Git Bash) |
Contributor
There was a problem hiding this comment.
Can rename to just "output" to save a few chars, implies the same.
| ua := useragent.FromContext(ctx) | ||
|
|
||
| if !strings.Contains(ua, "interactive/") { | ||
| t.Errorf("expected user agent to contain 'interactive/', got %s", ua) |
| const interactiveModeKey = "interactive" | ||
|
|
||
| func withInteractiveModeInUserAgent(ctx context.Context) context.Context { | ||
| // mode is empty when cmdio is not initialized in the context (e.g., early startup). |
Contributor
There was a problem hiding this comment.
When does this happen? Per the other fromContext comment I think we can omit this case entirely.
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.
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: