Skip to content

refactor(experiment): separate iostreams prompts from survey implementations - #404

Merged
zimeg merged 4 commits into
mainfrom
zimeg-refactor-iostreams-prompts
Mar 17, 2026
Merged

refactor(experiment): separate iostreams prompts from survey implementations#404
zimeg merged 4 commits into
mainfrom
zimeg-refactor-iostreams-prompts

Conversation

@zimeg

Copy link
Copy Markdown
Member

Changelog

N/A - "Nothing 'appening" 👻

Summary

This PR separates iostreamsprompts from survey implementations for improvements to test cases and planned changes toward standard flag handling.

Reviewers

No change to logic with this change I hope!

Requirements

@zimegzimeg added this to the Next Release milestone Mar 16, 2026
@zimegzimeg self-assigned this Mar 16, 2026
@zimeg
zimeg requested a review from a team as a code ownerMarch 16, 2026 07:28
@zimegzimeg added code health M-T: Test improvements and anything that improves code health experiment Experimental feature accessed behind the --experiment flag or toggle semver:patch Use on pull requests to describe the release version increment labels Mar 16, 2026
@codecov

codecovBot commented Mar 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.42149% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.16%. Comparing base (f23e6d3) to head (ff364f8).
⚠️ Report is 1 commits behind head on main.

Files with missing linesPatch %Lines
internal/iostreams/prompts.go79.20%19 Missing and 2 partials ⚠️
internal/iostreams/survey.go20.00%14 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #404 +/- ##
==========================================
+ Coverage 67.89% 68.16% +0.27% 
==========================================
Files 217 218 +1 Lines 18015 18020 +5 ==========================================
+ Hits 12231 12284 +53 + Misses 4632 4583 -49 - Partials 1152 1153 +1 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zimegzimeg left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

🔏 A few more notes on changes more!

🍀 I realize the reason to separate prompt interfaces from implementations wasn't noted in the description, but these changes hope to keep interfaces stable as the charm experiment reaches conclusion.

}, nil)
cm.IO.On("InputPrompt", mock.Anything, "Enter an expression", iostreams.InputPromptConfig{
Required: false,
}).Return("")

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

🧪 note: Lots of changes add the expected error value to mock prompts!

Comment on lines -86 to -88
if cfg.PageSize > 0 {
field.Height(cfg.PageSize + 2)
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

🪓 note: Alongside changes of #400 and #401 we're hoping to use default form heights while the experiment for charm prompts remains active.

Comment on lines +192 to +217
// ConfirmPrompt prompts the user for a "yes" or "no" (true or false) value for
// the message
func (io *IOStreams) ConfirmPrompt(ctx context.Context, message string, defaultValue bool) (bool, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmConfirmPrompt(io, ctx, message, defaultValue)
}
return surveyConfirmPrompt(io, ctx, message, defaultValue)
}

// InputPrompt prompts the user for a string value for the message, which can
// optionally be made required
func (io *IOStreams) InputPrompt(ctx context.Context, message string, cfg InputPromptConfig) (string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmInputPrompt(io, ctx, message, cfg)
}
return surveyInputPrompt(io, ctx, message, cfg)
}

// MultiSelectPrompt prompts the user to select multiple values in a list and
// returns the selected values
func (io *IOStreams) MultiSelectPrompt(ctx context.Context, message string, options []string) ([]string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmMultiSelectPrompt(io, ctx, message, options)
}
return surveyMultiSelectPrompt(io, ctx, message, options)
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

👾 note: IIRC callsites often guard against flag inputs, but we might follow up with changes here to accept these in configurations so these prompts guard against scripting fallthrough!

🐌 ramble: I'm curious about the default behavior for confirm prompts too when interactive prompts aren't available since we might use the default choice instead of requiring flag alternatives to perhaps revisit the changes of #87?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree, in non-TTY it should use the default choice and we should offer a flag for each confirm to override the choice.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Thanks for a check here! Let's follow up with defaults and also options as changes to prompts become stable. We're not regressing with current behavior, but it's a known gap now!

zimegand others added 2 commits March 16, 2026 21:36
…ams-prompts
# Conflicts:
#	internal/iostreams/survey.go
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@mwbrooksmwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Looks more organized and thanks for improving the iostreams test coverage!

🧪 I've done a little local testing and I don't see any difference ✨

💬 I feel like a broken record, but I'll just ask that we try to stay focused on the survey-to-huh migration. I think this PR is helping us land in a more organized place with huh. But, I find it difficult to feel 100% confident in PRs that make large changes to our UI logic when our test coverage is still on the lower side.

Comment on lines +192 to +217
// ConfirmPrompt prompts the user for a "yes" or "no" (true or false) value for
// the message
func (io *IOStreams) ConfirmPrompt(ctx context.Context, message string, defaultValue bool) (bool, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmConfirmPrompt(io, ctx, message, defaultValue)
}
return surveyConfirmPrompt(io, ctx, message, defaultValue)
}

// InputPrompt prompts the user for a string value for the message, which can
// optionally be made required
func (io *IOStreams) InputPrompt(ctx context.Context, message string, cfg InputPromptConfig) (string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmInputPrompt(io, ctx, message, cfg)
}
return surveyInputPrompt(io, ctx, message, cfg)
}

// MultiSelectPrompt prompts the user to select multiple values in a list and
// returns the selected values
func (io *IOStreams) MultiSelectPrompt(ctx context.Context, message string, options []string) ([]string, error) {
if io.config.WithExperimentOn(experiment.Charm) {
return charmMultiSelectPrompt(io, ctx, message, options)
}
return surveyMultiSelectPrompt(io, ctx, message, options)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree, in non-TTY it should use the default choice and we should offer a flag for each confirm to override the choice.

@zimeg

Copy link
Copy Markdown
MemberAuthor

@mwbrooks Thank you for taking space to review these changesets 📚 🔍 ✨

I had gotten carried toward bringing the huh prompts to a stable place and hoped this was a meaningful refactor to separate prompts from survey so we can feel confident later in removing that file. I'll merge this now with confidence in the test additions and will keep focusing on focused PRs. I don't mean to test the kindness of amazing reviewers ❤️

@zimeg
zimeg merged commit f3767d6 into mainMar 17, 2026
8 checks passed
@zimeg
zimeg deleted the zimeg-refactor-iostreams-prompts branch March 17, 2026 20:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code healthM-T: Test improvements and anything that improves code healthexperimentExperimental feature accessed behind the --experiment flag or togglesemver:patchUse on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@zimeg@mwbrooks