Skip to content

fix: render interactive prompts once on Windows by using ux components#8648

Closed
RickWinter wants to merge 2 commits into
mainfrom
rickwinter/fix-duplicate-environment-name-prompt
Closed

fix: render interactive prompts once on Windows by using ux components#8648
RickWinter wants to merge 2 commits into
mainfrom
rickwinter/fix-duplicate-environment-name-prompt

Conversation

@RickWinter

Copy link
Copy Markdown
Member

Summary

Fixes #435.

On Windows terminals (PowerShell 7, Windows Terminal, VS Code terminal), azd's interactive prompts render twice — after the user submits a value, the prompt and its answer are redrawn above the next prompt. Originally reported for the azd init environment-name prompt, later confirmed for Select/Confirm prompts as well.

Root cause

azd uses the archived AlecAivazis/survey library for interactive input. survey has a long-standing Windows-specific double-render bug (survey#368, #406, #479) that was never fixed upstream; the project was archived in April 2024.

Fix

Per maintainer guidance on the issue, route the terminal rendering path of Prompt, Select, Confirm, and MultiSelect through the in-repo pkg/ux components (ux.NewPrompt, ux.NewSelect, ux.NewConfirm, ux.NewMultiSelect). These components render prompts themselves and do not exhibit the double-render.

The non-terminal, --no-prompt, and external prompt-client (promptClient) paths are left untouched, so machine-friendly behavior used by tests, CI, and piped stdin is unchanged.

Changes

  • New cli/azd/pkg/input/console_ux.go: promptUx, selectUx, confirmUx, multiSelectUx helpers, plus:
    • mapUxCancel — maps ux.ErrCancelled to surveyterm.InterruptErr so existing Ctrl+C / interrupt handling continues to work.
    • optionLabel — preserves the gray "(detail)" suffix previously rendered for select option details.
  • cli/azd/pkg/input/console.go: each of the four methods now dispatches to its ux helper when c.isTerminal.

Testing

  • go build ./... — clean
  • go test ./pkg/input/... — pass
  • golangci-lint run ./... — 0 issues
  • mage preflight — gofmt, go fix, copyright, cspell, cspell-misc, build, and test all pass.

Note: The playback functional tests fail in the sandbox with downloading bicep: http error 400 (no Bicep binary available and the recordings don't include its download). These failures are environmental and unrelated to this change; the prompt portions of those flows succeed.

Manual Windows verification recommended on each prompt type to confirm single-render output.

azd used the archived AlecAivazis/survey library for interactive input,
which has an unfixed Windows-specific bug that re-renders a prompt and its
answer above the next prompt. Route the terminal path of Prompt, Select,
Confirm, and MultiSelect through the in-repo pkg/ux components, which render
prompts themselves and do not exhibit the double-render. Non-terminal,
no-prompt, and external prompt-client paths are unchanged.

Fixes #435

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 15, 2026 16:55
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Review may take a bit longer — reach out to @rajeshkamal5050 or @kristenwomack if you'd like to discuss prioritization.

@RickWinter

Copy link
Copy Markdown
Member Author

Re-opening from a branch on my fork (RickWinter/azure-dev) per workflow.

@RickWinter RickWinter closed this Jun 15, 2026
@RickWinter RickWinter deleted the rickwinter/fix-duplicate-environment-name-prompt branch June 15, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Windows terminal-specific UX issue where interactive prompts render twice by routing the terminal prompt flow in pkg/input through azd’s in-repo pkg/ux components instead of the archived AlecAivazis/survey rendering path.

Changes:

  • Dispatch terminal-mode Prompt, Select, Confirm, and MultiSelect to new ux-backed helpers.
  • Add console_ux.go with ux-backed implementations plus cancel/error mapping and option labeling.
  • Add a changelog entry documenting the Windows double-render fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
cli/azd/pkg/input/console.go Routes terminal prompt APIs through new ux-backed helper methods.
cli/azd/pkg/input/console_ux.go Implements ux-backed prompt/select/confirm/multiselect wrappers and cancellation mapping.
cli/azd/CHANGELOG.md Documents the fix in the unreleased changelog.

Comment on lines +722 to +724
if c.isTerminal {
return c.promptUx(ctx, options)
}
Comment on lines +788 to +790
if c.isTerminal {
return c.selectUx(ctx, options)
}
Comment on lines +865 to +867
if c.isTerminal {
return c.multiSelectUx(ctx, options)
}
Comment on lines +946 to +948
if c.isTerminal {
return c.confirmUx(ctx, options)
}
Comment on lines +75 to +82
func (c *AskerConsole) selectUx(ctx context.Context, options ConsoleOptions) (int, error) {
choices := make([]*uxlib.SelectChoice, len(options.Options))
for i, option := range options.Options {
choices[i] = &uxlib.SelectChoice{
Value: option,
Label: optionLabel(options, i),
}
}
Comment on lines +146 to +149
func (c *AskerConsole) multiSelectUx(ctx context.Context, options ConsoleOptions) ([]string, error) {
defaultValues, _ := options.DefaultValue.([]string)

choices := make([]*uxlib.MultiSelectChoice, len(options.Options))
Comment on lines +158 to +163
component := uxlib.NewMultiSelect(&uxlib.MultiSelectOptions{
Writer: c.writer,
Message: options.Message,
HelpMessage: options.Help,
Choices: choices,
})
Comment on lines +36 to +38
// optionLabel returns the display label for an option, appending the gray detail
// text (when present) the same way the previous survey-based rendering did.
func optionLabel(options ConsoleOptions, index int) string {
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.

The prompt for environment name shows up twice (Windows, PowerShell 7)

2 participants