Azure / Azure/azure-dev

Consolidate interactive input/output capabilities into GlobalCommandOptions

Open
#7,391 1 comment 0 reactions 1 assignee Claimed by @spboyer View on GitHub
area/core-cli enhancement
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

## Summary

Refactor the interactivity model to expose explicit `SupportsInteractiveInput` and `SupportsInteractiveOutput` properties in a single location, rather than splitting the logic across `GlobalCommandOptions.NoPrompt` and `terminal.IsTerminal()`.

## Motivation

azd currently uses two separate mechanisms for interactivity:

- **`NoPrompt`** (in `GlobalCommandOptions`): Suppresses interactive input prompts
- **`isTerminal`** (from `terminal.IsTerminal()`): Controls output rendering (spinners, colors, terminal resize)

These two concepts are spread across different parts of the codebase with no unified model. This makes it harder to reason about what capabilities are available in a given context and creates subtle bugs when they interact.

Consolidating them into explicit properties would:

- **Make the interactivity model self-documenting** — one place to check what's supported
- **Allow commands to check capabilities uniformly** — instead of mixing `NoPrompt` checks with `isTerminal` checks
- **Simplify future enhancements** — e.g., MCP tools that can handle prompts (via external prompt endpoint) but don't support spinners
- **Reduce the cognitive load** for new contributors understanding the codebase

## Implementation Notes

- Add `SupportsInteractiveInput` and `SupportsInteractiveOutput` to `GlobalCommandOptions` or a new `InteractivityContext` type
- Derive values from: explicit flags (`--no-prompt`, `--non-interactive`), env vars, agent detection, TTY detection
- Update `Console`/`AskerConsole` to consume these properties instead of separate `noPrompt` + `isTerminal` booleans
- This is a refactoring — no user-facing behavior change expected

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.