fix: render interactive prompts once on Windows by using ux components#8648
Closed
RickWinter wants to merge 2 commits into
Closed
fix: render interactive prompts once on Windows by using ux components#8648RickWinter wants to merge 2 commits into
RickWinter wants to merge 2 commits into
Conversation
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>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Member
Author
|
Re-opening from a branch on my fork (RickWinter/azure-dev) per workflow. |
Contributor
There was a problem hiding this comment.
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, andMultiSelectto new ux-backed helpers. - Add
console_ux.gowith 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 { |
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.
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 initenvironment-name prompt, later confirmed for Select/Confirm prompts as well.Root cause
azd uses the archived
AlecAivazis/surveylibrary 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, andMultiSelectthrough the in-repopkg/uxcomponents (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
cli/azd/pkg/input/console_ux.go:promptUx,selectUx,confirmUx,multiSelectUxhelpers, plus:mapUxCancel— mapsux.ErrCancelledtosurveyterm.InterruptErrso 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 itsuxhelper whenc.isTerminal.Testing
go build ./...— cleango test ./pkg/input/...— passgolangci-lint run ./...— 0 issuesmage preflight— gofmt, go fix, copyright, cspell, cspell-misc, build, and test all pass.Manual Windows verification recommended on each prompt type to confirm single-render output.