feat: show confirm prompts as a vertical selection#564
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #564 +/- ##
==========================================
- Coverage 71.68% 71.66% -0.03%
==========================================
Files 226 226
Lines 19140 19144 +4
==========================================
- Hits 13721 13719 -2
- Misses 4214 4216 +2
- Partials 1205 1209 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| // confirmForm interactively prompts for a yes/no confirmation. | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) { | ||
| var choice = defaultValue |
There was a problem hiding this comment.
🌵 question: Is setting the default value to "true" - or the top option - for all confirmation prompts too wild an idea?
🦔 ramble: I found it jarring when testing and think it might be most predictable to prompt from start.
slack-cli/.github/STYLE_GUIDE.md
Lines 16 to 22 in 85f5c96
🏁 ramble: We ought keep flag defaults as is but also that might bring follow up discussion on flag pairings for various prompts. The force flag is overused and unclear IMHO. For the delete example I'd expected instead:
- --force
+ --confirm-deleteThere was a problem hiding this comment.
ahh yes this makes more sense! thank you for sharing that doc 👁️ ❤️
|
|
||
| // confirmForm interactively prompts for a yes/no confirmation. | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) { | ||
| var choice = defaultValue |
| // confirmForm interactively prompts for a yes/no confirmation. | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) { | ||
| var choice = defaultValue | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, _ bool) (bool, error) { |
There was a problem hiding this comment.
note: defualtValue is unused but I renamed it to _ because it's required by the IOStreams interface signature
There was a problem hiding this comment.
@srtaalej IMO we should update the call signature to avoid confusion when passing a value here?
| func confirmForm(io *IOStreams, _ context.Context, message string, _ bool) (bool, error) { | |
| func confirmForm(io *IOStreams, _ context.Context, message string) (bool, error) { |
👾 ramble: I'm unsure how much change that might cause but I think now'd be the right time to keep updates together!
There was a problem hiding this comment.
i actually think that the caller can be updated in a different PR because it touches files outside the scope of this pr 🤔 what do you think
There was a problem hiding this comment.
🔭 @srtaalej I'm understanding removing defaults from confirm prompt for vertical selections is a change to those prompts also?
Fair to follow up with removing this because it's internal refactor but current branch has code in odd state without removing these defaults:
Line 123 in 4e52cbd
Line 139 in 4e52cbd
| // confirmForm interactively prompts for a yes/no confirmation. | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) { | ||
| var choice = defaultValue | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, _ bool) (bool, error) { |
There was a problem hiding this comment.
@srtaalej IMO we should update the call signature to avoid confusion when passing a value here?
| func confirmForm(io *IOStreams, _ context.Context, message string, _ bool) (bool, error) { | |
| func confirmForm(io *IOStreams, _ context.Context, message string) (bool, error) { |
👾 ramble: I'm unsure how much change that might cause but I think now'd be the right time to keep updates together!
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
This reverts commit 4e52cbd.
mwbrooks
left a comment
There was a problem hiding this comment.
🙇🏻 Thanks for putting together this PR @srtaalej!
🧪 I've left some important feedback around default values. I think we need to address it before we can merge this PR.
- We must support default values for the confirmation prompt to avoid regression
- The visual order should never change, just the default selected choice
| // confirmForm interactively prompts for a yes/no confirmation. | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) { | ||
| var choice = defaultValue | ||
| func confirmForm(io *IOStreams, _ context.Context, message string, _ bool) (bool, error) { |
There was a problem hiding this comment.
suggestion: @srtaalej I don't think we can ignore the default value (_ bool). Many commands set the default value to false (No) and this is extremely important to avoid destructive behaviour. For example, deleting an app will default to no because we don't want a developer to accidentally, permanently deleting their App ID.
A quick search shows the following commands deliberately passed false to the confirmation prompt:
cmd/app/delete.go:123- "Are you sure you want to delete the app?"cmd/app/uninstall.go:117- "Are you sure you want to uninstall?"cmd/sandbox/delete.go:87- "Are you sure you want to delete the sandbox?"cmd/app/unlink.go:104- "Are you sure you want to unlink this app?"cmd/externalauth/remove.go:111+- Remove all tokensinternal/api/app.go:799- "Cancel the current request…?"
So we'll want a implementation something like:
func confirmForm(io *IOStreams, _ context.Context, message string, defaultValue bool) (bool, error) {
var choice = defaultValue
err := buildConfirmForm(io, message, &choice).Run()
// ...
}Visually, we want to keep the "Yes / No" order unchanged with "Yes" on top. When the default value is false the second option ("No") will automatically be selected.
┃ Do you want to do this?
┃ Yes
┃ ❱ NoThere was a problem hiding this comment.
thank you for this clarification @mwbrooks! my latest commit reverts the logic back to the initial commit 🫡
| // buildConfirmForm constructs an interactive form for yes/no confirmation prompts. | ||
| func buildConfirmForm(io *IOStreams, message string, choice *bool) *huh.Form { | ||
| field := huh.NewConfirm(). | ||
| field := huh.NewSelect[bool](). |
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej Thank you for working through feedback I shared - let's get this merged with default options to match current patterns. If this feels unexpected in actual use I'm open to revisiting this without fear of breaking form options 🚢 💨



Changelog
Y/N select prompts now display as vertical selection similar to 'slack create'.
Summary
This PR changes the Y/N select prompt from left/right selector to up/down selector.
When using a Yes/No confirm prompt (huh), the currently selected button is hard to distinguish from the unselected one. The ThemeSurvey theme doesn't override the default huh button styles, so it falls through to ThemeBase defaults.
Depending on terminal theme and background color, these can look very similar or the contrast between them isn't obvious enough to tell which one you're currently on.
Preview
Before

After

Testing
Notes
Adresses issue #562
Requirements